Adding a new column changes the shape of your data. It expands what you can store, query, and transform. Done right, it gives clarity to queries and power to analytics. Done wrong, it slows performance, locks tables, or corrupts production data. Precision matters.
In relational databases, a new column starts with an ALTER TABLE statement. The specifics depend on the engine. In PostgreSQL:
ALTER TABLE users
ADD COLUMN last_login TIMESTAMP;
For large datasets, consider the consequences. An ALTER TABLE can trigger a full table rewrite. That means blocking writes and reads, even in modern engines. On MySQL with InnoDB, online DDL can help. In PostgreSQL, use ADD COLUMN with a DEFAULT that avoids rewriting existing rows when possible.
Always check constraints. Adding a NOT NULL column without a default requires rewriting all rows. On production, this can take seconds or hours depending on data size. Use nullable columns first, backfill in small batches, then enforce constraints.