Skip to content

CURRENT_SCHEMA

Return the name of the first schema in the search path (or a null value if the search path is empty).

CURRENT_SCHEMA[()]

The parentheses are optional. For example:

yellowbrick=# SET SCHEMA 'stage';
SET

yellowbrick=# SELECT CURRENT_SCHEMA();
current_schema
----------------
stage
(1 row)

See also CURRENT_SCHEMAS().

search_path (configuration variable)

See the search_path configuration parameter to see how database objects are searched for in schemas.

Alternatively, you can use a set schema command with single quotes around the schema name to change the current schema.

yellowbrick=# set schema 'neilschema';
SET

Note: set schema 'value' is equivalent to set search_path to 'value', but you can only specify one schema in the set schema syntax.

A qualified schema name consists of the schema name and table name separated by dots. You may also include the database name before the schema name.

database.schema.table

New objects that are not schema-qualified, consisting of just the table name, are always created in the first schema of the search path. To access any object that is not in a schema listed in the search path, you must provide the schema name.