Adding a new column is one of the most common database schema changes in active production systems. It looks simple. It isn’t. Whether you work with PostgreSQL, MySQL, or SQL Server, the wrong approach can lock tables, stall writes, and break live queries. The right approach adds flexibility without downtime.
Start by defining the exact column name, data type, and nullability. For PostgreSQL, use:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP;
This is instant for small tables, but large tables can take time and block traffic. In high-load environments, consider adding the new column as nullable first, backfilling in batches, and only then enforcing constraints.
In MySQL, modern versions with ALGORITHM=INPLACE can add a nullable column without rebuilding the table. Older versions require a full copy, which is slow. In SQL Server, adding a nullable column is usually metadata-only, but adding with a default forces a full rewrite.