Snewman888
Snewman888

Reputation: 81

Relation “users” does not exist. PostgreSQL

I have a users table, I see it in pgadmin4, but for some reason when I use psql and try to run list users, I get the following error:

Relation “users” does not exist.

Upvotes: 7

Views: 28379

Answers (5)

Ahmet Emrebas
Ahmet Emrebas

Reputation: 945

You need to put table name in quotes. And, it is case sensitive:

SELECT * FROM "Users";

Upvotes: 12

Ibraheem Adeyemo
Ibraheem Adeyemo

Reputation: 62

none of the solution mentioned here worked for me untill i wrote the query thus

SELECT * FROM public."Users";

This worked for me.

Upvotes: 1

Peter Kobzar
Peter Kobzar

Reputation: 39

I've add new Schema (and remove there my user table) in database so my request was

SELECT "role" FROM "user" ...

But now should be with schema name

SELECT "role" FROM "schemaName"."user" ...

Upvotes: 1

niomu
niomu

Reputation: 7

In case of automated test, setting a delay after migrations do the job:

setTimeout(() => {
   // queries
}, 1000);

Maybe it is the delay for the database to be done.
The automated test is multithread in my case.

Upvotes: -5

sizzlecookie
sizzlecookie

Reputation: 288

This will happen if the psql user does not have schema level privileges. This error message can be misleading.

To solve this issue, try connecting using psql with an admin user and run:

1.

GRANT USAGE ON SCHEMA public TO <non-admin-user>;  
GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA public TO <non-admin-user>;

Upvotes: 12

Related Questions