Adding a new column is one of the most common schema changes in modern applications. It should be fast, safe, and reversible. Yet in production, a poorly planned migration can lock tables, block writes, and bring down entire services. To do it right, you need to think about data type, defaults, indexing, and the exact sequence of operations your migration tool will perform.
In SQL, you can add a new column with:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP;
On small datasets, this runs in milliseconds. On large ones, it can trigger long table rewrites. Some engines, like PostgreSQL, can add certain columns instantly if you omit a default. MySQL until recent versions often required a full table copy. Understanding your database version and storage format is essential before you run the command.
If the new column needs a default value, set it in your application layer first. This avoids costly backfills during schema change. For example, deploy the new code that writes to the column, and only then backfill old rows in batches. Once all codepaths are using it, you can make the column NOT NULL safely.