Adding a new column in a production database is not just about writing ALTER TABLE. It’s about speed, safety, and avoiding downtime. The cost of locking a large table can be high. Schema changes must be planned with precision.
The simplest approach is to run:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP;
This works for small datasets. On large tables, it can block reads and writes. For high-traffic systems, migrations should run online. Tools like pt-online-schema-change or native database features can create a new column without downtime by copying rows incrementally.
Naming matters. Define a purpose-driven name, use consistent casing, and avoid reserved words. Set the correct data type. Apply defaults when safe. If backfilling is needed, do it in batches to prevent load spikes.