Adding a new column is one of the most common operations in database evolution. It is simple in concept, but dangerous in execution if not done right. Performance, consistency, and backward compatibility are always at stake.
In SQL, the pattern starts with ALTER TABLE. For example:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP;
The command modifies the table definition instantly in metadata, but the impact depends on the database engine. In Postgres, adding a nullable column without a default value is nearly instant. Adding a column with a default can lock the table and rewrite it, which may stall production traffic. MySQL behaves differently depending on the storage engine. Understanding engine-specific behavior is critical to avoid downtime.
For large datasets, schema changes must be run with caution. Techniques include adding the column without defaults, backfilling in small batches, and then adding constraints once the data is in place. This avoids locking.