Adding a new column is one of the most common schema changes in modern systems. Yet doing it safely, without downtime or data loss, demands precision. In SQL, the syntax is direct:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP DEFAULT NOW();
The ALTER TABLE command applies across MySQL, PostgreSQL, and most relational databases. But the execution cost and migration strategy depend on scale. In small datasets, the change is near-instant. In large production tables, adding a new column can lock writes and block queries.
Best practice is to create the column with a default value or NULL allowance to prevent backfill from stalling production. For multi-tenant systems or high-traffic applications, run the change during off-peak hours or use an online schema change tool to avoid blocking. PostgreSQL’s ADD COLUMN with a constant default in newer versions is now optimized to avoid full table rewrites — a critical improvement for uptime.