The schema was set, the tables locked, and yet the product team needed more. A new column had to be added fast, without breaking anything already in production.
Adding a new column sounds simple, but at scale, the risks multiply. Migrations can lock writes. Data backfills can choke I/O. An ill-timed deploy can stall user actions or corrupt records. A precise plan avoids downtime and keeps integrity intact.
In SQL, the ALTER TABLE statement is the common path. For most relational databases, the syntax to add a new column is direct:
ALTER TABLE users
ADD COLUMN last_login TIMESTAMP;
This works for many cases, but production environments demand more than syntax. Consider constraints. Will the new column allow NULL values? Should it have a default? Adding a non-null column without a default can fail if existing rows do not contain valid values.
Performance matters. In MySQL, adding a column can cause a full table copy depending on the storage engine. PostgreSQL handles certain additions without a rewrite if no default is specified, which reduces lock time. Knowing the database’s internal operations lets you deploy safer changes.