Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

psql: no relations found despite existing relations

Version 8.4.16 (no choice in version).

I log into my db as follows:

psql -d JRuser

The resulting prompt is:

JRuser=>

I do \d or \dt expecting to see a list of all the relations in schema 'translate'

No relations found. 

But I can select from any of the tables in the schema without any issues. For example:

select * from translate.storage; --works fine

I have ensured that the access privileges are correct for JRuser by doing \dn+:

                                 List of schemas
        Name        |  Owner   |  Access privileges   |           Description  
translate           | JRuser   | JRuser=UC/JRuser     | 
                               : postgres=UC/JRuser     

Why can't I see the tables in the translate schema?

like image 225
lostinthebits Avatar asked Jul 10 '13 18:07

lostinthebits


People also ask

What is the PSQL command to show the schema of a relation?

To show the name of the current schema, use the following simple command. >> SELECT current_schema(); This shows that the current schema is “public”.

What is a relation in PSQL?

PostgreSQL is a relational database management system ( RDBMS ). That means it is a system for managing data stored in relations. Relation is essentially a mathematical term for table.


1 Answers

\d in psql only shows visible tables, i.e. in your search_path.

Try and see:

SHOW search_path;
SET search_path= translate;
\d

The setting for your session has probably been changed somehow. There are multiple ways to do that:

  • How does the search_path influence identifier resolution and the "current schema"

Related later question on dba.SE:

  • Why can't I see my table (PostgreSQL) when I use \dt(+) inside psql?
like image 142
Erwin Brandstetter Avatar answered Sep 29 '22 11:09

Erwin Brandstetter