Adding a new column to a table is simple in syntax but complex in impact. In SQL, the command is direct:
ALTER TABLE orders ADD COLUMN status VARCHAR(20);
This tells the database to extend the table with a column named status. The type defines the data each row will hold. What comes next depends on your workload, constraints, and the scale of your data.
On large datasets, a new column is not just an extra field. It can lock tables, spike I/O, and block concurrent writes. Modern databases use different strategies to reduce downtime. PostgreSQL can add a column with a default NULL in constant time. MySQL’s behavior varies with storage engines and version. Knowing these differences is the key to safe migrations.
A new column often comes with defaults, indexes, or computed values. Defaults set initial data automatically. Indexes speed up queries but slow down writes. Generated columns can store computed results without application code. Each choice affects read and write paths, cache usage, and query planning.