Adding a new column to a database table should be simple, fast, and reliable. Yet in production systems, schema changes can carry risk: downtime, locked writes, and inconsistent reads. The key is choosing the right method for your database engine, workload, and deployment strategy.
In SQL, a typical new column operation looks like:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP;
This works for small tables during low traffic. But with large datasets, this command can lock the table and block queries. For PostgreSQL 11+, adding nullable columns without defaults is nearly instantaneous. Adding columns with defaults requires a careful migration plan.
In MySQL, ALTER TABLE may rebuild the entire table unless you use ALGORITHM=INPLACE where supported. Even then, watch for triggers, indexes, and replication lag.