A new column changes the shape of your data. It allows you to track new attributes, enable new features, and power new queries. In SQL, adding one is simple in syntax but critical in effect. The operation can alter storage, indexing, application logic, and even downtime risk. Treat it as more than a routine change.
In PostgreSQL, the ALTER TABLE command is the standard way forward:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP;
This statement defines the column name, type, and position in one shot. The database updates its catalog and, depending on the default value, may rewrite existing rows. On large tables, this can be costly. Minimal changes, such as adding a nullable column without defaults, are almost instant. Defaults require backfilling, which may lock writes or slow reads.
In MySQL, the equivalent looks like:
ALTER TABLE users ADD COLUMN last_login DATETIME;
Engine and version affect performance. Modern MySQL supports instant add column for certain storage engines, but not in all cases. Always verify documentation.