Creating & Managing Tables
Creating & Managing Tables — Learn DDL commands: CREATE, ALTER, DROP tables, and how to define constraints and indexes. The guide walks through CREATE TABLE, ALTER TABLE, DROP & TRUNCATE, Table Constraints. CREATE TABLE defines a new table with columns, data types, and constraints. Each column must have a name and type. Constraints can be column-level or table-level. Example: CREATE TABLE employees (id INT PRIMARY KEY, name VARCHAR(100) NOT NULL, salary DECIMAL(10,2)). ALTER TABLE modifies an existing table. Add columns: ADD COLUMN. Drop columns: DROP COLUMN. Modify types: MODIFY COLUMN or ALTER COLUMN. Rename columns or tables. Add/drop constraints. Each database has slightly different ALTER syntax. The guide is organized into 4 sections that build on each other, each pairing a prose explanation with real SQL you can run as-is. Related guides: SQL Introduction, SELECT Statement, WHERE Clause & Operators, SQL JOINs, GROUP BY & Aggregation.