The difference decides whether you can undo a migration once it has started. In MySQL, a statement that changes the schema is committed on its own. The same statement inside an open transaction is committed the moment it finishes. SQLite and PostgreSQL behave differently. There, a change to the schema stays inside your transaction until you commit it.
That one difference changes how a failure halfway through a migration looks. Picture a release that adds a column, backfills it, and then switches the application code to read that column.
On a database that commits schema changes straight away, the column appears in the live table before the backfill has run. If the backfill fails, the rollback removes the data change but not the column. The schema and the data no longer match. The old application code keeps running, because it does not know about the new column. The new code cannot run, because the column holds nothing yet.
You are now in the middle of a release with no simple way back. The reverse migration has to be written by hand while the incident is still going on.
On a database where schema changes are transactional, the same failure is much easier to handle. The rollback takes the column with it, so the database returns to the state it had before the migration started.
Two more things make schema changes harder than they look. A change to the schema often takes a lock, and traffic on that table waits while the lock is held. And a migration that mixes a schema change with a large data change gives you one large transaction, which runs longer and holds locks for longer.
The practical habit is to split the work into small steps, and to check how your engine treats schema changes before you rely on it.
Here is each statement with the reason it belongs where it does.
-- DDL: creates the table.
CREATE TABLE invoices (
id INTEGER PRIMARY KEY,
customer TEXT NOT NULL,
amount REAL NOT NULL,
state TEXT NOT NULL DEFAULT 'open'
);
-- DML: adds rows.
INSERT INTO invoices (id, customer, amount) VALUES (1, 'Northwind', 250.00);
INSERT INTO invoices (id, customer, amount) VALUES (2, 'Acme', 410.50);
-- TCL: opens a transaction.
BEGIN;
-- DML: changes rows.
UPDATE invoices SET state = 'paid' WHERE id = 1;
-- TCL: keeps the change.
COMMIT;
-- DML: reads the rows back.
SELECT id, customer, state FROM invoices ORDER BY id;
The CREATE TABLE is DDL. It adds a table to the schema and defines its columns, types and rules. It does not touch any row.
The two INSERT statements are DML. The table already exists, so these statements add rows to a table whose shape is fixed.
The BEGIN and the COMMIT are TCL. They mark the start and the end of the transaction and decide whether the work inside is kept. The UPDATE between them is DML, and it sits inside the boundary the transaction created.
The final SELECT is DML too. Reading rows is data manipulation, even though it changes nothing.
Where is the DCL in this set? The DCL commands are GRANT and REVOKE, which give and take away permissions. SQLite does not implement those two commands, so this runnable script leaves them out. On PostgreSQL or MySQL you would add a line that gives a reporting account select access on the invoices table.
One warning about the order here. The transaction wraps only the update, so a failure after the commit leaves the paid row in place. In a real program you would group the statements that must succeed or fail together.
Learn what each family touches and the rest follows. DDL changes the shape of the database. DML changes the rows inside it. DCL changes who is allowed to act. TCL decides whether the work is kept or thrown away.
This one rule makes three everyday situations easier.
When you review a migration, you know that a statement that changes a table or a column is a schema change and deserves more care than an insert. Schema changes often need a plan, a lock and a way back.
When you set up access, you know that granting permissions is DCL and separate from the data itself. You can give someone read access to one table and nothing else, and you can take that access away later without touching a single row.
When you work with transactions, you know that the commit and the rollback are TCL, and that they apply to the work between them. The other three families say nothing about that boundary.
In an interview this also gives you a clean way to talk about SQL without reciting a list of statements. Say that the four families separate the schema, the data, the permissions and the transaction boundary, and you have covered the whole language in one sentence.