The query ran, and the data came back wrong. You knew it before the logs confirmed it. The missing field wasn’t a bug in logic—the table itself needed a new column.
Adding a new column to a database table is one of the most common schema changes. Done right, it’s smooth. Done wrong, it can lock rows, block queries, and bring down production. The approach depends on your database engine, its storage model, and your tolerance for downtime.
In SQL, a new column is defined with an ALTER TABLE statement:
ALTER TABLE users
ADD COLUMN last_login TIMESTAMP;
This works instantly for small tables. On large ones, the database may need to rewrite data or update metadata. PostgreSQL can often add nullable columns without a full table rewrite. MySQL before 8.0 may lock the entire table during the change. In distributed databases, adding a new column might trigger schema propagation that impacts cluster performance.