alter system用于批改整个server级别的配置,它通过批改文件来实现。只能由superuser执行,并且不能在事务中执行(批改了配置文件postgresql.auto.conf,不能回退)
配置后,参数不会立即失效,须要零碎从新reload参数(pg_reload_conf(), pg_ctl reload, 或者向postmaster发送SIGHUP),有的参数是server启动时才失效,则须要restart server(pg_ctl restart)。
用法
ALTER SYSTEM SET configuration_parameter { TO | = } { value | 'value' | DEFAULT }ALTER SYSTEM RESET configuration_parameterALTER SYSTEM RESET ALL
用法例子
alter system
ALTER SYSTEM set max_prepared_transactions to 10;postgres=# show max_prepared_transactions; max_prepared_transactions--------------------------- 0(1 row)[root@centos]# cat /usr/local/pgsql/data/postgresql.auto.conf# Do not edit this file manually!# It will be overwritten by the ALTER SYSTEM command.max_prepared_transactions = '10'
非启动用参数失效,不须要重启server
如???
select pg_reload_conf();pg_ctl xxx reload
启动用参数失效,须要重启服务
如max_prepared_transactions
pg_ctl xxx restart
参考资料
https://www.postgresql.org/do...