The query ran, but the table was wrong. A missing field had broken the flow. You needed a new column.
Adding a new column is one of the most common schema changes in relational databases. Done well, it’s fast, safe, and predictable. Done poorly, it can lock rows for minutes, take applications offline, or corrupt production data.
The first step is to define the column with the correct type, nullability, and default value. Every choice here affects performance and storage. ALTER TABLE is simple syntax, but its behavior changes between MySQL, PostgreSQL, and newer cloud-native systems. Some engines rewrite the table in place. Others create a copy. Knowing this determines whether the migration is instant or blocking.
For large datasets, use online schema change tools. MySQL has ALGORITHM=INPLACE and LOCK=NONE options. PostgreSQL can add nullable columns instantly, but adding defaults may rewrite the table unless you use the newer default-expression optimization. In distributed SQL, the command often triggers background replication changes that run without downtime, but still require monitoring.