Adding a new column in a production environment is simple in theory and dangerous in practice. Schema changes can block queries, trigger lock contention, and impact availability. The right approach depends on your database engine, data size, and tolerance for downtime.
In SQL, the basic syntax is direct:
ALTER TABLE users
ADD COLUMN last_login TIMESTAMP;
This works on small tables, but on large datasets it can lock the table for the duration of the change. In MySQL and PostgreSQL, modern versions offer non-blocking ADD COLUMN in many cases, but not all. Always check the documentation for the exact release you run.
For critical systems, zero-downtime migrations are the standard. Use an online schema change tool like gh-ost or pt-online-schema-change for MySQL, or break the work into smaller steps in PostgreSQL by adding the column without defaults, backfilling in batches, then applying constraints.