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:

SET parameter [ 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:

Change history

Work-in-progress

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)
  • PostgreSQL documentation: SET

Categories

Configuration, Utility command

See also

SHOW, RESET, set_config()