The query ran. The table was old. It needed a new column.
Adding a new column to a production database is simple in syntax, risky in effect. The operation can block writes, lock rows, or inflate storage. Done right, it adds power without downtime. Done wrong, it stalls the system.
The first step is to understand the schema. Map the existing columns, indexes, and constraints. Decide the data type for the new column based on the smallest type that meets the requirement. Avoid generic types like TEXT unless necessary; they waste space and slow queries.
Use ALTER TABLE with care. On large tables, a direct ALTER TABLE ADD COLUMN can cause long table locks. Modern databases offer online DDL or non-blocking schema changes. MySQL’s ALGORITHM=INPLACE and PostgreSQL’s ADD COLUMN with a default NULL minimize locks. When backfilling, batch updates in small transactions to avoid saturating I/O.