Discussion:
relation does not exist error
Simon Wittber
2004-12-03 03:01:16 UTC
Permalink
I'm evaluationg PostgreSQL 8.0 beta 5 for a new development project.

I've created a user 'simon' and a database named 'WMSDV'.

I've created some tables (see below) and assigned arwdRxt privledges
to the 'simon' user.

However, when i use psql, I am unable to select these tables. I
receive a 'relation "'tabename' does not exist" error. I'm completely
new to PostgreSQL, and this problem has me stumped.

Can anyone point me in the right direction?

Sw.

WMSDV=# \dt
List of relations
Schema | Name | Type | Owner
--------+-----------+-------+-------
public | Customers | table | simon
public | Persons | table | simon
(2 rows)

WMSDV=# select * from Customers;
ERROR: relation "customers" does not exist
WMSDV=# select * from public.Customers;
ERROR: relation "public.customers" does not exist
WMSDV=#

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend
Michael Fuhr
2004-12-03 03:18:54 UTC
Permalink
Post by Simon Wittber
List of relations
Schema | Name | Type | Owner
--------+-----------+-------+-------
public | Customers | table | simon
public | Persons | table | simon
(2 rows)
WMSDV=# select * from Customers;
ERROR: relation "customers" does not exist
See the "Identifiers and Key Words" section in the "SQL Syntax" of
the PostgreSQL documentation. Pay particular attention to what it
says about case sensitivity, case folding, and quoting of identifiers.
--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ***@postgresql.org)
Doug McNaught
2004-12-03 03:22:11 UTC
Permalink
Post by Simon Wittber
WMSDV=# \dt
List of relations
Schema | Name | Type | Owner
--------+-----------+-------+-------
public | Customers | table | simon
public | Persons | table | simon
(2 rows)
WMSDV=# select * from Customers;
ERROR: relation "customers" does not exist
Identifiers get mashed to lower case unless you quote them:

SELECT * FROM "Customers";

-Doug

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings
Simon Wittber
2004-12-03 03:34:03 UTC
Permalink
Wow, 4 responses in 10 minutes to my newbie question. Thanks guys.

I'm coming from a SQL Server background, so quoting table names didn't
immediately spring to mind.

I can see support will not be a problem. 10 out of 10.

Sw.

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ***@postgresql.org)
Ian Harding
2004-12-03 14:34:06 UTC
Permalink
The answer is in the question! It's the difference between Customers
and customers.

PostgreSQL folds identifiers to lower case if not double quoted.

The best solution is to use lower case consistently. The alternative is
to use double quotes consistently.

Try SELECT * FROM "Customers"; and you will be happy again.

Ian Harding
Programmer/Analyst II
Tacoma-Pierce County Health Department
***@tpchd.org
Phone: (253) 798-3549
Pager: (253) 754-0002
I'm evaluationg PostgreSQL 8.0 beta 5 for a new development project.

I've created a user 'simon' and a database named 'WMSDV'.

I've created some tables (see below) and assigned arwdRxt privledges
to the 'simon' user.

However, when i use psql, I am unable to select these tables. I
receive a 'relation "'tabename' does not exist" error. I'm completely
new to PostgreSQL, and this problem has me stumped.

Can anyone point me in the right direction?

Sw.

WMSDV=# \dt
List of relations
Schema | Name | Type | Owner
--------+-----------+-------+-------
public | Customers | table | simon
public | Persons | table | simon
(2 rows)

WMSDV=# select * from Customers;
ERROR: relation "customers" does not exist
WMSDV=# select * from public.Customers;
ERROR: relation "public.customers" does not exist
WMSDV=#

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend


---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Loading...