Skip to main content

Catalog Functions

Several functions are provided to inspect the catalogs and schemas that are configured in the database.

The following catalog functions are available:

FunctionDescription
current_catalog()Returns the name of the currently active catalog.
current_schema()Returns the name of the currently active schema.
current_schemas(include_implicit)Returns the list of schemas in the search path. Pass true to include implicit schemas.

current_catalog()

Returns the name of the currently active catalog, which is the database the session is connected to.

Query
SELECT current_catalog() = current_database() AS catalog_is_current_db;
Result
 catalog_is_current_db----------------------- t

current_schema()

Returns the name of the currently active schema.

Query
SELECT current_schema();
Result
 current_schema---------------- public

current_schemas(include_implicit)

Returns the list of schemas in the search path. Pass true to include implicit schemas such as pg_catalog.

Query
SELECT current_schemas(true) AS schemas;
Result
 schemas--------------------- {pg_catalog,public}
Query
SELECT current_schemas(false) AS schemas;
Result
 schemas---------- {public}

This page contains: