Introduction to SQL:
- SQL stands for Structured Query Language(SQL).
- It is a database query language used for storing and managing data in RDBMS.
- RDBMS stands for Relational DBMS.
- DBMS stands for Data Base Management System.
- SQL was the first commercial language introduced for E.F Codd's Relational model of database.
- Today almost all RDBMS (MySql, Oracle, Informix, Sybase, MS Access) use SQL as the standard database query language.
- SQL is used to perform all types of data operations in RDBMS.
- SQL defines the following ways to manipulate data stored in an RDBMS.
- DDL: Data Definition Language
- This includes changes to the structure of the table like the creation of table, altering table, deleting a table, etc.
- All DDL commands are auto-committed.
- That means it saves all the changes permanently in the database.
- Example:
- create: to create a new table or database
- alter: for alteration
- truncate: delete data from table
- drop: to drop a table
- rename: to rename a table
- DML: Data Manipulation Language
- DML commands are used for manipulating the data stored in the table and not the table itself.
- DML commands are not auto-committed.
- It means changes are not permanent to the database, they can be rolled back.
- Example:
- 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 effect on the database.
- These commands can annul changes made by other commands by rolling the data back to its original state.
- It can also make any temporary change permanent.
- Example:
- 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.
- Example:
- grant: grant permission of right
- revoke: take back permission.
- DQL: Data Query Language
Tags:
DBMS