Adding a new column to a database table is one of the most common schema changes, yet it’s also one of the most dangerous if done carelessly. Whether you’re working with PostgreSQL, MySQL, or a distributed SQL system, the way you introduce a new column can determine if your deployment stays smooth or triggers downtime.
The first rule: know your defaults. When you add a new column with NOT NULL and no default, your database must write a value for every row before the change completes. On large tables, that can lock writes for minutes or hours. Use a nullable column first, backfill the data in batches, and enforce the constraint later.
The second rule: understand how your database’s ALTER TABLE works. In PostgreSQL, adding a nullable column is a metadata-only operation—instant, even on billions of rows. In MySQL, depending on the storage engine and version, the same statement might rebuild the table. Check your engine’s documentation before you run anything in production.