Adding a new column is one of the fastest ways to evolve a database without rebuilding the system. It can store fresh data, unlock new features, or reshape queries. Simple in concept, critical in execution.
Before you create a new column, decide the type, nullability, default values, and indexing strategy. Each choice ripples through performance, schema migrations, and downstream services. Mistakes here become legacy debt.
In SQL, the syntax is direct:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP;
This works, but in production databases with millions of rows, you must weigh the cost. Adding columns on large tables can lock writes, delay transactions, or cause long-running migrations. Plan a deployment window or use tools with online schema change capabilities.