Adding a new column should not be guesswork. It should be precise, fast, and safe. Whether you’re working with Postgres, MySQL, or a distributed SQL database, the principle is the same: define the column, set its constraints, and ensure the schema update does not block production traffic.
Use ALTER TABLE for most cases:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP DEFAULT NOW();
This command adds the column, sets the default, and backfills instantly for new rows. But the cost depends on database size and engine behavior. Large tables may lock writes. In those cases, perform the migration in stages: add the column without a default, update rows in batches, then set the default and constraints.
Naming matters. A new column should have a clear, unambiguous name. Avoid abbreviations unless they are standard across your schema. Decide the data type with intent. You cannot afford a TEXT where an indexed VARCHAR(255) is needed, or a BIGINT where an INT fits.