The database waited, silent, until the command dropped: ALTER TABLE ADD COLUMN. One keystroke, and the schema shifted. A new column was born.
Adding a new column is one of the most common schema changes in production systems. When done right, it’s fast and safe. When done wrong, it locks rows, blocks queries, and forces downtime nobody can afford. Every system has quirks—PostgreSQL, MySQL, and SQLite handle schema changes differently. Understanding their execution paths is the difference between a smooth deployment and a burned rollback window.
In PostgreSQL, adding a new nullable column without a default is instant. The database updates the table metadata; it does not rewrite the entire table. But add a default value, and older versions will rewrite every row. Since version 11, PostgreSQL optimizes this by only setting the default at read time until an explicit update happens.
On MySQL, the story depends on the storage engine. InnoDB used to rebuild the table for almost every ALTER TABLE operation. Recent versions support instant DDL for certain column additions, but not for all data types or constraints. Always check your execution plan before pushing changes to production.