Adding a new column in a relational database sounds simple. In reality, it affects queries, indexes, constraints, application code, and data integrity. The approach depends on your database engine, schema change tooling, and tolerance for downtime.
In PostgreSQL, ALTER TABLE ADD COLUMN is fast for nullable columns without defaults. When adding defaults, older versions rewrite the whole table—locking writes until it finishes. On modern versions, adding a non-null column with a constant default value is metadata-only. Read your version’s release notes before pushing to production.
In MySQL, adding a new column can trigger a full table copy, depending on the storage engine and column definition. Use ALGORITHM=INPLACE or ALGORITHM=INSTANT to avoid downtime where supported. Always check with SHOW CREATE TABLE and the documentation for your exact release.
For large datasets, use an online schema change tool like pt-online-schema-change or gh-ost. These allow you to add a column without blocking reads and writes, at the cost of more complex deployment steps.