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_parameter
ALTER 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…