What is SQL, and what do DDL, DML, DCL, and TCL stand for?
Quick Answer
SQL (Structured Query Language) is the standard declarative language for defining and manipulating relational data. Its statements fall into four categories. DDL (Data Definition Language — CREATE, ALTER, DROP) changes schema structure. DML (Data Manipulation Language — SELECT, INSERT, UPDATE, DELETE) reads and writes rows. DCL (Data Control Language — GRANT, REVOKE) manages permissions. TCL (Transaction Control Language — COMMIT, ROLLBACK, SAVEPOINT) manages transaction boundaries.
Detailed Answer
SQL splits into four sub-languages, grouped by what kind of change a statement makes. This split matters because it affects transaction behavior, required privileges, and whether you can roll a change back.
The four categories
| Category | Full name | Example statements | What it affects |
|---|---|---|---|
| DDL | Data Definition Language | CREATE TABLE, ALTER TABLE, DROP TABLE, TRUNCATE | Schema/structure (tables, indexes, constraints) |
| DML | Data Manipulation Language | SELECT, INSERT, UPDATE, DELETE | Row-level data |
| DCL | Data Control Language | GRANT, REVOKE | Permissions and access control |
| TCL | Transaction Control Language | COMMIT, ROLLBACK, SAVEPOINT, SET TRANSACTION | Transaction boundaries |
-- DDL: defines structure
CREATE TABLE accounts (
id SERIAL PRIMARY KEY,
balance NUMERIC(12,2) NOT NULL DEFAULT 0
);
-- DML: manipulates rows
INSERT INTO accounts (balance) VALUES (100.00);
UPDATE accounts SET balance = balance - 50 WHERE id = 1;
-- DCL: controls access
GRANT SELECT, INSERT ON accounts TO app_user;
-- TCL: controls the transaction
BEGIN;
UPDATE accounts SET balance = balance - 50 WHERE id = 1;
UPDATE accounts SET balance = balance + 50 WHERE id = 2;
COMMIT;
Why the distinction matters
Most databases auto-commit DDL. Some even implicitly commit any open transaction before running it. In MySQL, running ALTER TABLE mid-transaction causes an implicit commit — you can't roll back a schema change the way you can an UPDATE. PostgreSQL is an exception: it supports transactional DDL, so a CREATE TABLE inside a BEGIN...ROLLBACK block really does disappear.
DCL statements are usually not transactional either. Permission changes often take effect immediately and ROLLBACK won't undo them in many engines. Knowing which bucket a statement falls into tells you whether you can safely wrap it in a transaction for an atomic migration, or whether you need a different rollback strategy — like a paired "down" migration script.