Adding a new column to a database table is simple in theory, but in production it has to be precise. The right approach depends on your system load, the database engine, and your rollback plan. Done wrong, you introduce downtime, lock contention, or unplanned schema drift.
In SQL, the most direct method is ALTER TABLE. For example:
ALTER TABLE orders
ADD COLUMN processed_at TIMESTAMP NULL;
This command creates the new column without touching existing data. On small tables, it completes instantly. On high-traffic production workloads, even this operation can lock writes. That’s why many teams batch schema changes using tools like pt-online-schema-change or built-in features like PostgreSQL’s ADD COLUMN with default values deferred until update.
A new column should come with a migration strategy. Start with a nullable column. Deploy. Backfill in controlled batches to avoid overwhelming the database. Update application code to use the column only after data is complete. Finally, enforce constraints when you are certain the data meets them.