sql - Postgres CLI 查询未执行

标签 sql linux postgresql terminal

我已经在本教程的帮助下在我的 ubuntu 操作系统上安装了 postgresql Tutorial .

我按照前几个步骤进行操作,直到我需要创建 ROLES,但我的查询没有执行,甚至没有任何选择查询,它只是简单地移动到下一行而没有任何错误。

在尝试创建新角色时,这似乎对我有用

createuser test_user

但在创建用户后它不会提示我这些选项

Shall the new role be a superuser? (y/n) n
Shall the new role be allowed to create databases? (y/n) n
Shall the new role be allowed to create more new roles? (y/n) n

我无法更改这些用户的权限,因为我的查询没有得到执行,我也没有收到任何错误。

最佳答案

but it doesn't prompt me with these options after the user has been created

这对于最近的 PostgreSQL 客户端来说是正常的。添加 --interactive 选项以提示您使用教程使用的旧版本等选项。

来自手册页:

  --interactive
       Prompt for the user name if none is specified on the command line, and also prompt for
       whichever of the options -d/-D, -r/-R, -s/-S is not specified on the command line. (This
       was the default behavior up to PostgreSQL 9.1.)

关于不执行的查询:

my queries doesn't execute, not even any of the select queries, it simply just move to the next line without any errors

您可能忘记用分号结束查询。或者,查询有一个不平衡的单引号或双引号,解释器等待您关闭引用的部分。 如果您需要更多帮助,请使用您在 psql 上显示的内容的精确复制粘贴来编辑您的问题。 psql 中的提示揭示了它所处的状态以及它正在等待什么。

关于sql - Postgres CLI 查询未执行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25872648/

相关文章:

sql - IN 谓词在 SQL 中如何工作?

c - 查找 C 代码中的错误

linux - 我想通过命令行向 python 传递一个参数

python - 如何使用 Pandas 数据框更新 Postgres 表列?

python - Psycopg2 不提交更改

java - Hibernate查询、QueryException异常

Java - sql查询的正则表达式

python - Linux Apache Django 视频静态文件问题

sql - 是自己做唯一约束还是作为主键?

mysql - mysql中的负限制偏移量