The query ran in seconds, but the result was wrong. The data was there, hidden in plain sight, but the schema had no room for it. The fix was simple: a new column.
Adding a new column changes the shape of a table, the way queries behave, and the performance profile of your database. It is not just an alteration command — it is an irreversible change to history if done carelessly.
In SQL, you create a new column with ALTER TABLE. A minimal form looks like:
ALTER TABLE orders
ADD COLUMN shipped_at TIMESTAMP;
This works in PostgreSQL, MySQL, and most relational systems with minor syntax changes. The column definition must match the intended data type and constraints. Think about NULL vs NOT NULL, default values, and whether the column should be indexed.
On small tables, new columns appear instantly. On large tables with billions of rows, the operation can lock writes and even reads, depending on the database engine. For production systems, plan a migration path. Check for online DDL support, create the column with a default in a second step, and backfill in controlled batches.