【问题标题】:PostgreSQL - No relations found.PostgreSQL - 未找到任何关系。
【发布时间】:2015-07-25 14:09:44
【问题描述】:

我是开发人员世界的新手,所以如果我没有清楚地提出我的问题,我深表歉意,如果我做错了,请随时指出。谢谢。

我在设置我的 PostgreSQL 数据库时遇到了这个问题,no relations found 时键入命令 timlin=# \d

我确实尝试了以下解决方案来修复,但没有奏效。 postgresql database owner can't access database - "No relations found."

下面是我的情况

timlin=# \dn+

                      List of schemas
  Name  | Owner  | Access privileges |      Description       
--------+--------+-------------------+————————————
 public | timlin | timlin=UC/timlin +| standard public schema
        |        | =UC/timlin        | 
(1 row)

timlin=# \l
                                    List of databases
        Name         | Owner  | Encoding |   Collate   |    Ctype    | Access privileges  
---------------------+--------+----------+-------------+-------------+--------------------
 postgres            | timlin | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 psqlapp             | timlin | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 psqlapp_development | timlin | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 psqlapp_test        | timlin | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 psqlappdemo         | timlin | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =Tc/timlin        +
                     |        |          |             |             | timlin=CTc/timlin +
                     |        |          |             |             | psqlapp=CTc/timlin
 template0           | timlin | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/timlin         +
                     |        |          |             |             | timlin=CTc/timlin
 template1           | timlin | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/timlin         +
                     |        |          |             |             | timlin=CTc/timlin
 timlin              | timlin | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
(8 rows)

timlin=# \du
                             List of roles
 Role name |                   Attributes                   | Member of 
-----------+------------------------------------------------+-----------
 psqlapp   |                                                | {}
 timlin    | Superuser, Create role, Create DB, Replication | {}

我检查了每一个,都没有发现以前的灵魂有任何区别。 当我尝试时

timlin=# \d

我仍然得到了结果: 未找到任何关系。

我错过了什么?我该如何解决? 请建议并提前谢谢大家。

【问题讨论】:

    标签: postgresql


    【解决方案1】:

    这意味着数据库 timlin 不包含 public 架构中的任何表(\d 通常会列出)。

    听起来你创建了一个空数据库,例如:

    createdb -h localhost -U postgres timlin
    

    在这种情况下,\d 会在创建后立即返回:

    未找到任何关系。

    您需要显式创建一个或多个表才能查看\d 的输出中列出的任何内容。

    例如如果您执行以下操作:

    create table foo (id serial, val text);
    

    然后做一个\d,会得到如下输出:

                 List of relations
     Schema |    Name    |   Type   |  Owner   
    --------+------------+----------+----------
     public | foo        | table    | postgres
     public | foo_id_seq | sequence | postgres
    (2 rows)
    

    【讨论】:

    • 嗨@khampsom,感谢您的回答,您是正确的。它在我创建表格后工作。谢谢!
    猜你喜欢
    • 1970-01-01
    • 2021-07-19
    • 2017-04-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-05
    • 1970-01-01
    相关资源
    最近更新 更多