Adding a new column is simple in theory. In production, it can be risky. A poorly executed schema change can lock tables, slow queries, or cause downtime. To do it right, you start with clarity. Decide exactly what this column will store, set the correct data type, and define constraints early.
In SQL, you add a new column with ALTER TABLE. The syntax is direct:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP;
This works, but in systems with high traffic, even small changes deserve caution. For large tables, run migrations in steps. First add the new column as nullable. Avoid default values on massive writes. Then backfill data in controlled batches. Finally, apply NOT NULL or indexes after the backfill completes.
In distributed databases, the process changes. PostgreSQL, MySQL, and modern cloud services like Amazon Aurora or Google Cloud Spanner have different locking behaviors. Study the documentation and test in staging with realistic data sizes. Measure query plans before and after the change to detect subtle performance impacts.