0

I’m totally new to developer world, so I apologize if I’m not make my question clearly, please don’t be hesitate to point out if I did any wrong. Thanks.

I faced this problem on setting my PostgreSQL DB, no relations found when type command timlin=# \d.

I did try below solution to fix but it didn’t work. postgresql database owner can't access database - "No relations found."

Below is my situation

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 | {}

I check each one and couldn't find any difference between previous soultion. While I try

timlin=# \d

I still got the result : No relations found.

What do I missed ? How can I fix it ? Please advice and thank you all in advence.

Community
  • 1
  • 1
Tim Lin
  • 3
  • 1
  • 1
  • 2

1 Answers1

3

This would imply that the database timlin does not contain any tables in the public schema (which is what \d would normally list).

It sounds like you created an empty database, e.g.:

createdb -h localhost -U postgres timlin

In which case, immediately after creation, \d would return:

No relations found.

You would need to explicitly create one or more tables in order to see anything listed in the output of \d.

e.g. if you do the following:

create table foo (id serial, val text);

And then do a \d, the following output will result:

             List of relations
 Schema |    Name    |   Type   |  Owner   
--------+------------+----------+----------
 public | foo        | table    | postgres
 public | foo_id_seq | sequence | postgres
(2 rows)
khampson
  • 14,700
  • 4
  • 41
  • 43
  • Hi @khampsom, thanks for your answer, your are correct. It works after I creat a table. Thank you ! – Tim Lin May 14 '15 at 09:17