Adding a new column to a database table should be simple. In production, it can be anything but. Locking tables, blocking queries, and downtime risks make this moment sensitive. The wrong command at the wrong time can cascade through services until alerts flood your phone.
A new column starts with a schema change. In SQL, the statement is direct:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP;
In PostgreSQL, this is fast for nullable columns without defaults. Adding a default value to an existing large table rewrites the entire table, causing locks and potential outages. The common pattern is to add the column as nullable, backfill data in small batches, then add constraints once complete.
In MySQL, the behavior depends on storage engine and version. Historically, every ALTER TABLE rebuilt the table; modern versions with InnoDB and ALGORITHM=INPLACE or ALGORITHM=INSTANT avoid full copies in many cases. Testing on staging with realistic data sizes is essential.