Adding a new column to a database should be fast, safe, and predictable. Yet in production systems, a single schema change can bring risk: slow migrations, locked tables, bad defaults, and broken deployments. The solution is not just knowing the ALTER TABLE syntax, but understanding performance, compatibility, and rollback strategy.
A new column changes how code runs. Upstream services need to know if the column exists before writing to it. Downstream queries must handle nulls until the backfill is complete. Primary keys, indexes, and constraints must be aligned early to avoid rework.
In PostgreSQL, adding a nullable column with no default is near instant:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP;
But if you add a column with a default on a large table, the database rewrites every row, locking it until complete. In MySQL, similar pitfalls occur; use ALGORITHM=INPLACE when possible.