Adding a new column in a database sounds simple. It isn’t. Every change to a schema can ripple across queries, indexes, and integrations. The key is precision. Decide why you need the column, define the data type, set nullability, and update default values where required. Without this intent, you risk migrations that lock up production or corrupt data.
For relational databases, ALTER TABLE is the standard command. In PostgreSQL:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP;
This runs fast on small datasets. On large tables, adding a new column with a default non-null value can rewrite the table and block writes. Use NULL defaults first, migrate data in batches, and backfill under controlled load. For MySQL, avoid locking with ALGORITHM=INPLACE when possible. For cloud-hosted systems, review provider-specific tools like pg_repack or online schema migrations with gh-ost and pt-online-schema-change.