Postgres 用户无法从公共表中进行选择

Iva*_* S. 3 postgresql schema rights public

您好,我的 postgresql db \dt 输出中有一个用户:

 test=> \dt
                  List of relations
 Schema |           Name           | Type  |  Owner
--------+--------------------------+-------+----------
 public | code                     | table | postgres
 public | code_to_indicator        | table | postgres
 public | indicator                | table | postgres
Run Code Online (Sandbox Code Playgroud)

正如您所看到的,表的所有者是 postgres 但如果为 postgres 用户运行 \dt 命令,它会显示:

postgres=# \dt
Did not find any relations.
Run Code Online (Sandbox Code Playgroud)

这怎么可能?另外,如果我尝试通过 postgres 用户进行选择,它也会失败:

postgres=# select * from indicator;
ERROR:  relation "indicator" does not exist
LINE 1: select * from indicator;
Run Code Online (Sandbox Code Playgroud)

有人可以帮忙吗?直到今天一切都很好,出了点问题我什至不知道是什么。PostgreSQL 版本:11.4

Nic*_*nes 6

提示符开头postgres=#psql表示您已连接到postgres数据库,该数据库是作为管理连接的占位符创建的,并且通常其中没有任何内容。如果在命令行中没有指定数据库,psql则会查找与用户同名的数据库,因此用户postgres默认会连接到该数据库。

要连接到test数据库,您可以在提示\c test中键入psql,或使用 启动它psql -d test