Adding a new column to a database table should be simple. Yet every change to production data has risk. Locking, downtime, and inconsistent state can all happen if the operation isn’t planned and executed well.
In relational databases like PostgreSQL, MySQL, or MariaDB, the ALTER TABLE command lets you add a new column with a defined data type and constraints. The syntax is direct:
ALTER TABLE users
ADD COLUMN last_login TIMESTAMP NULL;
This works instantly on small tables. On large tables, performance costs rise. Depending on the database engine, adding a new column may rewrite the entire table. That triggers I/O spikes, replication lag, and degraded query performance.
Online schema change tools such as pg_online_schema_change, gh-ost, or pt-online-schema-change can add columns with minimal blocking. These tools create a shadow table, copy data in chunks, and swap it in when ready. This pattern reduces transactional locks and operational noise in high-throughput systems.