postgresql: alter system

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...

你可能感兴趣的:(postgresql)