The query ran. The output was clear. But the schema had shifted, and the missing piece was simple: a new column.
Adding a new column is one of the most common and deceptively critical changes you will make to a database. It can alter storage needs, query plans, and system performance. Done carelessly, it locks tables, blocks writes, or breaks dependent code. Done well, it becomes invisible—just another part of the schema, serving its purpose without drawing attention.
In SQL, you create a new column with an ALTER TABLE statement. In PostgreSQL:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP WITH TIME ZONE;
This looks simple. But in production, simplicity hides risk. You must confirm the impact of defaults, nullability, and indexing. Adding a column with a default value that is non-null forces a table rewrite, which can stall large datasets. The safe pattern is often to add the column as nullable, backfill the values in small, controlled batches, and then apply a constraint if needed.
In MySQL and MariaDB, the command is similar: