ALTER_SYSTEM(7pg13)

πŸ“¦ version 13.23, in opensuse-leap 16.0

πŸ’… 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 SIGHUP signal 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 in postgresql.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