In relational databases, adding a new column is one of the most common schema changes. Done carelessly, it can lock tables, break queries, or corrupt production data. Done right, it keeps services stable and edits the schema without downtime.
A new column can be added for tracking state, storing computed results, or enabling fresh business logic. In SQL, the command is straightforward:
ALTER TABLE orders ADD COLUMN status VARCHAR(20) NOT NULL DEFAULT 'pending';
The complexity lies in the environment. For large tables, adding a column with a default value may rewrite the entire table. In PostgreSQL, adding a nullable column without a default is usually instant. Then you can backfill data in small batches to avoid blocking operations.
For MySQL, the impact depends on storage engine and version. InnoDB before certain versions locks the table completely. Newer versions support instant column addition for some data types. Always confirm with SHOW CREATE TABLE and test on staging data.