Adding a new column is simple until it isn't. The wrong migration can lock tables, stall deployments, or drop rows into the void. The goal is speed without breaking production. That means knowing whether to use ALTER TABLE directly or to stage the change with zero-downtime patterns. In systems with heavy writes, an ALTER TABLE can block queries; instead, add the column as nullable, backfill in batches, then lock down constraints last.
In SQL, the basic syntax to add a new column is direct:
ALTER TABLE table_name
ADD COLUMN column_name data_type;
But databases differ. PostgreSQL handles new nullable columns fast, while MySQL can still block under load depending on the storage engine. Some teams use tools like gh-ost or pt-online-schema-change to run non-blocking migrations. Others wrap the schema change in a feature flag rollout, ensuring no code references the new field before it exists everywhere.