Search code examples
oracle-databasescalajdbcsqueryl

Change Oracle CURRENT_SCHEMA via Squeryl


I have a Squeryl connection to an Oracle database.

How do I change the CURRENT_SCHEMA setting upon connecting?

In raw sql this would be done with

ALTER SESSION SET CURRENT_SCHEMA=<schema name>

How do I do this via Squeryl?


Solution

  • There are two ways:

    1. org.squeryl.Schema has a method called name. If you override it and provide a name, each statement will use that name to reference the schema.

    2. If you want to alter the implicit schema that a statement is executed against, then you'll want to execute what you posted above as JDBC. You should be able to find information on how to access the JDBC Connection associated with a Squeryl Session fairly easily.