Adding a new column to a production database is simple in syntax but dangerous in execution. Done right, it keeps the system stable. Done wrong, it locks tables, drops performance, or corrupts live data.
In SQL, adding a column is direct:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP NULL;
The statement is short, but the implications run deep. Choose the correct data type from the start. Decide if it can be null. Consider indexes only after the column is live—adding both at once can block writes for too long.
For large tables, use an online schema change process. Tools like gh-ost or pt-online-schema-change avoid full table locks. On Postgres, review ALTER TABLE ... ADD COLUMN performance on your version; in many cases adding a nullable column is instant, but adding with a default can rewrite the entire table.