all topics

Database Languages

The five categories

Every command in MySQL falls into one of five categories, grouped by what kind of thing the command actually does.

DDL — Data Definition Language

Commands related to defining the structure of a table, not the data inside it.

sql
CREATE TABLE, DROP, ALTER

DML — Data Manipulation Language

Commands used for manipulating the actual data inside a table.

sql
INSERT, UPDATE, DELETE

DCL — Data Control Language

Commands for controlling access, who's allowed to do what.

sql
GRANT, REVOKE

TCL — Transaction Control Language

Commands for managing transactions, groups of operations meant to succeed or fail as one unit.

  • A transaction is a complete unit of work in a database, potentially several statements bundled together as a single logical operation.
  • A transaction has exactly two outcomes: successful, every operation in it went through, or never initiated, as if none of it happened. There's no partial state in between, a transaction can't be "60% done", it's either all the way through or rolled back entirely, atomicity, not a gradual progress bar.
  • COMMIT makes the transaction's changes permanent.
  • ROLLBACK undoes the transaction's changes, reverting back to before it started.

DQL — Data Query Language

Commands for reading data back out.

sql
SELECT

SELECT gets grouped separately as its own category, DQL, even though older classifications sometimes lump it under DML alongside INSERT/UPDATE/DELETE. It doesn't change data the way those three do, it only reads it, which is the whole reason it earns a category of its own.