Google+ Followers

Tuesday, August 26, 2014

Types of SQL Command

SQL stands for Structured Query Language which is used against RDBMS to manage data.

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

1-      DDL (Data Definition Language)
2-      DML (Data Manipulation Language )
3-      DRL (Data Retrieval Language )
4-      TCL (Transaction Control Language)
5-      DCL (Data Control Language)

DDL (Data Definition Language) Statements are used to define the database object structure. DDL commands are auto- committed.

·         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.

DML (Data Manipulation Language) Statements are used to  Store, Modify, Delete data in database. DML commands are not auto-committed.

·         INSERT –Used to  insert data into a table, "INTO" KEYWORD is not necessary in the query. You can insert default values using this insert statement : INSERT TABLENAME DEFAULT VALUES().
·         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.

·         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.

·         GRANT – This command gives user access privileges to database
·         REVOKE – This command withdraw access privileges given with the GRANT command

I hope you enjoyed the article don't forget to share on Facebook. Please leave your comments below if there are any questions.

No comments: