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 6 of 33 · about 10 minutes

Video: Running a shopThe narrated video for this lesson is coming soon. The lesson below covers the same ideas.

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.

FamilyShop analogyMain commandsExample
DDL, Data Definition LanguageBuild the shelvesCREATE, ALTER, DROPCreate a books table
DML, Data Manipulation LanguageStock the shelvesINSERT, UPDATE, DELETEAdd a new book, change a price
DQL, Data Query LanguageAsk questionsSELECTWhich books cost under $10?
TCL, Transaction Control LanguageMake each sale all-or-nothingBEGIN, COMMIT, ROLLBACKUndo a half-finished price update
DCL, Data Control LanguageHand out keysGRANT, REVOKELet 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…

Quick check

1. CREATE TABLE belongs to which family?

2. You want to change a book's price. Which family?

3. Which family includes ROLLBACK?