The query runs. The table responds. But the data you need sits in a separate field that doesn’t exist yet. You need a new column.
A new column in a database is not just structure — it’s a decision about storage, performance, and future compatibility. Whether you’re in PostgreSQL, MySQL, or a distributed data store, adding a new column means altering the table definition. The ALTER TABLE command is the core operation. In PostgreSQL:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP;
This changes the schema instantly for empty or small tables, but large datasets can lock rows and pause writes. Minimize downtime by using concurrent schema change tools or background migrations.
Think about defaults. Setting a DEFAULT value bakes in both behavior and cost. In some systems, applying a default to an existing column writes that value to every row. That can take seconds on a small table and hours on a big one. If your workload tolerates nulls, create the column without defaults, then backfill in small batches.