PostgreSQL current_schemas() Function

The PostgreSQL current_schemas() function returns all schema names on the currently valid search path in order of priority.

current_schemas() Syntax

Here is the syntax of the PostgreSQL current_schemas() function:

current_schemas(include_implicit boolean) -> name[]

Parameters

include_implicit

Required. Whether to include an implicit system mode. Boolean type.

If include_implicit is FALSE, this function returns all existing and searchable patterns defined in the current search path.

If include_implicit is TRUE, the returned list includes implicitly searched system patterns, eg pg_catalog.

Return value

The PostgreSQL current_schemas() function returns an array containing all schema names on the currently valid search path, in order of priority.

current_schemas() Examples

To get all patterns on a valid path (excluding implicit patterns), use the following SELECT statement with the current_schemas() function:

SELECT current_schemas(false);
 current_schemas
-----------------
 {public}

To get all patterns (including implicit patterns) on a valid path, use the following statement:

SELECT current_schemas(true);
   current_schemas
---------------------
 {pg_catalog,public}

Here, pg_catalog is an implicit system pattern.