6

I have a heroku postgres add-on database with a user table. However, when I attempt to select * from user, all I get is:

  current_user  
----------------
 rtsjlhdfptlaqd
(1 row)

The table name is definitely user. There is no users table. There are definitely a bunch of users in my app, but I can't seem to list them.

Thoughts?

5

Ok this is kind of a stupid question, but I'll leave it in case someone else makes a similarly dumb mistake.

For the record, I'm not the one who created a set of models including user instead of users.

Postgres has its own table user which it holds postgres users in. When you select * from user what you're getting is the result of the postgres user table. What you have to do instead is select * from "user" where user is in double quotes.

  • This is not really correct, see the output of \dt *."user". Regardless, I'd suggest removing this question in favour of the SO one (with an excellent answer). – dezso May 8 '15 at 10:03
1

Try:

select * from <schema-name>."user";

For example:

select * from public."user";

Note (my Postgres version):

# select version();
                                                         version                                                              
----------------------------------------------------------------------------------------------------------------------------------
PostgreSQL 10.5 (Debian 10.5-1.pgdg90+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 6.3.0-18+deb9u1) 6.3.0 20170516, 64-bit

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.