✏️ Explanatory Question
Level: Basic — A must-know classification question; interviewers expect all five categories.
SQL commands are grouped into five main categories based on what they do. Remembering these categories shows you understand how SQL is organized.
CREATE, ALTER, DROP, TRUNCATE, RENAME.INSERT, UPDATE, DELETE.SELECT.GRANT, REVOKE.COMMIT, ROLLBACK, SAVEPOINT.TRUNCATE is a DDL command (not DML), because it deallocates the data pages rather than deleting rows one by one — that's why it can't be rolled back and doesn't fire triggers.
| Category | Full Form | Commands | Auto-Commit? |
|---|---|---|---|
| DDL | Data Definition Language | CREATE, ALTER, DROP, TRUNCATE | Yes |
| DML | Data Manipulation Language | INSERT, UPDATE, DELETE | No |
| DQL | Data Query Language | SELECT | No |
| DCL | Data Control Language | GRANT, REVOKE | Yes |
| TCL | Transaction Control Language | COMMIT, ROLLBACK, SAVEPOINT | — |
-- DDL: define structure
CREATE TABLE students (id INT, name VARCHAR(50));
-- DML: manipulate data
INSERT INTO students VALUES (1, 'Rumman');
UPDATE students SET name = 'Ansari' WHERE id = 1;
-- DQL: query data
SELECT * FROM students;
-- DCL: control access
GRANT SELECT ON students TO 'app_user'@'localhost';
-- TCL: manage transaction
COMMIT;