Five Point Someone – Chetan Bhagat | Book Summary & Analysis by Bhupesh KushwahaBhupesh Kushwaha
An introduction to Prepositions for beginners.pptxdrsiddhantnagine
Information Texts_Infographic on Forgetting Curve.pptxTata Sevilla
The Picture of Dorian Gray summary and depictionopaliyahemel
Introduction to Structured Query Language
1. Sanjivani Rural Education Society’s
Sanjivani College of Engineering, Kopargaon-423 603
(An Autonomous Institute, Affiliated to Savitribai Phule Pune University, Pune)
NACC ‘A’ Grade Accredited, ISO 9001:2015 Certified
Department of Computer Engineering
(NBA Accredited)
Prof. Monika Agrawal
Assistant Professor
E-mail : [email protected]
Contact No: 8770361037
Course:CO210
Database Management System
Unit 2
Lecture-01 Introduction
2. Content
s
DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon 2
Characteristics of SQL
SQL Data Types
Data Definition Language
Data Manipulation Language
Data Control Language
Transaction Control Language
3. What is SQL ?
•SQL stands for Structured Query Language
•SQL lets you access and manipulate databases
•SQL became a standard of the American National Standards Institute (ANSI)
in 1986, and of the International Organization for Standardization (ISO) in
1987
•SQL widely used Non procedural language.
4. Characteristics of SQL
DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon 3
SQL is easy to learn.
SQL is used to access data from relational database management systems.
SQL can execute queries against the database.
SQL is used to describe the data.
SQL is used to define the data in the database and manipulate it when needed.
SQL is used to create and drop the database and table.
SQL is used to create a view, stored procedure, function in a database.
SQL allows users to set permissions on tables, procedures, and views.
5. Advantages SQL
DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon 4
• High Speed.
• No coding needed.
• Well defined standards.
• Portability.
• Non Procedurally – SQL DML is Non Procedural.
• Interactive language.
• Multiple data views.
6. Database Tables
• A database most often contains one or more tables.
• Each table is identified by a name (e.g. "Customers" or "Orders"), and contain
records (rows) with data.
• The table above contains five records (one for each customer) and seven columns (CustomerID,
CustomerName, ContactName, Address, City, PostalCode, and Country).
7. Rules to write commands:
• Table names cannot exceed 20 characters.
• Name of the table must be unique.
• Field names also must be unique.
• The field list and filed length must be enclosed in parentheses.
• The user must specify the field length and type.
• The field definitions must be separated with commas.
• SQL statements must end with a semicolon.
8. SQL (Cont.)
DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon 6
• Example: Find the name of the customer with customer-id 192-83-7465
select
from
where
customer.customername
customer
customer.customerid =
‘192-83-7465’
• Application programs generally access databases through one of
• Language extensions to allow embedded SQL
• Application program interface (e.g., ODBC/JDBC) which allow SQL
queries to be sent to a database
9. SQL Data Types
DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon 7
• char(n). Fixed length character string, with user-specified length n.
• varchar(n). Variable length character strings, with user-specified maximum
length n.
• int. Integer (a finite subset of the integers that is machine-dependent). Signed
range is from -2147483648 to 2147483647. Unsigned range is from 0 to
4294967295.
• smallint. Small integer (a machine-dependent subset of the integer domain
type). Signed range is from -32768 to 32767. Unsigned range is from 0 to 65535.
• float(p,d). Fixed point number, with user-specified precision of p digits,
with
n digits to the right of decimal point.
• real, double precision. Floating point and double-precision floating point
numbers, with machine-dependent precision.
• float(n). Floating point number, with user-specified precision of at least n
digits.
11. Data Definition Language
DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon 9
• DDL or Data Definition Language actually consists of the SQL
commands that can be used to define the database schema.
• It simply deals with descriptions of the database schema and is used
to create and modify the structure of database objects in the database.
• DDL is a set of SQL commands used to create, modify, and delete
database structures but not data.
12. List of DDL commands:
•CREATE: This command is used to create the database or its objects (like
table, index, function, views, store procedure, and triggers).
•DROP: This command is used to delete objects from the database.
•ALTER: This is used to alter the structure of the database.
•TRUNCATE: This is used to remove all records from a table, including all
spaces allocated for the records are removed.
•COMMENT: This is used to add comments to the data dictionary.
•RENAME: This is used to rename an object existing in the database.
13. Data Definition Language(Cont.)
DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon 10
Specification notation for defining the database schema
Example: create table account (
account-number
balance
char(10),
integer)
DDL compiler generates a set of tables stored in a data dictionary
Data dictionary contains metadata (i.e., data about data)
Database schema
Data storage and definition language
Specifies the storage structure and access methods used
Integrity constraints
Domain constraints
Referential integrity (references constraint in SQL)
Assertions
Authorization
14. Data Manipulation Language (DML)
DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon 11
Language for accessing and manipulating the data organized by the
appropriate data model
DML also known as query language
Two classes of languages
Procedural – user specifies what data is required and how to get
those data
Declarative (nonprocedural) – user specifies what data is required
without specifying how to get those data
SQL is the most widely used query language
15. List of DML commands:
DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon 12
•INSERT: It is used to insert data into a table.
•UPDATE: It is used to update existing data within a table.
•DELETE: It is used to delete records from a database table.
•LOCK: Table control concurrency.
•CALL: Call a PL/SQL or JAVA subprogram.
•EXPLAIN PLAN: It describes the access path to data.
16. DQL
• We can define DQL as follows it is a component of SQL
statement that allows getting data from the database and
imposing order upon it.
• It includes the SELECT statement.
• When a SELECT is fired against a table or tables the result is
compiled into a further temporary table, which is displayed or
perhaps received by the program i.e. a front-end.
List of DQL:
•SELECT: It is used to retrieve data from the database.
17. DCL
DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon 13
DCL includes commands such as GRANT and REVOKE which mainly deal
with the rights, permissions, and other controls of the database system.
GRANT: This command gives users access privileges to the database.
Syntax:
GRANT SELECT, UPDATE ON MY_TABLE TO SOME_USER, ANOTHER_USER;
REVOKE: This command withdraws the user’s access privileges given by using
the GRANT command.
Syntax:
REVOKE SELECT, UPDATE ON MY_TABLE FROM USER1, USER2;
18. TCL
DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon 14
Transactions group a set of tasks into a single execution unit.
Each transaction begins with a specific task and ends when all the
tasks in the group are successfully completed.
If any of the tasks fail, the transaction fails.
Therefore, a transaction has only two results: success or failure.
COMMIT: Commits a Transaction.
Syntax:
COMMIT;
ROLLBACK: Rollbacks a transaction in case of any error occurs.
Syntax:
ROLLBACK;
SAVEPOINT: Sets a save point within a transaction.
Syntax:
SAVEPOINT SAVEPOINT_NAME;