Database Systems - Structured Query Language (SQL)
Database Systems - Structured Query Language (SQL)
CS-222
Lecture 9
“Structured Query Language (SQL)”
• Standardization:
• American National Standards Institute (ANSI) in 1986,
• International Organization for Standardization (ISO) in 1987
RELATIONS IN SQL
Product
Table name
PName Price Category Manufacturer
Tuples or rows
What can SQL do with databases?
Execute
Create stored Delete
queries Insert records Create views
procedures in records from
against a in a database in a database
a database a database
database
• CONSTANTS/VALUES:
• Correct ‘abc’
• Wrong “abc”
• Use single quote (‘) for strings/character values
• ‘Ahmed Khan’ , ‘Peshawar’ , ‘+92-3331234567
• Use grave accent (`) for object names
• `table_name` , `std_info_view` , `procedure1`
SQL COMMANDS
• SQL defines following ways to manipulate data stored in an RDBMS.
Command Description
INSERT to insert a new row
UPDATE to update existing row
DELETE to delete a row
MERGE merging two rows or two tables
TCL: Transaction Control Language
• These commands are to keep a check on other commands and their
affect on the database.
• It can also make any temporary change permanent.
Command Description
COMMIT to permanently save
ROLLBACK to undo change
SAVEPOINT to save temporarily
DCL: Data Control Language
• Data control language are the commands to grant and take back
authority from any database user.
Command Description
GRANT grant permission of right
REVOKE take back permission.
DQL: Data Query Language
• Data query language is used to fetch data from tables based on
conditions that we can easily apply
Command Description
SELECT retrieve records from one or more table
SUMMARY
• SQL: A language used for management of RDBMS