Adding a new column is one of the most common operations in schema design. It looks simple, but if done carelessly, it can break code, lock tables, or slow queries. Whether you are working with PostgreSQL, MySQL, SQLite, or a cloud-managed database, the core steps are the same: define the column, set the type, decide on defaults, and handle existing data.
Use an explicit ALTER TABLE command to create the new column. Always define the column type with precision—avoid generic or deprecated types. If a default value is needed, set it in the same statement so that existing rows are populated in a single pass. Without a default, NULL will be inserted for old rows, which may break downstream systems.
On large tables, adding a new column can lock writes. In PostgreSQL, using ADD COLUMN with a default on older versions rewrites the entire table. The safer pattern is to add the column as nullable, backfill data in chunks, then add the NOT NULL constraint. MySQL’s ALTER TABLE can trigger a full table copy unless you’re using an online DDL feature like ALGORITHM=INPLACE. Understand how your database executes schema changes before applying them in production.