What is SQL, and what are DDL, DML, DCL and TCL?
Quick Answer
SQL (Structured Query Language) is the standard language for relational databases. Its statements group into four categories: DDL defines structure (CREATE, ALTER, DROP, TRUNCATE), DML manipulates data (SELECT, INSERT, UPDATE, DELETE), DCL controls access (GRANT, REVOKE), and TCL manages transactions (COMMIT, ROLLBACK, SAVE TRANSACTION).
SQL is the language for talking to relational databases. The commands split into groups: DDL is for structure — create, alter, drop a table. DML is for the data itself — select, insert, update, delete. DCL is permissions — grant and revoke. And TCL is transactions — commit, rollback, savepoints. Knowing which group a command is in matters because, for example, TRUNCATE is DDL and DELETE is DML, and they behave differently around logging and identity seeds.
- DDL — schema changes. Mostly auto-committed;
TRUNCATEis DDL (minimally logged) whileDELETEis DML. - DML — the day-to-day CRUD statements.
SELECTis sometimes called DQL. - DCL — permissions and roles.
- TCL — grouping DML into atomic units of work.