Adding a new column to a database table sounds simple, but it’s where speed, safety, and accuracy collide. The wrong command can lock writes. The wrong migration can stall a release. At scale, a “small” schema change can ripple through services, APIs, and caches.
In SQL, ALTER TABLE ADD COLUMN is the direct path. In PostgreSQL:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP;
This works fast when defaults are NULL. But adding a column with a default non-null value rewrites the whole table. That can mean minutes—or hours—of downtime in production. Avoid that by adding the column first with NULL, then backfilling data in controlled batches.
For MySQL, recent versions handle ADD COLUMN without full table copies for many cases. Still, know your engine’s limits. Test the schema change against a dataset that mirrors production size. Monitor performance during migrations.