Adding a new column sounds simple. In practice, it can be a breaking change if done wrong. A new column changes your database structure, your application code, and sometimes the data itself. Whether you work with PostgreSQL, MySQL, or SQLite, the process must be precise.
First, define the column name, data type, and constraints. Choose defaults carefully to avoid NULL pitfalls or incompatible updates. In PostgreSQL, a statement like:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP WITH TIME ZONE DEFAULT NOW();
adds the new column instantly for future inserts, but backfilling historical data may still lock or slow queries. In MySQL, online DDL features reduce downtime, but you must test migration scripts under load. For large datasets, consider creating the column without defaults, then running batched updates to backfill.