Adding a new column sounds simple, but it carries hidden weight. In modern systems, a column change can break queries, affect indexes, or trigger expensive migrations. The key is to do it with precision, speed, and zero downtime.
In SQL, the ALTER TABLE command is the gateway. For example:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP;
This works, but in production the details matter. Check constraints. Set sensible defaults. For large datasets, adding a column with a default value can rewrite the whole table. Avoid that by adding the column first without a default, then backfilling asynchronously, then adding the constraint.
For PostgreSQL, adding a nullable column is instant. Adding one with NOT NULL requires either a default or a full scan, so phase it. In MySQL, behavior differs by engine—InnoDB may rebuild the table for certain changes unless you use ALGORITHM=INPLACE when possible.