Wednesday, July 24, 2013

Types of Commands

SQL stands for Structured Query Language and pronounced as 'Sequel' which is used against RDBMS to manage data.SQL is a computer language for accessing databases. It is used to store, manipulate and retrieve the data stored in a database.

SQL is a standard that every database should follow. That means all the SQLcommands should
work in all databases. Based on the type of operations we are performing on the database,

SQL commands have been divided in many categories but frequently used commands are:



       DDL (Data Definition Language)
       DML (Data Manipulation Language )
       DRL (Data Retrieval Language )
       TCL (Transaction Control Language)
       DCL (Data Control Language)


DDL (Data Definition Language) Statements are used to define the structure of database objects. DDL commands are auto- committed. It is used to create an object (e.g table), alter the structure of an object and also to delete the object from the server. All these commands will effect only the structure of the database object. The commands contained by this language are :
  • CREATE - Used to create Objects in Database i.e Table, Views, Triggers etc.
  • ALTER – Used to modify Object Structure in Database.
  • DROP – Used to Delete Objects from Database.
  • TRUNCATE – Removes all records from a Table.
  • RENAME – used to rename an existing database object.
Note : DDL commands are AUTO COMMIT. i.e with the execution of these commands, the results will be stored directly into the database.


DML (Data Manipulation Language) Statements are used to Store, Modify, Delete data in database. DML commands are not auto-committed.The DML commands are most frequently used SQL Commands. They are used to query and manipulate existing objects like tables. They should affect only the data of an existing structure. The commands existing in this language are:
  • INSERT    –Used to insert data into a table
  • UPDATE – Used to updates existing data within a table
  • DELETE – Used to deletes records from a table
  • MERGE  – Used for insert-update operation.

DRL (Data Retrieval Language) Statements are used to Retrieve data from the database.
  • SELECT – Used to retrieve data from the a database

TCL (Transaction Control Language) these commands are used to manage transaction in database. These are used to manage changes made by DML. A transaction is a logical unit of work. All changes made to the database can be referred to as a transaction.Whenever, we perform a DML operation, results will be stored in the buffer not in the database. The user can control Transaction changes with the use of this language commands. They are :
  • COMMIT      – Permanently save work in database.
  • SAVEPOINT – This command identify a point in a transaction so that you can roll back later                              if required.
  • ROLLBACK – This command restores database to original since the last COMMIT




DCL (Data Control Language) these commands are used to manage privilege in database. In general to access an object which was created by another user, at first, we must get the permission from the owner of the object. To provide the permission or remove the permission, we use this language commands. They are
  • GRANT – This command gives user access privileges to database
  • REVOKE – This command withdraw access privileges given with the GRANT command