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()" 的任何评论、建议或更正 在此处