Adding a new column to a production database is simple in concept but dangerous in execution. One mistake can cause downtime or data loss. The right approach depends on database type, table size, and the system’s tolerance for changes under load.
First, define the purpose and data type of the new column. Use the smallest type that works, because every byte matters in storage and performance. Avoid NULL defaults unless required, as they can increase complexity in queries and indexing.
Next, consider the migration strategy. In small tables, ALTER TABLE may finish instantly. On large tables, that same command can lock writes for minutes or hours. For PostgreSQL, ALTER TABLE ... ADD COLUMN is fast if no default value is set, but any default backfill can be costly. MySQL and MariaDB often require special handling; tools like pt-online-schema-change or native online DDL features minimize impact.