查询参数(postgresql.conf设置),如"max_connections"

Gre*_*ida 106 postgresql settings configuration postgresql-9.1

有谁知道在PostgreSQL(9.1)中查询数据库服务器设置是否可行(以及如何,如果是)?

我需要查看max_connections(最大打开数据库连接数)设置.

Erw*_*ter 196

可以这么简单:

SHOW max_connections;
Run Code Online (Sandbox Code Playgroud)

这将返回当前有效的设置.请注意,它可能与设置不同,postgresql.conf因为有两种方法可以在PostgreSQL中设置运行时参数.要重置postgresql.conf当前会话中的"原始"设置:

RESET max_connections;
Run Code Online (Sandbox Code Playgroud)

但是,不适用于此特定设置.每个文件:

此参数只能在服务器启动时设置.

要查看所有设置:

SHOW ALL;
Run Code Online (Sandbox Code Playgroud)

有关SHOW手册中命令的更多信息.
如果您需要更多详细信息或想要将查找集成到标准SELECT查询中,还有:

SELECT * FROM pg_settings;
Run Code Online (Sandbox Code Playgroud)

返回SHOW ALL与之相同的结果,但每个设置都包含其他信息.原始要求:

SELECT *
FROM   pg_settings
WHERE  name = 'max_connections';
Run Code Online (Sandbox Code Playgroud)

还有功能等效的current_setting(),它可以嵌套在DML语句中.

SELECT current_setting('max_connections');
Run Code Online (Sandbox Code Playgroud)

有关: