Adding a new column is simple in concept. In practice, it can cause downtime, lock tables, or corrupt data if done wrong. The right approach depends on your database engine, schema complexity, and traffic patterns.
First, define the column's purpose and data type. Use precise types to avoid wasted storage and future migrations. For large tables, test column addition on a staging copy with realistic data and load. In PostgreSQL, adding a nullable column without a default is fast. Adding with a default rewrites the table. In MySQL, behavior depends on the storage engine and version.
For active production systems, avoid blocking writes. Use tools like pt-online-schema-change for MySQL or declarative migrations with zero-downtime flags in PostgreSQL. Break large changes into smaller, safe steps: