Adding a new column in a production database is simple in theory and dangerous in practice. It changes the shape of your data model. It affects queries, indexes, and the code that depends on them. The wrong migration can lock a table, slow a service, or break an API.
Start with intent. Know exactly why the column exists and how it will be used. Define its type: integer, text, boolean, JSON. Set the right default value or make it nullable. Consider whether it needs indexing at creation—adding an index later may require a lock that impacts uptime.
In SQL, the basic command is clear:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP;
In a large table, this command can trigger costly rewrites. For zero-downtime changes, use tools like gh-ost or pt-online-schema-change for MySQL, or ADD COLUMN with NULL defaults in PostgreSQL to avoid table rewrites. If you must backfill data, do it in batches to protect query performance.