Oracle Database - CURRENT_SCHEMA

> Database > Oracle Database

1 - About

When a session starts, CURRENT_SCHEMA has the value of the schema owned by SESSION_USER.

Advertising

3 - How to

3.1 - Get the current value

To get the current value of CURRENT_SCHEMA, CURRENT_USER, or SESSION_USER, use the userenv context:

SELECT sys_context('USERENV', 'CURRENT_SCHEMA') FROM dual;

3.2 - Modify it

CURRENT_SCHEMA can be changed during the session with the SQL statement ALTER SESSION SET CURRENT_SCHEMA.

ALTER SESSION SET CURRENT_SCHEMA = MY_SCHEMA;

MY_SCHEMA without quote.

Oracle recommends against issuing ALTER SESSION SET CURRENT_SCHEMA from in a stored PL/SQL unit.