Adding a new column changes the shape of your schema. It can hold fresh values, unlock features, or store computed results. In SQL, the syntax is simple:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP;
This command tells the database to alter the users table and append last_login. Most relational databases—PostgreSQL, MySQL, SQL Server—follow a similar pattern with small differences in keywords or constraints.
When adding a column to a large production table, consider performance. On high-traffic systems, a blocking ALTER TABLE can interrupt queries. PostgreSQL can add nullable columns without rewriting the entire table, but adding defaults may trigger a full table rewrite. MySQL’s behavior depends on the storage engine and version. Always test migrations in a staging environment before touching production.
Think about constraints and indexes at creation. Adding NOT NULL with a default can make queries simpler, but might lock the table during the update. Indexes on a new column can speed lookups but also impact write performance.