Adding a new column sounds simple, but speed, safety, and zero downtime matter when the system is live. A poorly executed change can lock tables, block queries, or cause application errors. The best method depends on the database engine, the size of the table, and the requirements for default values and nullability.
In SQL, the standard syntax is direct:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP;
For small tables, this runs instantly. For large ones under heavy load, background migrations or online schema changes are safer. PostgreSQL supports ADD COLUMN with a default value as a fast metadata change if you use DEFAULT without NOT NULL. MySQL may copy the table unless you use tools like pt-online-schema-change or native ALGORITHM=INPLACE when available.
Plan for application compatibility. Deploy code that can handle both the old and new schema before altering the table. Avoid making the column required until existing rows are backfilled. Use transactional DDL when supported to ensure atomicity.