Most of the time people struggle with running the postgres sql file with psql from the command prompt
– Postgres need to be install on your windows 10 machine
– psql.exe path must be included in Environment variable path
Create an sql file with the command “SELECT Now()” and save with name test.sql .
To run this file open command prompt and navigate to the file path.
run command > psql -U postgres -d postgres -a -f ./test.sql
result: time printed
here -U parameter is for username which postgres and -d is database which is again postgres
Run this file from the another sql file. To do this create a sql file in same directory and type the command “\i ./test.sql” and save with name test2.sql.
Now to run test2.sql
run command > psql -U postgres -d postgres -a -f ./test2.sql
result time printed
Now to run the file with host name
>psql -h <HostName> -p 5432 -U postgres -d <DatabaseName> -a -f ./test2.sql
for more information refer to this link
Please leave your comments…