我已经启动了一个 postgres 容器。它通过放置在 docker-entrypoint 文件夹中的 .sql 文件创建模式和表。我的架构在\dn+ 中列出。但是\dt 没有给出任何关系。访问权限保持不变。
做\dn+ 给出:
List of schemas:
Name | Owner | Access privileges | Description
--------+----------+----------------------+------------------------
MYAPP | postgres | |
public | postgres | postgres=UC/postgres+| standard public schema
| | =UC/postgres |
做\dt 给出: (在公共(public)架构内) Did not find any relations.
但是,我的 .sql 文件可以在同一 DB 内的公共(public)架构内创建表。并且\dt 正确显示表格列表。为什么我无法在 non-public schema 中创建表。任何特权限制?
sql内容如下:
CREATE SCHEMA "MYAPP";
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA MYAPP TO postgres;
CREATE TABLE "MYAPP"."ACCESS_MASTER" ("ACCESS_ID" character varying COLLATE pg_catalog."default" NOT NULL,"ROLE_ID" character varying COLLATE pg_catalog."default");
这里有什么问题?请指导。编辑 :
IMCDB=#\dn
List of schemas
Name | Owner
--------+----------
MYAPP | postgres
public | postgres
(2 rows)
MYAPP=# \dt
Did not find any relations.
IMCDB=# set search_path="MYAPP";
SET
MYAPP=# \dt
Did not find any relations.
MYAPP=# show search_path;
search_path
-------------
"MYAPP"
(1 row)
MYAPP=# \dt
Did not find any relations.
MYAPP=#
设置我的模式的路径也没有帮助。
最佳答案
\dt 将仅列出您的默认架构中存在的关系,在您的情况下该架构是公开的。
您需要将 search_path 设置为 MYAPP,之后,它将列出模式 MYAPP 中存在的所有关系。
postgres=# show search_path;
LOG: statement: show search_path;
search_path
-----------------
"$user", public
(1 row)
postgres=# set search_path="MYAPP";
SET
postgres=# show search_path;
search_path
-------------
"MYAPP"
(1 row)
披露:我为 EnterpriseDB (EDB) 工作
关于postgresql - 无法查看创建的架构中的任何关系,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63296082/