The database table was ready, but the data model had changed. A new column was needed. Not tomorrow. Now.
Adding a new column seems simple. It isn’t. If you do it wrong in production, you risk downtime, locks, and broken code paths. The right approach depends on your database engine, your schema design, and the volume of live traffic. Understanding these factors lets you add functionality without risking system stability.
In SQL, the ALTER TABLE statement is the standard way to add a new column. For example:
ALTER TABLE users
ADD COLUMN last_login TIMESTAMP NULL;
On small tables, this runs instantly. On massive ones, it can block reads and writes. Postgres, MySQL, and other systems handle schema changes differently. With MySQL’s InnoDB, adding a column can rebuild the entire table unless you use ALGORITHM=INSTANT (available in newer versions). In Postgres, adding a nullable column with no default is fast, but adding a default value rewrites the table.