Adding a new column to a database should be simple. In practice, it can strain uptime, performance, and deployment pipelines if done without care. A poorly executed schema change can lock tables, block queries, and cost real money. The right process makes it fast, safe, and repeatable.
A new column can serve many purposes: storing computed values, holding foreign keys, tracking state, or enabling new product features. Before adding one, decide its exact type, default value, nullability, and indexing strategy. Choosing incorrectly creates debt that is harder to fix later.
In SQL, the core command is straightforward:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP DEFAULT NOW();
This command works for most relational systems: PostgreSQL, MySQL, MariaDB, and others. But the cost is in the details. On large datasets, ALTER TABLE can lock the table for the entire operation. Migration tools like Liquibase, Flyway, and gh-ost exist to run such schema changes online, with minimal blocking.