current_schemas()

一个列出当前搜索路径中模式的函数

current_schemas() 是一个系统函数,用于列出当前有效搜索路径中的模式。

current_schemas() 已在 PostgreSQL 7.3 中添加。

用法

current_schemas ( include_implicit boolean ) → name[]

如果 include_implicitFALSE,则返回当前搜索路径中存在的、可搜索的所有模式。

如果 include_implicitTRUE,则返回的列表中包含隐式搜索的系统模式,例如 pg_catalog

变更历史

示例

的基本用法示例

postgres=# SELECT * FROM current_schemas(false);
 current_schemas 
-----------------
 {public}
(1 row)

包含隐式模式

postgres=# SELECT * FROM current_schemas(true);
   current_schemas   
---------------------
 {pg_catalog,public}
(1 row)

模式按 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)

不存在的模式将不会被列出

postgres=# SET search_path TO baz, boo;
SET

postgres=# SELECT * FROM current_schemas(false);
 current_schemas 
-----------------
 {}
(1 row)

分类

模式(命名空间), 系统函数

另请参阅

current_schema()

反馈

请在此处 提交关于“current_schemas()”的任何评论、建议或更正