Adding a new column to a database table is simple in syntax, but heavy in consequence. The schema change touches every read, every write, every cache. On small datasets, it is routine. On large, high-traffic systems, it is a calculated risk.
In SQL, the core operation is clear:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP;
This command runs fast on empty tables, but on production-scale datasets it can lock the table, block writes, and cause downtime if handled carelessly. Before adding a new column in production, analyze the table size, storage engine, and transactional requirements.
For PostgreSQL, ALTER TABLE ... ADD COLUMN with a default value rewrites the whole table in versions before 11. Avoid this by adding the column without a default, then updating in batches. MySQL has similar pitfalls—older versions rebuild the table, while newer ones with Instant DDL avoid the rewrite for nullable columns without defaults.