Adding a new column to an existing database table is not hard, but it is easy to do wrong. The wrong approach locks tables, slows queries, or breaks deployments. The right approach integrates smoothly with production traffic, preserves data, and keeps your release predictable.
A new column starts with a clear definition. Specify the name, data type, and nullability. Decide on a default value or if it can remain NULL. In relational databases like PostgreSQL or MySQL, the ALTER TABLE command is standard:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP WITH TIME ZONE;
Avoid schema changes during peak load. On large datasets, adding a column with a default value can rewrite the entire table. This can block reads and writes. Use NULL first, then backfill with an online process to avoid downtime.