Adding a new column changes the shape of your data. It can unlock new queries, store more attributes, or support new features in production. Done right, it’s instant power. Done wrong, it risks downtime and bad migrations.
In SQL, the ALTER TABLE statement is the core tool:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP;
This adds the column without dropping data. Always define the type, constraints, and default values. If the table is large, consider the impact on locks and replication lag.
For NoSQL databases, adding a new column might mean updating document schemas or inserting fields in JSON objects. In MongoDB:
db.users.updateMany({}, { $set: { last_login: null } });
It’s fast but keep in mind schema consistency across services.