How to execute multiple queries using psql command from bash shell?

后端 未结 4 736
天涯浪人
天涯浪人 2021-01-03 17:35

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

4条回答
  •  心在旅途
    2021-01-03 18:30

    The --file parameter executes a file's content

    psql -U postgres -h  -f "my_file.psql"
    

    All the output will be sent to standard output

    http://www.postgresql.org/docs/current/static/app-psql.html

提交回复
热议问题