SQL from Zero › Module 1: How a database thinks
SQL's five families of commands
DDL, DML, DQL, TCL and DCL: the map for the rest of the course.
Lesson 7 of 35 · about 10 minutes
The lesson
SQL has many commands, but they fall into five families. Think about running our bookshop's database the way you'd run a real shop.
| Family | Shop analogy | Main commands | Example |
|---|---|---|---|
| DDL, Data Definition Language | Build the shelves | CREATE, ALTER, DROP | Create a books table |
| DML, Data Manipulation Language | Stock the shelves | INSERT, UPDATE, DELETE | Add a new book, change a price |
| DQL, Data Query Language | Ask questions | SELECT | Which books cost under $10? |
| TCL, Transaction Control Language | Make each sale all-or-nothing | BEGIN, COMMIT, ROLLBACK | Undo a half-finished price update |
| DCL, Data Control Language | Hand out keys | GRANT, REVOKE | Let an intern read orders, but not delete them |
Some people count SELECT as part of DML. Either way, it's the command you'll use most.
This is also the map of this course. Next, you'll start building: writing your first CREATE TABLE and putting up the bookshop's shelves.
Key ideas
- DDL builds the structure: CREATE, ALTER, DROP.
- DML changes the data: INSERT, UPDATE, DELETE. DQL asks questions with SELECT.
- TCL makes changes all-or-nothing: BEGIN, COMMIT, ROLLBACK. DCL controls who can do what: GRANT, REVOKE.
Practise
Loading practice…