The table is live, the data is pouring in, and now the schema needs to change. You need a new column. Not tomorrow. Not during a weekend maintenance window. Now.
A new column is one of the most common schema changes in any database—SQL or NoSQL. It sounds simple: add it, set a default, migrate old records if needed. But in production, it can hurt. The wrong approach locks tables, blocks writes, and stalls services. The right approach is zero-downtime, safe, and fast.
Start with intent. Why is this new column needed? Is it required for all rows, or optional? Should it have a default value? Defining constraints early avoids costly rework. For relational databases like Postgres, MySQL, and MariaDB, ALTER TABLE ADD COLUMN is often safe for small data sets, but dangerous for massive ones. Consider background migrations that populate large tables in chunks.
In Postgres, adding a nullable column with no default is instant. Adding a column with a non-null default rewrites the table—risking downtime. For large datasets, add the nullable column first, backfill it in small batches, then apply the non-null constraint when ready. In MySQL, adding new columns to InnoDB tables can be instant with ALGORITHM=INSTANT, but only in specific cases. Always check engine and version capabilities.