postgresql: run SQL commands using psql in commandline

后端 未结 2 962
-上瘾入骨i
-上瘾入骨i 2021-01-16 02:33

I have the below three lines to be run in commandline using psql how can i do it.

CREATE DATABASE myproject;
CREATE USER myprojectuser WITH PASSWORD \'passwo         


        
2条回答
  •  情话喂你
    2021-01-16 02:51

    As per the docs psql -c 'command;'

    psql -c 'CREATE DATABASE myproject;' -c "CREATE USER myprojectuser WITH PASSWORD 'password';" -c 'GRANT ALL PRIVILEGES ON DATABASE myproject TO myprojectuser;'
    

提交回复
热议问题