The query ran. The output stared back. But the schema was wrong. You needed a new column, and nothing else would fix it.
Adding a new column to a database table is simple in theory. The choice of method depends on the database engine, table size, and downtime tolerance. For PostgreSQL, an ALTER TABLE ADD COLUMN statement is the standard.
ALTER TABLE users
ADD COLUMN last_login TIMESTAMP;
This adds the column without touching existing rows, allowing nulls by default. If a default value is required for all rows, adding it inline will rewrite data on disk. On large tables, this can lock writes and stall the system. In these cases, adding the column as nullable, then backfilling in small batches, is safer.
For MySQL and MariaDB, the same command applies. However, on older storage engines or MySQL versions without instantaneous DDL, be aware of table copy costs. For zero-downtime migrations, use an online schema change tool like pt-online-schema-change or gh-ost.