Adding a new column is one of the most common schema changes in production systems. It looks simple, but without a plan it can cause downtime, data loss, or performance drops. Understanding how to create, migrate, and backfill a new column is essential if you want fast, safe deployments.
A new column starts in definition. Decide its data type, nullability, and default values. For large datasets, default values in migrations can lock tables if applied in a single transaction. Avoid that by adding the column without the default, then applying the default at the application layer and running a background backfill.
In relational databases like PostgreSQL or MySQL, ALTER TABLE is the basic command to add a new column. On small tables, it’s instant. On large tables, it can block reads and writes. Use ALTER TABLE ... ADD COLUMN with caution in high-traffic environments. Some platforms support concurrent schema changes or online DDL to minimize locks.