I keep getting the error "relation [TABLE] does not exist"

Berra2k picture Berra2k · Dec 30, 2017 · Viewed 13.4k times · Source

I have been trying to query two tables in my database. In the server explorer I can see both tables and even see the columns within them. We'll call them Schema.table1 and Schema.table2 where "Schema" has its first letter capitalized. I have tried running the following queries:

select * from Schema.table1;

Where I get the following error:

ERROR: relation "schema.table1" does not exist

I then tried running the next query thinking maybe the capitalization in the schema made a difference.

Select * from "Schema.table1"; 
select "ID" from "Schema.table1";

But the same error persisted:

ERROR: relation "Schema.table1" does not exist

I later tried to specify the schema path with "SET search_path to "Schema1" and ran a query on the tables which again provided me the same error. Any ideas or help would be greatly appreciated.

Answer

a_horse_with_no_name picture a_horse_with_no_name · Feb 21, 2018

Each element has to be quoted individually:

select "ID" 
from "Schema"."table1";

More details about quoted identifiers are in the manual