How can I access the content of the tables on a schema in SQL?

Viewed 85

I have a python connection to a Red Shift database that it's organized with schemas. I am able to access all the schemas names and table names but I'm unable to load any specific table within any schema. It seems like I can connect to the database but I can't browse further. Any ideas?

When I write a query without specifying the schema name it gives me the following error:

UndefinedTable: relation "table_name" does not exist

I'm using psycopg2 for building the connection.

Thanks in advance

1 Answers

You need to specify search_path to a schemas if you want to not use schema name in a query

let say I have schema1 with table table1 in there, and my default search path is $user, public. If I want to query table1 I have to use it in query

select * from schema1.table1;

but if I set schema1 in my search_path

set search_path to schema1;

then I can query in this way

select * from table1;
Related