Adding a new column in a database is simple in syntax, but sharp in consequence. Whether you use PostgreSQL, MySQL, or SQLite, the decision ripples through queries, indexes, and storage. A new column changes the schema, alters performance, and impacts every upstream service that touches it.
In PostgreSQL, the most direct way is:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP;
This is instant for most metadata-only changes. But adding a column with a default value that’s not NULL can lock your table until it rewrites the data. On a large table, that can break production. If you need a default, add the column as NULL, then backfill in batches, then set the default and constraints.
In MySQL, ALTER TABLE can trigger a full table copy, depending on the engine and MySQL version. That means downtime or degraded performance for high-traffic systems. Newer features like ALGORITHM=INPLACE or ALGORITHM=INSTANT reduce this risk, so use them when possible.
For SQLite, adding a new column is straightforward: