Adding a new column should be simple. In practice, it carries risk: downtime, data corruption, broken queries. The process depends on your database engine, your schema scale, and your deployment pipeline. Done wrong, it can stall a release or force a rollback.
In SQL, the basic syntax is direct:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP;
This works instantly on small tables. On large production datasets, it can lock rows and block writes for minutes or hours. For high-availability systems, that’s unacceptable. Avoid blocking migrations by using features like ALGORITHM=INPLACE in MySQL or ADD COLUMN … DEFAULT NULL in Postgres without filling existing rows. Fill the data in background jobs, not in a single transaction.
Always version-control schema changes. Pair each new column addition with application code that can handle null states and legacy rows. Deploy the code first, then the schema, or run both in parallel until usage is stable. This reduces the blast radius of change.