The result set came back clean, but one thing was missing: a new column.
Adding a new column is one of the most common schema changes. It sounds simple, but doing it wrong can lock tables, block writes, and trigger downtime. The right approach depends on your database, dataset size, and uptime requirements.
In SQL, the basic syntax is direct:
ALTER TABLE table_name ADD COLUMN column_name data_type;
On small tables, this runs fast. On production-scale datasets, it can be dangerous. Some engines use a table rewrite, which can block all reads and writes during the operation. For high-traffic systems, you need an online schema change strategy.
MySQL and MariaDB support ALGORITHM=INPLACE or ALGORITHM=INSTANT for some column additions. PostgreSQL can add new columns instantly if you provide a NULL default. Setting a non-null default without NOT NULL avoids expensive table rewrites. Always test migration scripts in a staging environment that matches production load and indexes.