In most databases, adding a new column is simple. The choice of method determines whether the change is instant, locked behind a migration, or blocks writes for minutes. Knowing which path to take can decide the uptime of your service.
In SQL, the ALTER TABLE statement defines this change. In MySQL or PostgreSQL, the syntax to add a new column is straightforward:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP;
This creates the column, but it may not be free. On large tables, this operation can lock the table. Some engines rewrite the entire table file when adding a column with a default value. Others, like PostgreSQL with NULL defaults, only change the metadata. Understanding how your database stores new columns lets you plan migrations that avoid downtime.
For critical systems, you often deploy schema changes in stages. First, add the column as nullable. Then backfill data in small batches to avoid load spikes. Finally, add constraints or indexes once the data is ready. Each step reduces the risk of locking out requests or causing replication lag.