Adding a new column to a database sounds simple. It can be—if you respect the details. The wrong approach will lock tables, stall writes, or even cause downtime. The right approach keeps data flowing while the schema evolves.
First, define the purpose of the column. Is it nullable, or do you need a default value? A default requires careful planning: applying it to millions of rows can trigger a long-running write, which cascades into load spikes and performance degradation. When possible, create the column as nullable, then backfill data in small batches.
Second, choose the right migration strategy. For small tables, a direct ALTER TABLE ADD COLUMN is fine. For large tables in production, use online schema change tools like pt-online-schema-change or native database features (MySQL’s ALGORITHM=INPLACE, PostgreSQL’s fast column addition for NULL-only). This prevents full table rebuilds and keeps systems responsive.