Adding a new column is simple to describe but easy to get wrong. The goal is to evolve a database without breaking queries, indexes, or production code. Whether you work with PostgreSQL, MySQL, or SQLite, the path is the same: define precisely what the new column must store, how it will be indexed, and what defaults or constraints will keep integrity intact.
Start with the ALTER TABLE statement. In PostgreSQL:
ALTER TABLE users ADD COLUMN last_login TIMESTAMPTZ DEFAULT NOW();
This operation adds the column instantly for small tables, but can lock writes for larger ones. Plan migrations during low-traffic windows or use tools that manage concurrent schema changes. MySQL supports ALTER TABLE … ADD COLUMN but may rebuild the whole table depending on engine settings, so verify performance impact. In SQLite, the ADD COLUMN syntax cannot add constraints beyond NULL or DEFAULT, requiring extra steps for stricter rules.