Adding a new column to a database is simple in theory. In practice, it demands precision. Whether you are extending a PostgreSQL schema, modifying MySQL tables, or altering a NoSQL document structure, one wrong step can lock rows, drop performance, or even break production.
Plan the change. First, identify the exact column name. Choose a type that matches both the data you will store and the queries you will run. Decide if the column should allow NULL values or require defaults. Think about indexes. Adding an index as part of a new column migration can improve lookups but may slow inserts.
For relational databases, ALTER TABLE is the standard command. In PostgreSQL:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP;
In MySQL: