Adding a new column can seem small, but it touches data integrity, performance, and application logic. The operation is simple in syntax but complex in impact. You have to decide the column type, default values, nullability, and indexing. Each choice carries a cost.
In SQL, the basic form is direct:
ALTER TABLE users ADD COLUMN last_logged_in TIMESTAMP;
This runs fast on small tables. On large ones, it can lock writes and force full table rewrites, depending on the database engine. For MySQL, ALTER TABLE is often blocking without ALGORITHM=INPLACE or ALGORITHM=INSTANT (when supported). In PostgreSQL, adding a nullable column without a default is cheap; adding one with a default can rewrite every row.
Plan migrations so the schema change and application rollout are decoupled. Deploy the column first, ensure the code can handle it, then backfill data asynchronously if needed. Avoid adding non-nullable columns with defaults in a single step on production-scale datasets.