Adding a column to a database table should be simple, but in production, nothing is simple. Schema changes can block writes, trigger downtime, or even crash services if executed blindly. The goal is to add the new column without locking users out or degrading performance.
First, decide the column type and constraints. VARCHAR, INT, JSON—choose the storage format that matches your workload. If the column will be indexed, factor the cost of index creation. On large datasets, building an index can be more expensive than the column itself.
For relational databases like PostgreSQL or MySQL, use ALTER TABLE ... ADD COLUMN with care. On small tables, this is fast. On large, hot tables, it can trigger table rewrites. PostgreSQL supports adding nullable columns with a default value without a full rewrite, if you supply the default in future updates instead of in the statement. MySQL versions with instant DDL capabilities can add certain column types in place, but only under specific conditions.
If you need to add a new column with non-null constraints, the safe pattern is: