postgresql - 无法查看创建的架构中的任何关系

标签 postgresql docker

我已经启动了一个 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/

相关文章:

postgresql - PSQL 正在推断模式,但如何推断?

java - Kafka Streams 应用程序在 docker 容器中的奇怪行为

amazon-web-services - Docker ImagePush 失败,出现 "no basic auth credentials"

postgresql - 使用Docker容器和主机LAN的Postgres网络

node.js - Nodejs,将 bin 文件作为 BYTEA 存储到 pgsql 中(损坏的文件)

ruby-on-rails - 使用 pgAdmin 连接到 Rails 应用程序 Postgres DB

postgresql - Postgres 9.1 的 Docker 容器未将端口 5432 暴露给主机

python - psycopg2.errors.SyntaxError : syntax error at or near "<"

azure - 如何在多容器 Web 应用程序上挂载 Azure 文件?

docker ps 显示空列表