> For the complete documentation index, see [llms.txt](https://docs.postgresql.tw/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.postgresql.tw/reference/sql-commands/sql-altersystem.md).

# ALTER SYSTEM

### ALTER SYSTEM

ALTER SYSTEM — change a server configuration parameter

### Synopsis

```

ALTER SYSTEM SET configuration_parameter { TO | = } { value [, ...] | DEFAULT }

ALTER SYSTEM RESET configuration_parameter
ALTER SYSTEM RESET ALL
```

### Description

`ALTER SYSTEM` is used for changing server configuration parameters across the entire database cluster. It can be more convenient than the traditional method of manually editing the `postgresql.conf` file. `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. Use `RESET ALL` to remove all such configuration entries.

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.

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.

### Parameters

*`configuration_parameter`* : Name of a settable configuration parameter. Available parameters are documented in [Chapter 19](/server-administration/runtime-config.md).

*`value`* : 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. `DEFAULT` can be written to specify removing the parameter and its value from `postgresql.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.
```

### Notes

This command can't be used to set [data\_directory](/server-administration/runtime-config/runtime-config-file-locations.md#GUC-DATA-DIRECTORY), [allow\_alter\_system](/server-administration/runtime-config/runtime-config-compatible.md#GUC-ALLOW-ALTER-SYSTEM), nor parameters that are not allowed in `postgresql.conf` (e.g., [preset options](/server-administration/runtime-config/runtime-config-preset.md)).

See [Section 19.1](/server-administration/runtime-config/config-setting.md) for other ways to set the parameters.

`ALTER SYSTEM` can be disabled by setting [allow\_alter\_system](/server-administration/runtime-config/runtime-config-compatible.md#GUC-ALLOW-ALTER-SYSTEM) to `off`, but this is not a security mechanism (as explained in detail in the documentation for this parameter).

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

### See Also

[SET](/reference/sql-commands/sql-set.md), [SHOW](/reference/sql-commands/sql-show.md)

***

原文：[PostgreSQL 18.6 Documentation](https://www.postgresql.org/docs/18/sql-altersystem.html)（英文原文，待翻譯）


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.postgresql.tw/reference/sql-commands/sql-altersystem.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
