There are five types of commands in SQL based on the type of operation they perform.
DDL or Data Definition Language
Used in defining or manipulating database schema. These are used for creating, modifying, and dropping the structure of database objects such as tables.
CREATE TABLE | DATABASE <object_name>
ALTER TABLE <table_name>
DROP TABLE | DATABASE <object_name>
DML or Data Modification Language
Used in creating, updating or deleting data from the database objects such as tables.
INSERT INTO TABLE <table_name>
UPDATE <table_name> SET <column_name>=<new_value>
DELETE [ <column_name> | * ] FROM <table_name>
DCL or Data Control Language
Used enforce access control to data within the database or database objects.
GRANT <previlige_name> ON <object_name> TO <user_name>
REVOKE <previlige_name> ON <object_name> FROM <user_name>
TCL or Transaction Control Language
Used to enforce control on transactions within a database object which might result in a change in the state of data within the database objects.
COMMIT
ROLLBACK [ TO save_point_name ]
SAVEPOINT save_point_name
DQL or Data Query Language
Used for querying data from database objects. SELECT query is the only single command which can result in records from Database Objects such as tables, views etc and can be subject to projection.
The following table represents the command types and the SQL commands –
Command Type | SQL Commands |
---|---|
Data Definition Language | CREATE, ALTER, DROP |
Data Modification Language | INSERT, UPDATE, DELETE |
Data Control Language | GRANT, REVOKE |
Transaction Control Language | COMMIT, ROLLBACK, SAVEPOINT |
Data Query Language | SELECT |