Explain SQL subcategories giving at least one example in each category.
Answers
SQL commands can be classified into following categories:
(i) Data Definition Language(DDL): They are used to define the structure of tables and other objects in a database.
For example: CREATE, ALTER, DROP, TRUNCATE, RENAME.
(ii) Data Manipulation Language(DML): They are used to manipulate and access the data in the database.
For Example: SELECT, INSERT, UPDATE, DELETE, LOCK TABLE.
(iii) Transaction Control Language(TCL): Used to manage transactions in the database. They are also used to manage the changes done by DML statements.
For Example: COMMIT, SAVEPOINT, ROLLBACK, SET TRANSACTION.
(iv) Data Control Language(DCL): These commands are often used by Database Administrators and are considered as expert level commands because they are used to assign security levels in a database. Also, they are used to grant and define role and access privileges to the users.
For Example: GRANT, REVOKE.