CREATE, ALTER and DROP: making and changing tables
See how a table is made, changed and removed, what a data type and a default do when you define a column, and why a drop is the one statement to treat with care.
L1–L4 are part of the Pro pass
L0 Explain simply
Analogy: a workshop shelf. You build a shelf with labelled slots. Later you add a slot. Taking the shelf down throws away everything on it. Building is ordinary. Taking it down is final.
Daily List is a made-up to-do app (SYNTHETIC / TRAINING ONLY). Sam, the , reads how reminders are stored. Leo, the developer, is the person who runs a change. Nina, the , asks for a channel on each reminder.
What it is: (Structured Query Language) is a language for asking a database questions and for changing its structure. A table is a grid, a row is one record, and a column is one fact. makes a new table. ALTER TABLE changes a table that already exists, such as adding a column. DROP TABLE removes the table. You run them in the database. The neighbour of DROP TABLE is DELETE, which removes rows and leaves the table, and TRUNCATE, which empties a table in products that have it.
Why it matters: A drop on the live reminders table removes the reminders, not just a query. Sam never runs it there. He learns what each statement does so he can ask before Leo runs it.
A wooden shelf holds a few jars. A database table can hold every reminder, and a drop still removes all of them.
PLAIN WORDS · 1 in this section
- empties
- becomes empty, or drains into somewhere else
PICTURE IT
The picture is the one the lesson above opens with. The table below shows how each part of it matches the work.
THE REAL JOB A workshop shelf with labelled slots.
- Build
- Change
- Remove
HOW THE PICTURE MAPS
| In the picture | In the work |
|---|---|
| Building the shelf | CREATE TABLE |
| Adding a slot | ALTER TABLE add COLUMN |
| Taking down the shelf | DROP TABLE |
| The label on a slot | A column type |
WHERE THIS PICTURE STOPS
- A shelf is built by hand, but a table is built by a statement.
- A shelf is removed with care, but a drop runs in a moment.
- Slots hold objects, but columns hold typed values.
HOOK
Take down the shelf, lose the contents.
TELL A FRIEND
A shelf: changing its structure affects contents and dependencies.
OFTEN MIXED UP WITH SQL (Structured Query Language) for BAs: CRUD (create, read, update, delete), from a requirement to four statements. That topic covers reading and changing rows. This one covers making, changing and removing the table itself.
PRACTISE AND KEEP
Sources for this topic — 6 sources
- Market practice
Altering tables (PostgreSQL documentation) ↗ — PostgreSQL · PostgreSQL 18, §5.7 altering columns and constraints; publisher page opened6November 2026. Dialect scope explicit.
PostgreSQL18 publisher documentation opened on6November2026: §5.7 altering columns and constraints. No execution on PostgreSQL is claimed; engine-specific examples remain scoped to18.
- Market practice
DROP TABLE (PostgreSQL documentation) ↗ — PostgreSQL · PostgreSQL 18, DROP TABLE dependency RESTRICT/CASCADE scope; publisher page opened6November 2026. Dialect scope explicit.
PostgreSQL18 publisher documentation opened on6November2026: DROP TABLE dependency RESTRICT/CASCADE scope. No execution on PostgreSQL is claimed; engine-specific examples remain scoped to18.
- Market practice
SQLite: CREATE TABLE ↗ — SQLite project · SQLite: CREATE TABLE; DEFAULT/NOT NULL/CHECK, primary-key legacy NULL exceptions. Publisher page opened6November 2026.
Publisher documentation opened on6November2026. Engine/version scope is explicit; other database implementations may differ. Teaching queries are synthetic, not a required publisher template.
- Market practice
SQLite: transactions ↗ — SQLite project · SQLite: transactions; Explicit versus implicit transactions and error-handling scope. Publisher page opened6November 2026.
Publisher documentation opened on6November2026. Engine/version scope is explicit; other database implementations may differ. Teaching queries are synthetic, not a required publisher template.
- Market practice
Statements that cause an implicit commit (MySQL reference manual) ↗ — Oracle / MySQL · MySQL 8.4 publisher manual opened6November 2026. §15.3.3 DDL statements that implicitly commit; no claim all database DDL behaves alike.
MySQL8.4 publisher manual opened6November2026. §15.3.3 DDL statements that implicitly commit; no claim all database DDL behaves alike.
- Simplified educational illustration
Payments Signal editorial teaching models — Payments Signal
What this simplifies: Daily List people, data and exercises are invented for teaching. Query results belong to the declared fixture and database version. Authorization, business identity, time bounds and unknown-value policy must be agreed in context; no universal mandatory query template is implied.
Used wherever diagrams, scenarios, figures, or example values are didactic constructions rather than sourced facts; every such use carries a simplifications disclosure. All people, companies, banks, and list entries in examples are fictional.
Deepest material on this page: L4 — Standards & sources. Where a topic stops short of implementation depth, that is a deliberate coverage decision, not an oversight — see coverage.