Adding a new column should be fast, safe, and predictable. Done right, it improves performance, enables new features, and keeps schema drift under control. Done wrong, it blocks deploys, locks rows, or corrupts data.
Start with the schema. In SQL, ALTER TABLE adds a column to an existing table. The syntax is simple:
ALTER TABLE users
ADD COLUMN last_login TIMESTAMP DEFAULT NOW();
For high-traffic databases, consider the cost. On large PostgreSQL tables, a new column with a non-null default can rewrite the table, creating downtime. Use NULL defaults or backfill in batches. In MySQL, watch for table rebuilds. In cloud-managed systems like BigQuery or Snowflake, column additions are metadata-only, but type changes still require caution.
Plan migrations. Wrap schema changes in transactions if your database supports them. For zero-downtime patterns, run an additive migration first, deploy code that uses the new column, then remove legacy fields later. When working in a CI/CD pipeline, ensure migrations are idempotent and repeatable.