Adding a new column is one of the most common changes in a database schema. It can be simple, or it can break production if done poorly. The right process keeps queries fast, migrations safe, and deployments smooth.
Start by deciding the column type. Use the smallest type that suits the data. Avoid unnecessary NULLs. Set defaults if they make sense.
In relational databases like PostgreSQL or MySQL, adding a new column can be done with:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP;
On large tables, this operation can lock writes. Plan for downtime or use tools that perform online migrations. Some platforms like PostgreSQL 11+ allow adding columns with defaults instantly for certain data types. Always test on staging with realistic data sizes.