The database was ready to go live when you saw it: a missing column that would break the release. A single gap in the schema, and the whole system would stall. You needed a new column, fast, without blowing up migrations or blocking deploys.
Adding a new column is one of the most common schema changes in production. It sounds simple, but the wrong approach will cause downtime, lock tables, or drop performance under load. The key is knowing how to add a column safely, in a way that scales and works across different environments.
In SQL, you use ALTER TABLE to add the new column. For example:
ALTER TABLE users
ADD COLUMN last_login TIMESTAMP NULL;
On small datasets, this is instant. On large tables, it can block writes for minutes or hours, depending on the database engine. MySQL before version 8 will often lock the table. PostgreSQL handles many column adds without a full rewrite if the default is NULL. Adding a new column with a non-null default can trigger a costly table rewrite.