Adding a new column to a database table changes the schema. It can store fresh values, support new features, or improve query efficiency. The process depends on your database engine, but the principle is the same: define the column, set the type, decide on nullability, and deploy without breaking production.
In SQL, adding a new column often looks like this:
ALTER TABLE users
ADD COLUMN last_login TIMESTAMP NULL;
This statement adds last_login as a timestamp. If you need a default value, set it during creation to avoid null checks in code.
When adding a new column to a live system, plan for migrations. Backfill data if required. Use batches to avoid locking large tables for long periods. Monitor query performance before and after the schema update.
In PostgreSQL, ALTER TABLE ... ADD COLUMN is fast when adding nullable columns without defaults. In MySQL, adding a column may lock the table unless using an engine with online DDL support. In distributed databases, schema changes may propagate asynchronously—keep consistency rules in mind.