无法在PostgreSQL中查看表格

9

我在我的PostgreSQL数据库中创建了一个Hibernate使用的模式,创建表,持久化实体等。之后我将Ubuntu 14.04更新到16.04后,再也看不到这些表了。但操作数据及其表格的应用程序仍然可以执行。

在使用sudo -u postgres psql登录后,以下是一些命令的输出:

postgres=# \dt
No relations found.
postgres=# \dn
  List of schemas
  Name  |  Owner   
--------+----------
 jcat   | postgres
 public | postgres
(2 rows)

postgres=# \dn+
                          List of schemas
  Name  |  Owner   |  Access privileges   |      Description       
--------+----------+----------------------+------------------------
 jcat   | postgres | postgres=UC/postgres+| 
        |          | =UC/postgres         | 
 public | postgres | postgres=UC/postgres+| standard public schema
        |          | =UC/postgres         | 
(2 rows)

我尝试了以下几种方法,参考了我找到的一些答案:
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA jcat TO public;
grant ALL on SCHEMA jcat to public;

但我仍然看不到我的表格。有什么提示吗?
编辑:这里是所需的信息。
postgres-# \d jcat.*
Did not find any relation named "jcat.*".
postgres-# show search_path
postgres-#

2
show search_path 会给你什么信息?\d jcat.* 会给你什么信息? - user330315
我刚刚把它添加到问题中。 - Douglas De Rizzo Meneghetti
2
你需要用 ; 结束 SQL 语句。你的 show search_path 实际上没有运行。但是如果 \d jcat.* 的结果是 "did not find any relation",这意味着该模式中没有表。如果你运行 select table_name from information_schema.tables where table_schema = 'jcat';,你会得到什么? - user330315
1
show search_path; 显示 1 行:"$user", public。您刚刚请求的 select 语句返回 0 行。 - Douglas De Rizzo Meneghetti
让我们在聊天中继续这个讨论 - Douglas De Rizzo Meneghetti
显示剩余2条评论
2个回答

1
我怀疑你手动连接的数据库与ORM或代码连接的数据库不同(或者至少我遇到了与你相同的问题,结果发现我正在做的就是这个)。使用良好的GUI工具来查看数据库,帮助你确定表格实际上在哪里,可以帮助消除很多混乱。PGAdmin4是我选择的工具,值得一试:https://www.pgadmin.org/download/pgadmin-4-windows/。您还可以尝试通过psql命令行设置搜索路径。在Ubuntu上,它看起来像这样:
PGOPTIONS='-c search_path=jcat' psql -h your.host -U youruser

1

我有一个类似的问题。我在docker容器中运行了Postgresql 12,并使用卷管理数据。当访问数据库以显示表格列表时,出现了错误:

"ERROR: column c.relhasoids does not exist at character 190".

数据库的数据来自于Postgresql 11。 当我使用镜像 Postgresql 11 重新构建dockerfile时,一切都正常。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接