The query ran. The table was large. You needed a new column fast.
Adding a new column sounds simple. It rarely is. Schema changes touch live data, production queries, and application logic. The wrong migration can lock tables, stall writes, or trigger outages. The right one is precise, tested, and deployed with zero downtime.
A new column in SQL alters the shape of the table. Use ALTER TABLE with care. On massive datasets, even adding a nullable column can block. Some databases will rewrite the whole table. Others can add metadata-only columns instantly. Understand your engine before you run the command.
For PostgreSQL, adding a column with a default that is not NULL will rewrite the table. Add it as nullable, backfill in batches, then set the default and constraints. This avoids table-wide locks and protects performance.
In MySQL, the storage engine and version determine if the new column uses an in-place operation. Always check ALGORITHM=INPLACE or ALGORITHM=INSTANT when available. This can cut migration time from hours to milliseconds.