The query runs, but the output is wrong. You scan the table. The fix is simple: add a new column.
Adding a new column in modern databases is not just a schema change. It is a decision that touches performance, migrations, version control, and downstream services. Whether you work with PostgreSQL, MySQL, or a distributed SQL engine, the operation unlocks new capabilities but demands precision.
In SQL, the typical syntax is direct:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP;
This stores a timestamp of the last login for each user. But before running it, check the impact. Adding a column will update metadata. In large tables, write locks may occur. In systems with heavy traffic, migrate during low-load windows or use online DDL tools if supported.
Use nullable columns carefully. Setting NOT NULL with no default can break inserts. Adding defaults initializes rows and can extend migration time. Always plan indexes upfront. A new column without an index can slow lookups; an unnecessary index can make writes expensive.