Adding a new column sounds simple, but done wrong, it stalls releases, locks queries, and risks data loss. The right approach depends on scale, downtime tolerance, and database type. For small datasets, a quick ALTER TABLE ADD COLUMN may be enough. On production systems with millions of rows, that command can block writes and take minutes—or hours.
Plan schema changes like code changes. Test them. Know what happens under the hood. Most modern databases support adding a nullable column instantly. Adding a column with a default, a NOT NULL constraint, or computed values can trigger a costly rewrite. PostgreSQL 11+ can add a column with a default without a table rewrite, but older versions cannot. MySQL’s behavior varies with storage engine and version.
Zero-downtime patterns help teams move fast without taking services offline. Techniques include adding the column as nullable, backfilling data in batches, and then adding constraints after the backfill. Tools like pt-online-schema-change or gh-ost stream schema migrations to live systems without blocking.