This page assumes you have seen nothing. We name every word, notation, and symbol the parent note leans on, draw the picture behind it, and say why the topic can't work without it. Start at line one.
Before any SQL word makes sense, you need the picture the words describe.
Look at the figure: the grey grid is the tablestudents. The columns are the labelled headers running left-to-right (id, name, age). Each row is one filled-in line. DDL never touches individual rows-as-data — it decides which columns exist and what rules they obey. That is the drawer's shape, not the papers inside it.
The parent note uses four types. Here is the plain-words picture of each:
The figure shows the crucial CHAR vs VARCHAR difference the parent's "steel-man" warns about. Storing "IN" in CHAR(5) uses all 5 slots (padded ▯▯), while VARCHAR(5) uses only 2. That is why the "VARCHAR always uses n bytes" belief is wrong.
Recall What does the
n in VARCHAR(50) mean?
The maximum number of characters allowed, not the amount reserved. Actual storage grows with the actual text length.
A constraint is a rule that rejects illegal rows automatically. This is the heart of a good CREATE statement, so we build each rule from zero.
The figure draws the FOREIGN KEY picture, which the parent's DROP/CASCADE examples depend on. The arrow from students.dept_id points to departments.id: a student may only name a department that actually exists. This arrow is called referential integrity — see Referential Integrity & CASCADE. The arrow is why dropping departments fails while students still point at it.
The parent writes CHECK (age >= 0) and CHECK (age < 130). Two symbols do the work:
These are the only math symbols the parent note uses, and they answer the question "is this value in the allowed range?" — the exact job a CHECK constraint needs.
This pair is exactly why the parent's "add a NOT NULL column" example needs a DEFAULT: existing rows have no value, so a default must plug the hole or the ALTER fails.
Read it top-down: the cabinet/drawer picture feeds columns and rows; columns need types; types need the NULL marker; constraints build on NULL; keys link tables; and the transaction words explain why the four DDL verbs are permanent. Everything funnels into the box marked CREATE ALTER DROP TRUNCATE.