Adding a new column sounds simple. In production environments, it’s not. A schema change can block writes, lock tables, or force your application into downtime if it’s not planned. The right approach depends on your database engine, traffic patterns, and deployment pipeline.
New column in SQL
In relational databases like PostgreSQL or MySQL, ALTER TABLE ADD COLUMN is the basic syntax. On small tables, it completes instantly. On large tables, it can take minutes or hours, especially if the engine rewrites the whole table. Use NULL defaults when possible to avoid full table rewrites. For high-traffic systems, perform the change in non-peak hours or use online schema change tools like gh-ost or pt-online-schema-change.
New column in NoSQL
Document stores like MongoDB or DynamoDB don’t have strict schemas. You can add a field in code without migrations. The trade-off is consistency: existing documents won’t have the new field unless you update them. Design for backward compatibility. Application code should handle missing fields gracefully.