Contents /
Previous /
Next
Script Files
psql with the option "-f file" test will read commands from file, rather
than from the keyboard.
This is in many ways equivalent to the internal command \i
to read an external script file.
Example script "workshop.sql":
SELECT * FROM stud ;
INSERT INTO stud(id, name) VALUES( 20, 'outsider');
SELECT * FROM stud ;
DELETE FROM stud WHERE id=20 ;
SELECT * FROM stud ;
The script can be started from within psql:
\i '/home/fred//sql/workshop.sql'
or together with psql:
psql -f workshop.sql workshop