The query finished running, and you realize the data is wrong. A missing value, a duplicated entry, and now you need a new column.
Adding a new column should be simple, but mistakes here can ripple through your schema. First, decide if the column is truly required. Every column adds weight: more storage, more indexes, more cognitive overhead in queries. When the need is clear—extra metadata, computed fields, feature flags—choose the right type. Integers for discrete values, text for strings, boolean for flags, timestamps for events. Never use a type “just to get it working.” Precision now saves hours later.
In SQL, the syntax is direct:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP;
For large tables, run this during low traffic or in batches. In production, even a simple new column can lock writes and slow reads. If you use Postgres, check if the new column can be added with a default value without rewriting the whole table. In MySQL, be wary of old versions that still perform a full table rebuild. With NoSQL, a new field may require migration logic across documents.