Adding a new column should be simple, but in live systems it can cause downtime, data corruption, or failed deployments if handled wrong. Precision matters. The fastest path starts with a clear plan: define the field, set constraints, consider indexes, and understand the lifecycle from migration to deployment.
In SQL, the basic syntax is straightforward:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP;
On small datasets, this runs instantly. On large production tables, this can block queries and slow everything to a crawl. The safe approach is to run migrations in a way that avoids locks or to use online schema change tools like gh-ost or pt-online-schema-change.
For PostgreSQL, adding a nullable column without a default is often instant. Adding a default with a write to every row is not. MySQL behaves differently—an ALTER TABLE may rebuild the whole table. Always check engine-level behavior before running the change.