I need to execute postgresql queries from command line using psql -c command. For every psql command, it opens a new tcp connection to connect to the database server and exe
-c processes only one command. Without it however psql expects commands to be passed into standard input, e.g.:
-c
psql
psql -U postgres -h << EOF SELECT * FROM xyz_table; SELECT * FROM abc_table; EOF
Or by using echo and pipes.
echo