ALTER_SYSTEM(7pg18)
β¨ ALTER SYSTEM β¨
okay bestie so this is a page straight out of the PostgreSQL 18.6 docs, and it's about the ALTER SYSTEM command β the glow-up way to change your server config. let's get into it π
π NAME π
ALTER_SYSTEM β change a server configuration parameter
fr fr that's the whole vibe: tweak a server config param, no manual file editing required π«Ά
πΈ SYNOPSIS πΈ
ALTER SYSTEM SET configuration_parameter { TO | = } { value [, ...] | DEFAULT }
ALTER SYSTEM RESET configuration_parameter
ALTER SYSTEM RESET ALL
π DESCRIPTION π
So ALTER SYSTEM is the icon for changing server configuration parameters across your entire database cluster. It's literally so much more convenient than the old-school method of manually editing the postgresql.conf file. not me opening a text editor in 2026 π
What it actually does: ALTER SYSTEM writes the given parameter setting into the postgresql.auto.conf file, which gets read in addition to postgresql.conf. and if you set a parameter to DEFAULT, or you use the RESET variant, it removes that configuration entry from postgresql.auto.conf entirely. RESET ALL clears out all of those configuration entries. slay, clean slate β¨
Now the timeline of when your changes actually hit:
- Values set with
ALTER SYSTEMare effective after the next server configuration reload - OR after the next server restart if it's a parameter that can only be changed at server start (some params are just like that, main character behavior only π)
Want to trigger a reload? You've got three options, pick your fighter:
- calling the SQL function
pg_reload_conf() - running
pg_ctl reload - sending a
SIGHUPsignal to the main server process
Permission check π
: only superusers and users who've been granted ALTER SYSTEM privilege on a parameter can change it using ALTER SYSTEM.
π¨ Also β and this is important β since this command acts directly on the file system and cannot be rolled back, it is not allowed inside a transaction block or a function. no undo button, no take-backs, bestie. periodt.
π PARAMETERS π
configuration_parameterβ the name of a settable configuration parameter. the available ones are documented in Chapter 19.valueβ the new value of the parameter. values can be written as string constants, identifiers, numbers, or comma-separated lists of those, whichever fits the particular parameter. Values that are neither numbers nor valid identifiers must be quoted. and you can writeDEFAULTto specify removing the parameter and its value frompostgresql.auto.conf.- okay this next bit is niche but lowkey important: for some list-accepting parameters, quoted values will produce double-quoted output, which is how whitespace and commas get preserved. for others, you have to use double-quotes inside single-quoted strings to get that same effect. iykyk π¦
π§ NOTES π§
- This command can't be used to set
data_directory,allow_alter_system, nor parameters that are not allowed inpostgresql.conf(e.g., preset options). not up for discussion π - See Section 19.1 for other ways to set the parameters.
ALTER SYSTEMcan be disabled by settingallow_alter_systemtooff, but heads up: this is not a security mechanism (it's explained in detail in the documentation for that parameter, go read it).
β 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;
see? iconic. ate and left no crumbs π
π COMPATIBILITY π
The ALTER SYSTEM statement is a PostgreSQL extension.
(translation: this is our thing, not standard SQL, we made it ourselves π )
π₯ SEE ALSO π₯
and that's the whole page, bestie!! this one was shipped in the PostgreSQL 18.6 docs and dated 2026. go forth and configure responsibly π«Άβ¨π
π¦ where this page comes from
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 Β· PostgreSQL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms