Adding a new column to a database table can be trivial or it can halt production if done without planning. The difference lies in knowing the engine, the data size, and the impact on reads and writes. On small tables, a new column is fast. On large, high-traffic tables, it demands care.
In SQL, the syntax is simple:
ALTER TABLE orders ADD COLUMN processed_at TIMESTAMP;
For relational databases like PostgreSQL or MySQL, this change modifies the schema. Defaults, nullability, and indexing all affect migration speed. Avoid adding non-null columns with defaults in a single step on large datasets; do it in stages or with async backfill.
In PostgreSQL, using ADD COLUMN with a default rewrites the table. Skip the default at first, set it later with UPDATE, and then add constraints. In MySQL, impact depends on the storage engine and version—modern InnoDB handles many adds instantly if no data rewrite is needed.