Run a SQL file using the command line in PostgreSQL
Run the SQL file with the PSQL utility which connects with the PostgreSQL database
psql -h localhost -d Store -U admin -p 5432 -a -q -f C:\script\postgrefile.sql
-h PostgreSQL server IP address
-d database name
-U user name
-p port
-f path to SQL script
-a all echo
-q quiet
Direct connect with PostgreSQL command utility:
psql -h 127.0.0.1 -d test -u admin
password ******
postgres> \i C:\script\postgresfile.sql