Adding a new column should be fast, safe, and predictable. The wrong approach can lock tables, break code, or trigger downtime. The right approach makes schema changes seamless, even under load.
In SQL, a NEW COLUMN can be created with ALTER TABLE ADD COLUMN. But production databases demand more than syntax. You need to choose data types carefully, set sensible defaults, and avoid unnecessary recomputations. If the column is nullable, you can usually add it instantly. If it must have a default value, consider adding it without constraints first, then backfilling data in batches before applying the default and constraints. This prevents performance hits.
For PostgreSQL, adding a nullable column without a default is nearly instant. Adding with a non-null default rewrites the table, which can be dangerous for large datasets. Use a two-step migration: first add the column as nullable, then update it asynchronously, then enforce constraints. MySQL and other databases have their own nuances, so test on a staging environment before production.