Every engineer has faced it. The database is live, production traffic is flowing, and someone needs new data. Adding a new column to a table sounds simple. It can be, but done wrong it can lock tables, stall writes, or break code. The stakes are low in dev, high in prod.
A new column changes the shape of your data. In SQL, the syntax is straightforward. In PostgreSQL:
ALTER TABLE users ADD COLUMN last_login TIMESTAMPTZ;
In MySQL:
ALTER TABLE users ADD COLUMN last_login DATETIME;
In both, the details matter. Choose the right data type. Set NULL or NOT NULL with intention. Decide if the default value is computed or static. Avoid heavy defaults on large datasets; they can rewrite every row and block queries.
On large tables, make schema changes in steps. Add the column as nullable first. Backfill the data in small batches. Then add constraints or indexes later. This reduces the impact on live traffic and avoids long locks.