Sublanguages & Dialects (DDL/DML/DCL/TCL) in SQL
One language, four jobs — plus vendor dialects
SQL splits into DDL (CREATE/ALTER/DROP — structure), DML (SELECT/INSERT/UPDATE/DELETE — rows), DCL (GRANT/REVOKE — permissions) and TCL (COMMIT/ROLLBACK/SAVEPOINT — transactions). Core SELECT/WHERE/GROUP BY/JOIN transfers everywhere; functions, upsert syntax and quoting vary by engine (PostgreSQL, MySQL, SQLite, SQL Server, Oracle).
DDL shapes structure
CREATE/ALTER/DROP define tables, columns, constraints. Versioned migration files carry these.
DML moves rows
SELECT reads; INSERT/UPDATE/DELETE write. The daily 95% of statements.
DCL + TCL guard and group
GRANT/REVOKE gate access per role. BEGIN/COMMIT/ROLLBACK bundle writes atomically.
Dialects diverge at edges
Core transfers; upsert, quoting, functions and paging spellings vary — check the engine manual.
1CREATE TABLE t (id INT PRIMARY KEY); -- DDL2INSERT INTO t VALUES (1); -- DML3GRANT SELECT ON t TO analyst; -- DCL4COMMIT; -- TCL
| sublanguage | job |
|---|---|
| DDL | structure |
| DML | rows |
| DCL | permissions |
| TCL | transactions |
Four statements, four jobs. Interviewers often ask for one verb per letter — have CREATE, SELECT, GRANT, COMMIT ready.
One verb per letter
Have CREATE, SELECT, GRANT, COMMIT ready for the interview.
1CREATE TABLE t (id INT PRIMARY KEY);2INSERT INTO t VALUES (1);3GRANT SELECT ON t TO analyst;4COMMIT;
| sublanguage | verb |
|---|---|
| DDL | CREATE TABLE |
| DML | INSERT |
| DCL | GRANT |
| TCL | COMMIT |
Same job, two spellings
Upsert syntax is the canonical dialect split.
1-- PostgreSQL/SQLite:2INSERT INTO counters (k,n) VALUES ('hits',1) ON CONFLICT (k) DO UPDATE SET n = counters.n + 1;3-- MySQL:4-- INSERT INTO counters (k,n) VALUES ('hits',1) ON DUPLICATE KEY UPDATE n = n + 1;
| engine | spelling |
|---|---|
| PostgreSQL/SQLite | ON CONFLICT |
| MySQL | ON DUPLICATE KEY |
Recommended resourcesAffiliate links · may earn us a commission
Recommended for learners
Practice what you learned
Take the queries you just visualized and see the data structures that power real databases.