script files

created onJanuary 8, 2022

running a script file from a shell with psql

Connect to database as user and run the script db-init.sql, located in the current directory. The parameter causes psql to print all non-empty lines of the script file while they are executed.

psql -U bob -d sampledb -a -f db-init.sql

running a script file in the psql shell

sampledb=> \i ./db-init.sql
x