Adding a new column in a database is not just a field on a table. It is a schema evolution. Done right, it’s safe, atomic, and invisible to the users. Done wrong, it locks rows, blocks writes, or crashes queries under load.
To add a new column in SQL, most engines use a simple ALTER TABLE statement:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP DEFAULT NOW();
This works locally. In production, you must consider table size, index rebuilds, and replication lag. On massive datasets, even a simple ALTER TABLE can lock the table for minutes or hours. Some systems, like PostgreSQL with certain column types, can add columns without rewriting the full table if you provide a constant default. Others, like MySQL before 8.0+, may require a full copy, doubling disk I/O.
For zero-downtime deployments, engineers use phased migrations. First, add the new column as NULL. Then backfill in batches to avoid write amplification. Finally, change defaults or constraints. This pattern keeps availability high and reduces risk.