Adding a new column is simple in principle but dangerous in production. Done right, it opens the door to richer data, better analytics, and evolving business logic. Done wrong, it locks queries, breaks dependencies, or triggers downtime.
The first step is to identify required data types. Text, integer, timestamp — each choice affects storage, indexing, and query speed. Default values matter. Null handling matters. Constraints matter. A careless default can cascade through systems in ways that wreck performance.
For relational databases like PostgreSQL or MySQL, an ALTER TABLE command adds a new column without dropping existing data. In PostgreSQL:
ALTER TABLE orders ADD COLUMN shipped_at TIMESTAMP;
Think about indexing. Adding an index on the new column can speed queries but also slows writes. Benchmark both. In distributed databases, schema changes are more complex. Tools like gh-ost or pt-online-schema-change help avoid downtime in MySQL. In PostgreSQL, ALTER TABLE ... ADD COLUMN is fast for metadata-only changes, but adding defaults in older versions rewrites the table.