When schema changes slow development, performance suffers. Adding a new column is simple in concept but can be dangerous in practice. The wrong move can lock tables, stall queries, or corrupt data. Doing it right requires clear steps and awareness of the platform’s constraints.
In SQL, ALTER TABLE is the core tool.
ALTER TABLE users ADD COLUMN last_login TIMESTAMP;
This command adds a new column without changing existing rows. Default values, nullability, and indexes should be decided before execution. A column added with NOT NULL requires immediate data population. Adding an indexed column on a large table can trigger a full rebuild.
For PostgreSQL, adding a nullable column is fast. Adding a column with a default can rewrite the table unless you use DEFAULT with NULL and backfill later. In MySQL, ALTER TABLE often rebuilds the table entirely, increasing downtime risk. Plan migration windows and test on replicas before production.