The query ran. The table stared back, unchanged. You knew what it needed—a new column.
Adding a new column is not glamorous, but it decides whether your data model works or rots. It shapes performance, storage, and how teams interact with the schema. In SQL, ALTER TABLE is the standard. It’s simple in syntax, yet the implications run deep.
ALTER TABLE users
ADD COLUMN last_login_at TIMESTAMP;
This command extends the schema in place. On small datasets, it’s instant. On massive tables, it can lock writes, spike CPU, and push replication lag. Understand execution plans before running in production. Evaluate column defaults carefully; if you set one, the database may rewrite the table to fill it. This can burn hours.
For most relational systems—PostgreSQL, MySQL, SQL Server—the concept is the same but performance characteristics differ. PostgreSQL can add nullable columns without rewriting. MySQL may require a full table copy unless you use newer versions with instant DDL support. The right approach lowers downtime risk.