<aside> 🏗️ DDL commands define and manage database structure: CREATE, ALTER, DROP.
</aside>
Use CREATE TABLE to define a new table with columns and constraints.
CREATE TABLE persons (
id INT NOT NULL,
person_name VARCHAR(50) NOT NULL,
birth_date DATE,
phone VARCHAR(15) NOT NULL,
CONSTRAINT pk_persons PRIMARY KEY (id)
)
Use ALTER TABLE to add or remove columns from an existing table.
-- Add a new column
ALTER TABLE persons
ADD email VARCHAR(50) NOT NULL
-- Remove a column
ALTER TABLE persons
DROP COLUMN phone
Use DROP TABLE to permanently delete a table and all its data.
-- Delete the table
DROP TABLE persons
<aside> ⚠️ DROP is irreversible! Always back up before dropping tables.
</aside>