Adding a new column to a database is simple to describe but critical to execute well. It changes the contract between your application and the data it owns. Done carelessly, it can cause downtime, break queries, and corrupt reports. Done right, it extends functionality without harm.
First, decide where the new column belongs. Confirm that it matches the table’s purpose and that denormalization is intentional. Check the type constraints. Avoid default values that hide migration errors.
In SQL, add the column with an ALTER TABLE statement:
ALTER TABLE users
ADD COLUMN last_login TIMESTAMP;
On large tables, this can lock writes. Many production databases require online schema changes to avoid blocking traffic. Tools like pt-online-schema-change or native ALTER algorithms in MySQL and PostgreSQL can help.