Adding a new column is one of the most common schema changes in production systems. It sounds simple, but done wrong it can lock tables, block writes, or cause downtime. The goal is to add it without breaking availability or corrupting data.
First, confirm the use case. Decide the data type, default value, nullability, and indexing strategy before altering the table. Changing any of these after deployment is more expensive than getting them right up front.
Next, analyze your database engine’s behavior. In MySQL, ALTER TABLE can trigger a full table copy. PostgreSQL can add a nullable column instantly, but adding a default value will rewrite the table unless you use a version that supports metadata-only defaults. For very large datasets, these details matter.
Use a migration tool that supports online schema changes. For MySQL, gh-ost or pt-online-schema-change can add a new column without locking writes. For PostgreSQL, wrap the migration in a transaction if possible. Always deploy to a staging environment first and measure execution time.