The table is ready, but something’s missing. You need a new column. Not later. Now.
Adding a new column is one of the most common schema changes, yet it’s also one of the easiest places for mistakes to slip in. Whether you’re working with PostgreSQL, MySQL, SQLite, or a distributed database, the process looks simple but has deep consequences for performance, downtime, and backward compatibility.
In PostgreSQL, the fastest and safest way to add a nullable column without a default is:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP;
This executes instantly because it updates metadata only. If you add a default value, PostgreSQL will rewrite the entire table, which can lock rows and slow queries. For zero-downtime, first add the column as null, then backfill in small batches, then set the default and constraints.
MySQL works differently. Adding a column often triggers a table copy unless you use ALGORITHM=INPLACE or options available in newer versions. With large datasets, use ONLINE DDL when supported to avoid blocking writes.