TOPIC 19/3015 MINNOT STARTED

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.

  1. Build
  2. Change
  3. Remove
Shelf

HOW THE PICTURE MAPS

How each part of the picture matches the work
In the pictureIn the work
Building the shelfCREATE TABLE
Adding a slotALTER TABLE add COLUMN
Taking down the shelfDROP TABLE
The label on a slotA 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
  1. Market practice

    Altering tables (PostgreSQL documentation) ↗ — PostgreSQL · PostgreSQL 18, §5.7 altering columns and constraints; publisher page opened6November 2026. Dialect scope explicit.

    §5.7 altering columns and constraints. PostgreSQL18 implementation, not a universal SQL mandate. · Checked 2026-11-06

    PostgreSQL18 publisher documentation opened on6November2026: §5.7 altering columns and constraints. No execution on PostgreSQL is claimed; engine-specific examples remain scoped to18.

  2. Market practice

    DROP TABLE (PostgreSQL documentation) ↗ — PostgreSQL · PostgreSQL 18, DROP TABLE dependency RESTRICT/CASCADE scope; publisher page opened6November 2026. Dialect scope explicit.

    DROP TABLE dependency RESTRICT/CASCADE scope. PostgreSQL18 implementation, not a universal SQL mandate. · Checked 2026-11-06

    PostgreSQL18 publisher documentation opened on6November2026: DROP TABLE dependency RESTRICT/CASCADE scope. No execution on PostgreSQL is claimed; engine-specific examples remain scoped to18.

  3. Market practice

    SQLite: CREATE TABLE ↗ — SQLite project · SQLite: CREATE TABLE; DEFAULT/NOT NULL/CHECK, primary-key legacy NULL exceptions. Publisher page opened6November 2026.

    DEFAULT/NOT NULL/CHECK, primary-key legacy NULL exceptions. · Checked 2026-11-06

    Publisher documentation opened on6November2026. Engine/version scope is explicit; other database implementations may differ. Teaching queries are synthetic, not a required publisher template.

  4. Market practice

    SQLite: transactions ↗ — SQLite project · SQLite: transactions; Explicit versus implicit transactions and error-handling scope. Publisher page opened6November 2026.

    Explicit versus implicit transactions and error-handling scope. · Checked 2026-11-06

    Publisher documentation opened on6November2026. Engine/version scope is explicit; other database implementations may differ. Teaching queries are synthetic, not a required publisher template.

  5. 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.

    Official list of statements that end a transaction in MySQL, including TRUNCATE TABLE. · Checked 2026-11-06

    MySQL8.4 publisher manual opened6November2026. §15.3.3 DDL statements that implicitly commit; no claim all database DDL behaves alike.

  6. Simplified educational illustration

    Payments Signal editorial teaching models — Payments Signal

    This site's own simplified teaching models. · Checked 2026-07-12

    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.