Adding a new column is one of the simplest database operations, but doing it right matters. Schema changes can break production code, slow down queries, or cause costly downtime. The key is understanding how your database engine handles ALTER TABLE and planning for safe deployment.
In PostgreSQL, adding a column without a default is almost instant. The database updates the metadata and moves on. Add a default with NOT NULL, and things change. The system will rewrite the table, locking it and slowing throughput. For MySQL and MariaDB, the rules differ. Some operations are online; others block reads and writes until they finish.
To add a new column safely, start with a plain ALTER TABLE that sets no default. Populate values in small batches using UPDATE after the column exists. Once filled, enforce a NOT NULL constraint. In large-scale systems, break changes into deployable steps and verify them against production-like data before executing live.