The table was too rigid. You needed more space. You needed a new column.
Adding a new column changes the shape of your data. It shifts how queries perform and how code interacts with the database. Whether you work in PostgreSQL, MySQL, or SQLite, the pattern is the same: you define the name, type, and constraints, then alter the table.
In PostgreSQL:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP;
In MySQL:
ALTER TABLE users ADD COLUMN last_login DATETIME AFTER email;
For SQLite:
ALTER TABLE users ADD COLUMN last_login TEXT;
Choose the column type that matches the data you expect. Apply NOT NULL when the field must always have a value. Set DEFAULT to avoid problems in existing rows.
When adding a new column to large tables, watch for locks. In PostgreSQL, ALTER TABLE ... ADD COLUMN is fast if you use a default of NULL. Setting a constant default on large datasets will rewrite the table, which can block queries. MySQL’s behavior depends on engine and version. SQLite will always rewrite the table behind the scenes.
After creating the column, update indexes to support new query patterns. Adjust your ORM models. Test queries that use the column to ensure the execution plan still works as expected.
A new column is more than a schema change. It’s a contract update between the database and the code that consumes it. Plan, implement, migrate, then verify.
See how this runs instantly in a live database. Build and test a new column in minutes with hoop.dev.