Adding a new column to a database table is one of the most common schema changes. Done right, it’s fast, safe, and predictable. Done wrong, it can lock your application, stall deployments, and break production. The best approach depends on the size of your data, the database engine, and the type of workloads running at the moment you apply changes.
For relational databases like PostgreSQL, MySQL, and MariaDB, the simplest method is the ALTER TABLE command. Use it when you know the table is small or you can tolerate a brief lock:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP;
For large tables or high-traffic systems, an online schema change tool is better. Tools like gh-ost and pt-online-schema-change create the new column without blocking writes. They copy data in the background, then swap tables in one atomic step. This avoids downtime and preserves performance during migration.