Adding a new column to a database table is simple in syntax, but impact runs deeper. A new column changes schema, affects queries, and can alter application logic. Done carelessly, it slows performance or breaks code. Done well, it unlocks new capabilities without downtime.
In SQL, you create a new column with ALTER TABLE. For example:
ALTER TABLE users
ADD last_login TIMESTAMP;
This works, but the work doesn’t end here. You need to plan type, default values, nullability, indexing, and migration strategy. Each choice affects Writes, Reads, and storage.
If the table is large, avoid blocking writes. Use online migrations. In MySQL, tools like gh-ost or pt-online-schema-change keep services running. In PostgreSQL, adding certain columns can be fast, but adding non-null columns with defaults rewrites the table—plan around it.