Adding a new column should be fast, predictable, and safe. In reality, it can lock tables, break queries, and trigger deployment delays. The complexity depends on the database engine, schema size, traffic patterns, and deployment method. Doing it wrong in production can mean downtime or data loss.
When you create a new column in SQL, the basic syntax is clear:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP;
This looks simple, but implementation choices matter. Adding a column with a default value can rewrite the entire table, blocking reads and writes. Some databases like PostgreSQL can add nullable columns instantly, but fill operations still require careful batching or background jobs. MySQL on certain versions still runs full table rebuilds by default.
Best practice is to design schema changes for zero downtime. Create the new column without defaults. Backfill data in small batches. Add defaults and constraints after backfill completes. Deploy code that writes to and reads from both old and new structures until you confirm stability. Use feature flags to control rollout.