When databases evolve, adding a new column is one of the most common operations. It looks simple, but mistakes here cause downtime, lost data, and broken queries. Schema changes must be predictable, tracked, and tested before they hit production.
A new column in SQL alters the table structure. You define its name, data type, default values, and constraints. Done right, it integrates cleanly with existing code. Done wrong, it stalls deployments and forces costly rollbacks. Always pair it with version control for schema migrations.
For relational databases like PostgreSQL, MySQL, and MariaDB, ALTER TABLE ... ADD COLUMN is the direct command. In PostgreSQL, you can add a new column with:
ALTER TABLE orders
ADD COLUMN shipped_at TIMESTAMP;
If your table is large, adding a column with a default can lock writes and block queries. Avoid setting a default in the migration. Add the column first, backfill in batches, then set defaults. This approach keeps production responsive.