The database table was ready, but the query failed. The reason: no place for the data. It needed a new column.
Adding a new column should be simple, but choice and timing matter. Schema changes can break production if not planned. You must decide the column name, type, constraints, default values, and whether it should allow nulls. Every decision has impact on query performance, indexing, and storage.
In SQL, the syntax to add a column is direct:
ALTER TABLE orders
ADD COLUMN delivery_date TIMESTAMP;
This modifies the structure without touching existing rows. But the change is not free. On large tables, ALTER TABLE can lock writes and block reads. Some databases copy the entire table when adding a column with a default value. Others allow fast metadata-only changes. Know your engine.
When you add a new column in PostgreSQL without a default or NOT NULL constraint, it’s near instant. Adding a column with a default will rewrite table data in older versions. In MySQL, adding a column can be fast with ALGORITHM=INPLACE, but not with every storage engine or column type.