ALTER_SYSTEM(7pg17)
π NAME π
Okay so bestie, this is the ALTER_SYSTEM page from the PostgreSQL 17.11 Documentation, and it is literally about changing a server configuration parameter across your entire database cluster. Main character energy for your config files, no cap. β¨
π¦ SYNOPSIS π¦
ALTER SYSTEM SET configuration_parameter { TO | = } { value [, ...] | DEFAULT }
ALTER SYSTEM RESET configuration_parameter
ALTER SYSTEM RESET ALL
πΈ DESCRIPTION πΈ
So ALTER SYSTEM is the glow-up way to change server configuration parameters across the entire database cluster. It can be way more convenient than the traditional method of manually editing the postgresql.conf file β like, why hand-edit when you have syntax, bestie? π
ALTER SYSTEM writes the given parameter setting to the postgresql.auto.conf file, which is read in addition to postgresql.conf. Setting a parameter to DEFAULT, or using the RESET variant, removes that configuration entry from the postgresql.auto.conf file. And use RESET ALL to remove all such configuration entries. Cleanup queen behavior. π
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, or sending a SIGHUP signal to the main server process. Slay, signal, reload. π₯
Only superusers and users granted ALTER SYSTEM privilege on a parameter can change it using 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.
β οΈ Bestie, hear me: this one is not undo-able like a bad text. It acts directly on the file system, so no transaction-block or function shenanigans. Periodt. π
β¨ PARAMETERS β¨
configuration_parameterβ the name of a settable configuration parameter. Available parameters are documented in Chapter 19. iykyk, go check the chapter. π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.DEFAULTcan be written to specify removing the parameter and its value frompostgresql.auto.conf.
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. Quoting drama, but make it config. π¦
π NOTES π
This command can't be used to set data_directory, allow_alter_system, nor parameters that are not allowed in postgresql.conf (e.g., preset options). Not me trying to sneak those in β it's a no. π
See Section 19.1 for other ways to set the parameters. There are other routes, bestie, this is not the only road. π£οΈ
ALTER SYSTEM can be disabled by setting allow_alter_system to off, but this is not a security mechanism (as explained in detail in the documentation for this parameter). So don't use it like a lock on your bedroom door, okay? π
π§ 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;
π COMPATIBILITY π
The ALTER SYSTEM statement is a PostgreSQL extension. It's giving PostgreSQL-only, and honestly? Iconic. π
β SEE ALSO β
Mwah π β page source says PostgreSQL 17.11, dated 2026, and this little config fairy is signing off. π«ΆπΈ
π¦ where this page comes from
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql17 17.11-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