psql -f schema.sql

Category: Databases & SQL

psql -f schema.sql

Execute SQL statements from a file

Reads schema.sql and runs every statement in order. Without -v ON_ERROR_STOP=1 psql keeps going after an error, which can leave a migration half-applied. The same file can be piped in with psql < schema.sql. Related: psql -c for one statement.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.