Adding a new column to a database table is one of the most common schema changes, yet it can cause silent data loss or downtime if done wrong. The right approach depends on your database engine, traffic patterns, and your deployment workflow.
In SQL, the syntax is simple:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP;
But simplicity in syntax hides the complexity in production. Adding a column to a large table can lock writes. On PostgreSQL, adding a nullable column with a default requires rewriting the whole table unless you use a NULL default, then backfill in batches. MySQL’s ALTER TABLE can be instant with ALGORITHM=INPLACE for some types but not others.
Plan for forward and backward compatibility. Deploy schema changes before code that uses the new column. If your ORM supports migrations, generate them, then inspect the raw SQL. Avoid implicit type changes that may reformat or move data.