Contents
SET
A utility command for changing a run-time parameter
SET
is a utility command for changing a run-time system parameter.
SET
was added in PostgreSQL 6.1.
Usage
In its basic form, SET
is used to modify a run-tme system parameter in the context of a session or transaction within that session using the following syntax:
SETparameter
[ TO | = ]value
Note that the function set_config()
provides equivalent functionality to SET
.
SET
also provides specific syntax invocations for a subset of parameters, partially for SQL compatibility reasons; these are:
SET NAMES
SET SCHEMA
SET SEED
SET TIME ZONE
There are also a number of unrelated SET ... commands; these are discussed in separate entries:
SET CONSTRAINTS
SET ROLE
SET SESSION AUTHORIZATION
SET TRANSACTION
Change history
Work-in-progress
- PostgreSQL 15
- PostgreSQL 7.3
SET [ SESSION | LOCAL ]
syntax added (commit f0811a74)
- PostgreSQL 6.4
SET NAMES
syntax added (commit bf00bbb0)
- PostgreSQL 6.1
- added (initial commit a51df14a)
Examples
Basic usage example for SET
:
postgres=# SET application_name TO 'foo'; SET postgres=# SHOW application_name; application_name ------------------ foo (1 row)
The =
character can be used in place of TO
:
postgres=# SET application_name = 'bar'; SET postgres=# SHOW application_name; application_name ------------------ bar (1 row)
Reset the parameter to its original value with DEFAULT
:
postgres=# SET application_name TO DEFAULT; -- equivalent to RESET application_name SET postgres=# SHOW application_name; application_name ------------------ psql (1 row)
References
- PostgreSQL documentation: SET