Adding a new column should be fast, predictable, and safe. In SQL, that means using ALTER TABLE to define the column name, data type, and constraints. The command is simple:
ALTER TABLE orders
ADD COLUMN shipped_at TIMESTAMP;
This creates the new column without rewriting the existing table. But speed depends on the database engine, table size, and storage configuration. Some engines can add columns instantly; others lock writes until the operation completes. Always check your system’s documentation for the operational cost.
A new column can be nullable or have a default value. Setting sensible defaults helps avoid update failures later:
ALTER TABLE orders
ADD COLUMN status TEXT DEFAULT 'pending' NOT NULL;
If a column will hold indexed data, define the index after creation. This reduces migration time and prevents unnecessary locking.