How do I access a table foo in schema bar in database moo through JDBC?

Option 1:

select * from moo.bar.foo;

Just bar.foo does not work. The nomenclature is <database name>.<schema name>.<table name>.

Option2:

Update the search path. PostgreSQL has the concept of search paths in which it tries to find the schemas. For more information check this out.

set search_path to ‘bar’

select * from foo

Put the schema name within single quotes otherwise, you piss the compiler off.

Advertisements