Adding a new column is one of the most common schema changes in any database. It sounds simple, but it affects storage, queries, indexes, and application logic. A poorly planned ALTER TABLE can lock rows, slow writes, or even trigger costly downtime. The right approach depends on your database engine, table size, and uptime requirements.
In PostgreSQL, ALTER TABLE ADD COLUMN is straightforward. If you add a column without a default value or NOT NULL constraint, the command runs instantly because the database only updates metadata. Set a default on large tables and you risk a table rewrite—plan for that or insert defaults in batches.
In MySQL, a new column in InnoDB may involve physical changes to the table. For big datasets, use ALGORITHM=INPLACE or ALGORITHM=INSTANT when supported to avoid rebuilds. Keep an eye on version-specific behavior, as INSTANT became available in MySQL 8.0.
In production systems, avoid adding non-nullable columns with defaults in a single migration. Instead, add the nullable column, backfill with data in controlled chunks, and then apply constraints. This reduces locking and keeps your service responsive.