ALTER_SYSTEM(7pg13)
π
ALTER SYSTEM (a.k.a. the ALTER_SYSTEM page, straight outta the PostgreSQL 13.23 Documentation bestie!!) β¨
okay so real talk, this is the page that lets you change server config parameters for your whole entire database cluster without ever touching a text editor like some kind of medieval peasant. we love her. π
πΈ NAME πΈ
ALTER_SYSTEM β change a server configuration parameter, no cap π
π¦ SYNOPSIS π¦
ALTER SYSTEM SET configuration_parameter { TO | = } { value [, ...] | DEFAULT }
ALTER SYSTEM RESET configuration_parameter
ALTER SYSTEM RESET ALL
look at her. so clean. so iconic. π
β¨ DESCRIPTION β¨
ALTER SYSTEM is literally THE tool for changing server configuration parameters across the entire database cluster β like, everyone gets the new fit, not just one session. π«Ά
It can be way more convenient than the traditional method of manually editing the postgresql.conf file (iykyk, nobody wants to be in vim at 3am).
Here's the tea: ALTER SYSTEM writes the given parameter setting to the postgresql.auto.conf file, which is read in addition to postgresql.conf. Two files, one vibe. π
Setting a parameter to DEFAULT, or using the RESET variant, removes that configuration entry from the postgresql.auto.conf file. And RESET ALL removes all such configuration entries β like a full closet cleanout but for config. π§Ή
Values set with ALTER SYSTEM will be effective after the next server configuration reload, or after the next server restart in the case of parameters that can only be changed at server start. A server configuration reload can be commanded by:
- calling the SQL function
pg_reload_conf() - running
pg_ctl reload - sending a
SIGHUPsignal to the main server process
β οΈ ok so listen: only superusers can use ALTER SYSTEM. also, since this command acts directly on the file system and cannot be rolled back, it is not allowed inside a transaction block or function. it's giving "no undo button, bestie" ππ
π PARAMETERS π
configuration_parameterβ name of a settable configuration parameter. the available parameters are documented in Chapter 19 (go read it, I'll wait π).valueβ the new value of the parameter. values can be specified as string constants, identifiers, numbers, or comma-separated lists of these, as appropriate for the particular parameter. values that are neither numbers nor valid identifiers must be quoted. π
and yes, DEFAULT can be written to specify removing the parameter and its value from postgresql.auto.conf.
π little quirk alert: for some list-accepting parameters, quoted values will produce double-quoted output to preserve whitespace and commas; for others, double-quotes must be used inside single-quoted strings to get this effect. not me having to remember which is which... π
π§ NOTES π§
- this command can't be used to set
data_directory, nor parameters that are not allowed inpostgresql.conf(e.g., preset options). nope nope nope π - see Section 19.1 for other ways to set the parameters. options, we love options π
π₯ EXAMPLES π₯
Set the wal_level:
ALTER SYSTEM SET wal_level = replica;
Undo that, restoring whatever setting was effective in postgresql.conf:
ALTER SYSTEM RESET wal_level;
periodt. it's that easy. π β¨
β COMPATIBILITY β
The ALTER SYSTEM statement is a PostgreSQL extension β she's homegrown, not from the standard. main character energy fr fr π
π SEE ALSO π
~ and that's the whole page, bestie ~ π¦π
written for PostgreSQL 13.23 β dated 2025, same as ever, slaying in the docs since forever. πβ¨ go forth and reload your conf responsibly π«ΆπΈ
π¦ where this page comes from
- opensuse-leap 16.0: postgresql13 13.23-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql13 13.23-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql13 13.23-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql13 13.23-160000.1.1 Β· PostgreSQL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms