Adding a new column is one of the most common schema changes, yet it’s also a point where performance, reliability, and data integrity can be won or lost. Whether you are working in PostgreSQL, MySQL, or a distributed SQL database, the steps are straightforward but the details matter.
Define the column type first. Choose a type that matches the data you will store, not just what seems convenient. Mismatched types lead to slow queries and unexpected bugs. Enforce constraints early. If a column must never be NULL, declare it that way when you create it. Changing constraints later is riskier and often more expensive.
Consider the default value. Adding a default for existing rows can trigger a full table rewrite in some engines, locking or slowing writes. Large production tables can be impacted for minutes or hours. Schedule migrations during low traffic or use non-blocking migration tools.
For PostgreSQL:
ALTER TABLE users ADD COLUMN signup_source text;
For MySQL: