Adding a new column sounds simple. Done wrong, it can become a breaking change that ripples through queries, APIs, and downstream services. Done right, it becomes part of your data model with zero surprises.
In SQL, ALTER TABLE is the standard way.
ALTER TABLE users ADD COLUMN last_login TIMESTAMP;
This command updates the schema instantly, but think about constraints. Defaults prevent null values from spilling into reports.
ALTER TABLE users ADD COLUMN last_login TIMESTAMP DEFAULT CURRENT_TIMESTAMP;
If you work with large datasets, adding a new column can lock tables. Plan for migrations during low-traffic windows. Use transactional DDL in systems that support it, or break the change into steps that reduce load.
In NoSQL, a new column often means adding a new field to each document. With MongoDB: