Adding a new column is one of the most common schema changes in modern databases. Done right, it is fast, safe, and requires no downtime. Done wrong, it blocks queries, locks tables, and breaks production. This guide covers the essentials so you can implement a new column without risking your application.
First, define the column name and data type. Choose the smallest type that fits your data. Avoid defaults unless you need them. Large defaults can rewrite every row and slow migration.
Second, run the change in a safe window or use an online schema change tool. Most SQL databases, including PostgreSQL and MySQL, can add a nullable column instantly. Adding a column with a non-null default often triggers a full table rewrite. In high-traffic systems, this can block writes and degrade service.