Introduction to SQL

Structure Query Language or in short form SQL is a database query language usually employed in storing and managing data in Relational DBMS. It is known to be the first commercial language introduced for E.F Codd's Relational model of a database. Currently, all RDBMS including Oracle, MySql, MS Access, Infomix, and Sybase, use SQL as their standard database query language. Structure Query Language is used to perform all types of data operations in RDBMS.

 

SQL Command

Below you will see how SQL defines different ways you can manipulate data stored in an RDBMS.

 

DDL: Data Definition Language

Data Definition Language includes changes to the structure of the table such as the creation of a table, altering a table, deleting a table, and so on.

Any command in DDL is auto-committed. This means it saves all the changes permanently in the database.

CommandDescription
createIt is used to create new table or database
alterIt is used for alteration
truncateIt is used to delete data from table
dropIt is used to drop a table
renameIt is used to rename a table

 

DML: Data Manipulation Language

Data Manipulation Language or DML commands are basically employed in the manipulation of data stored in the table and not the table itself.

The command in DML is not auto-committed. That its changes are not permanent to the database but can be rolled back.

CommandDescription
insertIt is used to insert a new row
updateIt is used to update an existing row
deleteIt is used to delete a row
mergeIt is used to merge two rows or two tables


TCL: Transaction Control Language

The commands in Transaction Control Language are used to keep a check on other commands and what they do on the database. TCL commands can cancel or annul changes made by other commands by rolling the data back to its original state. They can also be used to make a temporary change permanent.

CommandDescription
commitIt is used to permanently save
rollbackIt is used to undo the change
savepointIt is used to save temporarily

 

DCL: Data Control Language

The commands in DCL are typically used to grant and take back authority from any database user.

CommandDescription
grantIt is used to grant permission for right
revokeIt is used to take back permission.


DQL: Data Query Language

The command in Data query language is basically used to fetch data from tables based on conditions that can be easily applied.

CommandDescription
selectIt is used to retrieve records from one or more table