Postgresql 博士后:在一行中创建角色

Postgresql 博士后:在一行中创建角色,postgresql,command-line,Postgresql,Command Line,我想在一行中创建一个角色/用户。以下是我尝试过的: psql -U postgres -c 'createuser my_app with createdb login password 'my_password';' psql: warning: extra command-line argument "with" ignored psql: warning: extra command-line argument "createdb" ignored psql: warning: extra

我想在一行中创建一个角色/用户。以下是我尝试过的:

psql -U postgres -c 'createuser my_app with createdb login password 'my_password';'
psql: warning: extra command-line argument "with" ignored
psql: warning: extra command-line argument "createdb" ignored
psql: warning: extra command-line argument "login" ignored
psql: warning: extra command-line argument "password" ignored
psql: warning: extra command-line argument "'my_password';'" ignored
psql: FATAL:  database "my_app" does not exist
我也尝试过创建用户和创建角色来代替createuser,但不管怎样,我都会得到相同的错误。我在Windows上使用PostgreSQL 9.6.2

我做错了什么

更新:

我尝试使用双引号,但出于某种原因,postgres似乎不喜欢我的双引号。在单引号中使用双引号可以神秘地工作->谢谢@Laurenz

psql -U postgres -c "createuser my_app with createdb login password 'my_password';"
ERROR:  syntax error at or near "createuser"
LINE 1: createuser my_app with createdb login password 'my_password'...
createuser不是SQL命令,因此无法使用

CREATE USER是正确的,但不能像这样在单引号中嵌套单引号

应该是

psql -U postgres -c "CREATE USER my_app CREATEDB PASSWORD 'my_password'"
createuser不是SQL命令,因此无法使用

CREATE USER是正确的,但不能像这样在单引号中嵌套单引号

应该是

psql -U postgres -c "CREATE USER my_app CREATEDB PASSWORD 'my_password'"