The query ran, the results returned, but something was missing. A new column.
Adding a new column to a database table should be simple, fast, and safe. Yet it can be the point where downtime, data mismatch, or broken code slips in. Whether you use PostgreSQL, MySQL, or another RDBMS, the method matters. Schema changes are not just technical; they are operational events that affect systems, pipelines, and users in real time.
The first step is to define the column precisely. Specify the name, data type, nullability, and default values. In PostgreSQL:
ALTER TABLE orders
ADD COLUMN shipped_at TIMESTAMP WITH TIME ZONE;
This statement adds the column without touching existing rows except to register the metadata. For large tables in production, consider tools or methods that perform online schema changes. In MySQL, ALTER TABLE can lock the table, so using pt-online-schema-change or native ALGORITHM=INPLACE helps avoid blocking writes.
If you need to backfill values, avoid a single massive update. Use batches to control load, maintain index performance, and prevent replication lag. Monitor queries and replication status during the process.