Adding a new column should be fast, predictable, and safe. In SQL databases, a ALTER TABLE ... ADD COLUMN statement modifies a table without losing existing data. The syntax is straightforward:
ALTER TABLE users
ADD COLUMN last_login TIMESTAMP;
In most relational databases, this change is instant if the new column is nullable or has a default value. If you set NOT NULL without a default, the database must rewrite data, which can lock large tables and slow production. Choose the right constraints based on your workload and deployment rules.
Indexes on a new column are a separate step. Create them only after confirming that queries will use them. For high-traffic systems, index creation on a live table can be optimized with concurrent or online options.
When adding a new column with application code changes, deploy in two phases. First, release the column to the database with safe defaults. Then, update the application to read from and write to it. This avoids runtime errors when code expects a field that doesn’t exist yet.