Adding a new column is simple in concept, but the real work is in doing it without breaking production, corrupting data, or slowing queries. Schema changes are one of the most common sources of downtime. They also impact performance if not planned carefully.
In SQL, a new column alters the table structure. The process differs between MySQL, PostgreSQL, and other relational databases, but the fundamentals remain the same: define the column, set its type, and decide if it allows NULL values or has a default.
Example in PostgreSQL:
ALTER TABLE users
ADD COLUMN last_login TIMESTAMP DEFAULT NOW();
For large tables, this operation can lock writes. Use tools like pg_repack or online schema change utilities in MySQL (pt-online-schema-change) to avoid blocking. If the new column needs to be populated with computed data, write backfill scripts in small batches to reduce load.