'Can't see tables in PostgreSQL
I've created a schema in my PostgreSQL database that Hibernate uses, creating tables, persisting entities and so on. After I updated my Ubuntu 14.04 to 16.04, I can't see the tables anymore. The applications that manipulate data in the schema and its tables can still do it, though.
Here is the output of some commands after I login using 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)
I've tried the following, from a few questions I aswers I found:
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA jcat TO public;
grant ALL on SCHEMA jcat to public;
but I still can't see my tables. Any hints?
Edit: here are the information requested.
postgres-# \d jcat.*
Did not find any relation named "jcat.*".
postgres-# show search_path
postgres-#
Solution 1:[1]
I suspect you are manually connecting to a different database than your ORM or code is connecting to (or at least I was running into the same problem as you and it turns out that's what I was doing).
It can help clear up a lot of confusion if you use a good GUI tool to look around in your database to help you figure out where your tables are actually ending up. PGAdmin4 was my tool of choice, might be worth a shot: https://www.pgadmin.org/download/pgadmin-4-windows/
You can also try setting your search path from the command line when connecting via psql. On Ubuntu that looks like this:
PGOPTIONS='-c search_path=jcat' psql -h your.host -U youruser
Solution 2:[2]
I had a similar problem. I was running Postgresql 12 in a docker container and using volume with data. When accessing the database to show a list of tables, an error occurred:
"ERROR: column c.relhasoids does not exist at character 190".
Data for DB was from Postgresql 11. When I rebuilt the dockerfile with image Postgresql 11 everything was OK
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | A. Hodasevich |