Adding a new column is one of the most common database operations, but also one of the most dangerous if done carelessly. It can lock writes, break queries, and produce inconsistent data if deployed without a plan. The right approach depends on your database engine, workload, and uptime requirements.
First, define the column with precision. Know its exact type, nullability, and default value before you touch production. In PostgreSQL, you can add a column with:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP WITH TIME ZONE;
On large tables, this can block reads and writes during the metadata change. Some engines can add nullable columns instantly, but others rewrite the table. In MySQL, ALTER TABLE may copy data unless you use ALGORITHM=INPLACE or ALGORITHM=INSTANT (available in newer versions).
For columns with default values, be aware that some engines backfill the entire table. This can cause downtime in high-traffic systems. To avoid disruption, deploy in two steps: add the column as nullable without a default, then backfill in small batches, and finally set the default constraint.