Contents
current_schemas()
A function listing the schemas in the current search path
current_schemas()
is a system function listing the schemas in the current effective search path.
current_schemas()
was added in PostgreSQL 7.3.
Usage
current_schemas (include_implicit
boolean
) →name
[]
If include_implicit
is FALSE
, all schemas defined in the current search path which exist and are searchable are returned.
If include_implicit
is TRUE
, the returned list includes implicitly searched system schemas such as pg_catalog
.
Change history
- PostgreSQL 7.3
- added (commit a309032d)
Examples
Basic usage example of :
postgres=# SELECT * FROM current_schemas(false); current_schemas ----------------- {public} (1 row)
Including implicit schemas:
postgres=# SELECT * FROM current_schemas(true); current_schemas --------------------- {pg_catalog,public} (1 row)
Schemas are listed in the order defined in search_path:
postgres=# CREATE SCHEMA foo; CREATE SCHEMA postgres=# CREATE SCHEMA bar; CREATE SCHEMA postgres=# SET search_path TO bar, foo; SET postgres=# SELECT * FROM current_schemas(false); current_schemas ----------------- {bar,foo} (1 row)
Non-existent schemas will not be listed:
postgres=# SET search_path TO baz, boo; SET postgres=# SELECT * FROM current_schemas(false); current_schemas ----------------- {} (1 row)
References
- PostgreSQL documentation: System Information Functions and Operators