Take the 2-minute tour ×

Is it possible? Can i specify it on the connection URL? How to do that?

share|improve this question

5 Answers 5

up vote 25 down vote accepted

I don't believe there is a way to specify the schema in the connection string. It appears you have to execute

set search_path to 'schema'

after the connection is made to specify the schema.

share|improve this answer
This worked for me, specifically using the "Connection" instance to run: Statement statement = connection.createStatement(); try { statement.execute("set search_path to '" + schema + "'"); } finally { statement.close(); } –  romeara Sep 30 at 18:42

If it is possible in your environment, you could also set the user's default schema to your desired schema:

ALTER USER user_name SET search_path to 'schema'
share|improve this answer
Probably better to ALTER the database itself so that the same user can connect to different databases with different search_paths if need be: ALTER DATABASE dbname SET search_path TO public,schemaname; –  Wokka Sep 5 at 19:21
thanks, you save my life. –  duccom Oct 2 at 15:33

I know this was answered already, but I just ran into the same issue trying to specify the schema to use for the liquibase command line.

According to this: http://postgresql.1045698.n5.nabble.com/Patch-to-allow-setting-schema-search-path-in-the-connectionURL-td2174512.html

You can specify the url like so:

share|improve this answer
Yes but at the moment of the writing (late 2012) it's not a part of the 9.1 driver, see: Connection Parameters. –  user272735 Sep 14 '12 at 6:51
Did you try it? Because it wasn't listed as part of the previous driver but it still worked. –  Hiro2k Sep 27 '12 at 13:18
Tried with 9.3-1101-jdbc41 and 9.1, doesn't work for me –  Ignacio A. Poletti Jun 3 at 14:30

I submitted an updated version of a patch to the PostgreSQL JDBC driver to enable this a few years back. You'll have to build the PostreSQL JDBC driver from source (after adding in the patch) to use it:



share|improve this answer

Don't forget SET SCHEMA 'myschema'


share|improve this answer

Your Answer


