Adding a new column is one of the most common schema changes, yet it carries risk. Done wrong, it locks queries, bloats the database, or breaks production code. Done right, it extends your data model with zero downtime.
Start with the definition. A new column means adding a field to an existing table. In SQL, it’s a direct command:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP;
Simple syntax hides complex impact. The database must update its metadata. Depending on engine and storage, it may rewrite the entire table or apply changes in place.
Plan for data type. Choose the smallest type that holds the required values. In modern systems, oversized types slow reads and writes. Set NOT NULL only when historical records can be backfilled at creation time. If old rows have no data for this column, use NULL until a migration sets defaults.