The database waits. You run the query, but the schema is wrong. The numbers don't line up. The fix starts with a new column.
Adding a new column is one of the most common schema changes. Yet simple doesn’t mean risk-free. You need speed, correctness, and zero downtime. Whether it’s adding a nullable column, setting a default value, or indexing for faster lookups, the steps matter.
Plan the migration. In SQL, the basic command is straightforward:
ALTER TABLE orders ADD COLUMN processed_at TIMESTAMP;
That statement works, but the impact depends on table size. On massive datasets, locking can block writes. The solution is online DDL tools, chunked migrations, or replication-based approaches. Modern databases like PostgreSQL, MySQL, and MariaDB handle this differently. Know your engine before running the change.
Set defaults carefully. Adding a column with a non-null default forces the database to rewrite existing rows. This can be slow and can block. Often it’s better to add the column NULL first, then backfill asynchronously. After the data exists, add a NOT NULL constraint.