SHOW

用于显示配置参数当前值的 SQL 命令

SHOW 是一个用于显示当前 配置参数 值的实用命令。

SHOWPostgreSQL 6.1 中添加。

用法

SHOW 是显示当前 配置参数 值的简单直观方法,或者通过 SHOW ALL 语法列出所有配置参数的当前值。

出于历史原因,SHOW 还可以显示以下项目的当前设置

  • IS_SUPERUSER
  • LC_COLLATEPostgreSQL 15 及更早版本)
  • LC_TYPEPostgreSQL 15 及更早版本)
  • SERVER_ENCODING
  • SERVER_VERSION

SHOW 命令的替代方案

SHOW 返回的行无法在 SQL 层面进行操作,这限制了该命令在临时命令行查询中的可用性。

函数 current_setting() 和视图 pg_settings 提供了一种更灵活的方式来获取有关当前 配置参数 设置的信息。

源代码

实现 SHOW 的代码包含在 src/backend/utils/misc/guc.c 中,具体函数为

  • ShowGUCConfigOption() 用于 SHOW name
  • ShowAllGUCConfig() 用于 SHOW ALL

变更历史

示例

显示正常配置参数的当前设置

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

分类

配置SQL 命令实用命令

另请参阅

current_setting()SETRESET

反馈

提交任何关于“SHOW”的评论、建议或更正请点击 此处