SHOW 是一个用于显示当前 配置参数 值的实用命令。
SHOW 在 PostgreSQL 6.1 中添加。
用法
SHOW 是显示当前 配置参数 值的简单直观方法,或者通过 SHOW ALL 语法列出所有配置参数的当前值。
出于历史原因,SHOW 还可以显示以下项目的当前设置
IS_SUPERUSERLC_COLLATE(PostgreSQL 15 及更早版本)LC_TYPE(PostgreSQL 15 及更早版本)SERVER_ENCODINGSERVER_VERSION
SHOW 命令的替代方案
SHOW 返回的行无法在 SQL 层面进行操作,这限制了该命令在临时命令行查询中的可用性。
函数 current_setting() 和视图 pg_settings 提供了一种更灵活的方式来获取有关当前 配置参数 设置的信息。
源代码
实现 SHOW 的代码包含在 src/backend/utils/misc/guc.c 中,具体函数为
ShowGUCConfigOption()用于SHOW nameShowAllGUCConfig()用于SHOW ALL
变更历史
- PostgreSQL 7.4
- PostgreSQL 7.2
- 添加了
SHOW ALL语法(提交 4ee76ad8)
- 添加了
- PostgreSQL 6.1
- 添加(初始提交 4b531912)
示例
显示正常配置参数的当前设置
postgres=# SHOW port; port ------ 5432 (1 row)
尝试显示不存在的配置参数的值
postgres=# SHOW foo; ERROR: unrecognized configuration parameter "foo"
显示所有配置参数(为清晰起见,输出已截断)
postgres=# SHOW ALL; -[ RECORD 1 ]----------------------------------------------------------------------- name | allow_system_table_mods setting | off description | Allows modifications of the structure of system tables. -[ RECORD 2 ]----------------------------------------------------------------------- name | application_name setting | psql description | Sets the application name to be reported in statistics and logs. -[ RECORD 3 ]----------------------------------------------------------------------- name | archive_cleanup_command setting | description | Sets the shell command that will be executed at every restart point. -[ RECORD 4 ]----------------------------------------------------------------------- ...
参考资料
- PostgreSQL 文档: SHOW
