SQL Command Categories
There are dozens of SQL keywords. Memorizing them is pointless. Grouping them into four families makes them stick.
The four families
| Family | What it does | Keywords you'll see |
|---|---|---|
| DDL — Data Definition Language | Defines the SHAPE of your data (creates / changes / removes tables) | CREATE, ALTER, DROP, TRUNCATE, RENAME |
| DML — Data Manipulation Language | Changes the CONTENT of your data (rows in/out) | INSERT, UPDATE, DELETE, MERGE |
| DCL — Data Control Language | Manages PERMISSIONS (who can do what) | GRANT, REVOKE |
| DQL — Data Query Language | Reads data (the most common one by far) | SELECT |
Some textbooks also list TCL — Transaction Control Language (COMMIT, ROLLBACK, SAVEPOINT) as a fifth family. We'll cover transactions in Module 9.
Why this grouping matters
It tells you what the command affects and how dangerous it is:
- DDL changes the structure — affects every row in a table at once. Hard to reverse. Big risk.
- DML changes rows — affects specific rows. Reversible via transactions before commit.
- DCL changes who-can-do-what — affects security. Production teams audit this.
- DQL just reads — zero risk. The only family safe to run on production without a second pair of eyes.
When you see a query, ask: which family? If it's DDL, slow down. If it's DQL, just run it.
Each family in one example
DDL — define structure
CREATE TABLE customers (
id INT PRIMARY KEY,
name VARCHAR(100) NOT NULL,
email VARCHAR(255) UNIQUE
);
This creates a new table. Until you run an INSERT, the table has zero rows.
DML — change content
INSERT INTO customers (id, name, email)
VALUES (1, 'Anita Rao', 'anita@example.com');
This adds one row to the existing table.
DCL — control access
GRANT SELECT ON customers TO analytics_user;
This gives the analytics_user role permission to read from the customers table, but not write.
DQL — read
SELECT name, email FROM customers WHERE id = 1;
This reads one row matching id = 1. Returns Anita Rao / anita@example.com.
A common interview trap
"What's the difference between
DELETEandTRUNCATE?"
Both empty out a table. The trick:
DELETE | TRUNCATE |
|---|---|
| DML — manipulates rows | DDL — redefines table |
| Row by row | Whole table at once |
| Logs each row deletion | Doesn't log individual rows (faster) |
Can have a WHERE clause | All-or-nothing |
| Can be rolled back inside a transaction | Can't always be rolled back |
| Triggers fire | Triggers do NOT fire |
DELETE is surgical. TRUNCATE is a wrecking ball. Same end state, very different mechanics.
Cheat sheet to bookmark
DDL → defines structure CREATE / ALTER / DROP / TRUNCATE
DML → changes content INSERT / UPDATE / DELETE
DCL → manages permissions GRANT / REVOKE
DQL → reads data SELECT
TCL → transaction control COMMIT / ROLLBACK / SAVEPOINT
Print this and tape it to your monitor for week one of any SQL job.
Module 1 complete 🎉
You now know:
- ✅ What SQL is and why it's worth learning
- ✅ Real-world scenarios where SQL is the answer
- ✅ What an RDBMS is and the major players
- ✅ Tables, rows, columns, fields, NULL
- ✅ The four families of SQL commands
In Module 2: SQL Databases, we'll do a quick tour of the major RDBMS systems — MySQL, PostgreSQL, SQLite, MS SQL Server, Oracle — and help you pick which one to install for hands-on practice.