Adding a new column is not just a matter of syntax. The way you apply it affects performance, availability, and rollback strategy. In production systems with constant writes, an ALTER TABLE command can lock rows and block queries. That can cascade into downtime. For high-traffic databases, even small schema changes demand planning.
First, name the new column with clarity. Avoid reserved words, ambiguous terms, or future-breaking conventions. Next, define the data type and constraints that match the intended use case. Indexing a new column can speed up reads, but adds cost to inserts and updates. Default values can simplify migration scripts, but physical storage and update logic must be accounted for.
When possible, add the new column without locking the table. Many database engines support online schema changes. In MySQL, tools like pt-online-schema-change or gh-ost allow non-blocking updates. In PostgreSQL, adding a nullable column without a default is fast, but backfilling millions of values can create long transactions and replication lag. Split the process into two steps: