A new column changes everything. It adds structure, unlocks queries, and makes future changes easier. In SQL, adding a new column is a precise operation. You define the column name, its data type, default values, and constraints. Done wrong, it can lock tables, break applications, or corrupt data. Done right, it’s instant power.
The most direct way in SQL:
ALTER TABLE users
ADD COLUMN last_login TIMESTAMP DEFAULT NOW();
This adds the last_login column with a default timestamp of the current moment. On large datasets, consider running the change in a maintenance window, or create the column with NULL values first to avoid full table locks.
In PostgreSQL, adding a column is usually fast because new columns with a default NULL don’t rewrite the entire table. Defaults with non-null values may trigger a table rewrite, which can take time. In MySQL, behavior depends on the storage engine, so always check before pushing to production.