Adding a new column should never be guesswork. It changes the shape of your data, the behavior of your queries, and the performance of your system. In relational databases like PostgreSQL, MySQL, and SQL Server, ALTER TABLE is the tool. This command modifies an existing table, inserting a new column definition without recreating the table from scratch.
ALTER TABLE users
ADD COLUMN last_login TIMESTAMP;
This statement adds a last_login column to the users table to store timestamps. The database updates its metadata. Rows already in the table get NULL in the new column unless you set a default value.
Performance depends on the database engine. Adding a nullable column is fast in PostgreSQL because it doesn’t rewrite the table’s data. Adding a column with a default in versions before 11 triggers a table rewrite, locking writes until completion. MySQL typically locks the table during the change unless you enable ALGORITHM=INPLACE or use an online schema change tool.
When working on production systems, a new column can break code if not deployed carefully. Code must handle NULL values until the column is backfilled. Backfills on large datasets should run in controlled batches to avoid locking and write spikes.