Adding a new column should be fast, predictable, and safe. Whether you are working with PostgreSQL, MySQL, or SQLite, the core mechanics are the same: define the new column, set its type, manage defaults, and handle backfill without blocking writes. The real challenge is adding it in production without downtime or data loss.
In relational databases, ALTER TABLE is the command for adding a new column. A simple form looks like:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP;
In development, this runs instantly. In production with millions of rows, it can lock the table and stall critical queries. To avoid this, schedule changes during low-traffic windows, or use tools that apply schema migrations online. For PostgreSQL, operations like adding a nullable column with no default are metadata-only and execute in milliseconds. MySQL with InnoDB requires careful choice of data types and may need ALGORITHM=INPLACE or ALGORITHM=INSTANT.
Defaults matter. Setting a default value at column creation can be expensive if the engine rewrites the table. Safer: add the column as nullable, backfill in batches, then set the default and NOT NULL constraint in a later migration. This keeps locks short and ensures indexes aren’t rebuilt unnecessarily.