Adding a new column to a database table sounds simple. In production, it is not. You must consider schema migrations, locking behavior, default values, and backward compatibility. A careless ALTER TABLE can block writes, lock rows, or even take down your application. Done right, it is a fast, safe operation. Done wrong, it is costly.
Most relational databases support ALTER TABLE ... ADD COLUMN. In PostgreSQL, adding a column without a default is immediate because it only updates the table metadata. In MySQL, small additions are often instant with InnoDB, but defaults can trigger a full table rewrite. For large datasets, running migrations online is critical. Use tools like gh-ost or pt-online-schema-change to avoid blocking queries.
New columns demand careful planning in application code. First, deploy changes that make the application tolerant to both old and new schemas. Read paths should not depend on the new column until it exists everywhere across environments. Write paths must handle nulls if the column is not yet populated. Only after the schema migration is complete should you enforce NOT NULL constraints or set heavy default values.
If the column stores derived or computed data, populate it with background jobs rather than blocking writes with a single massive update. For high-traffic services, run backfills in batches and monitor locks, replication lag, and error rates.