Adding a new column should be fast, safe, and predictable. Yet in production systems, careless changes can trigger downtime, lock tables, or corrupt data. Whether you’re using PostgreSQL, MySQL, or a distributed database, the way you introduce a new column matters.
In SQL, the common path is ALTER TABLE ADD COLUMN. Simple on the surface, but execution differs depending on engine and configuration:
- PostgreSQL: Adding a column with a default value rewrites the entire table, which can block writes. Adding it as NULL by default avoids a rewrite and is safer for large datasets.
- MySQL: The impact depends on storage engine and version. Newer releases with instant DDL can add columns without table copies.
- NoSQL systems: You often “add” columns via schema updates in the application layer or schema registry, but the same rules of backward compatibility apply.
Schema changes must consider application reads and writes that expect the old structure. Deployments should separate the steps: