CSE Roadmap

Core tier · about 2 hours · 5 parts

Part 2 of 5 · 1 min read

DDL: defining structure

Statements that create or change a table's structure itself.

Think of the difference between designing a filing cabinet's drawers and layout, versus actually putting paper into one of those drawers.

In plain words: Data Definition Language statements create, change or remove the structure of a database: tables, columns, constraints, indexes. CREATE TABLE, ALTER TABLE and DROP TABLE are DDL. They affect the schema, not the rows stored inside it.

A worked example. Adding a new column to books for a discount percentage changes the structure, not any specific row's data yet.

The key lines.

ALTER TABLE books ADD COLUMN discount_percent NUMERIC(4,1) DEFAULT 0;

DDL

Data Definition Language (DDL) covers statements that create, change or remove database structure. CREATE, ALTER and DROP are DDL commands.

Example: ALTER TABLE books ADD COLUMN discount_percent ... is DDL, since it changes the table's structure, not its row data.