script files

created onJanuary 8, 2022

running a script file from a shell with psql

Connect to database sampledb as user bob and run the script db-init.sql, located in the current directory. The parameter -a causes psql to print all nonempty 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