SQL commands are grouped by what they act on — the structure, the data, permissions, or transactions. A classic first interview question.
| Group | Stands for | Commands | Acts on |
|---|---|---|---|
| DDL | Data Definition Language | CREATE, ALTER, DROP, TRUNCATE, RENAME | Schema objects (tables, indexes, views) |
| DML | Data Manipulation Language | INSERT, UPDATE, DELETE, MERGE | Rows inside tables |
| DQL | Data Query Language | SELECT | Reading rows (often counted as part of DML) |
| DCL | Data Control Language | GRANT, REVOKE | Permissions of users and roles |
| TCL | Transaction Control Language | COMMIT, ROLLBACK, SAVEPOINT, BEGIN | Grouping DML into atomic units |
One of each
-- DDL: define structure
CREATE TABLE notes (id INTEGER PRIMARY KEY, body TEXT NOT NULL);
-- TCL + DML: change data inside a transaction
BEGIN;
INSERT INTO notes (body) VALUES ('learn SQL'), ('practice joins');
UPDATE notes SET body = 'practice window functions' WHERE id = 2;
COMMIT;
-- DQL: read it back
SELECT id, body FROM notes ORDER BY id;id | body
---+--------------------------
1 | learn SQL
2 | practice window functions-- DCL: permissions (server databases only; SQLite has no users)
GRANT SELECT, INSERT ON notes TO analyst;
REVOKE INSERT ON notes FROM analyst;Why the grouping matters
Is TRUNCATE DDL or DML?
Is SELECT part of DML?