psql -d appdb -c "ALTER TABLE users ADD COLUMN age int;"

Category: Databases & SQL

psql -d appdb -c "ALTER TABLE users ADD COLUMN age int;"

Add a column to a table

Adds an age column; existing rows get NULL. In modern PostgreSQL, adding a column with a constant default is nearly instant because no rewrite happens. Dropping it later is also cheap.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.