In modern databases, adding a new column is one of the most common schema changes. It sounds simple, but the way you do it can have consequences for performance, data integrity, and deployment safety. Whether you work with PostgreSQL, MySQL, or another relational database, the mechanics are similar: define the column, choose the right data type, and update your application code to handle it.
The SQL syntax is direct:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP;
This command gives each row a new field, but that’s only the start. If your table holds millions of rows, the operation can lock writes, slow queries, or even block your application. On production systems, you need an approach that avoids downtime. For PostgreSQL, using ADD COLUMN without a default value can be instant. If you must set a default, consider adding the column first, then updating values in smaller batches to reduce locking.