The database table was fine until the product team dropped a new feature request at noon. Suddenly, a new column had to exist. Not later—now.
Adding a new column sounds simple, but small mistakes can cripple performance or force downtime. The right approach depends on the database engine, the scale of the data, and the constraints you must preserve.
In relational databases like PostgreSQL and MySQL, ALTER TABLE is the standard command for creating a new column. On small tables, it completes instantly. On large datasets, blocking writes or reads is a risk. PostgreSQL can add nullable columns with default values almost instantly, but filling every row with a non-null default triggers a full table rewrite. MySQL’s behavior varies by storage engine; InnoDB supports fast metadata-only operations for some types of additions, but not all. Understanding the engine’s exact execution is essential to avoiding surprises.
On production systems, adding a new column should be planned like a deployment. Create migrations that are safe to run in stages. If you need defaults, set them in the application layer first and backfill data in batches later. This prevents long locks and keeps latency predictable.