server_version

A read-only server parameter containing the server version number

server_version is a read-only configuration parameter containing a representation of the server version number in human-readable form.

server_version was added in PostgreSQL 7.4.

Usage

server_version reports the current server version number in text form (e.g. "12.7"), possibly including additional information provided by the server packager.

server_version reports the value of PG_VERSION defined when the server was built.

To obtain a machine-readable version of the server number as an integer, see server_version_num.

Change history

Examples

Basic usage example for server_version:

postgres=# SHOW server_version;
 server_version 
----------------
 12.7
(1 row)

Note that the value returned may contain additional information provided by the packager, e.g. for Debian the number will be reported like this:

postgres=# SHOW server_version;
          server_version
----------------------------------
 11.12 (Debian 11.12-1.pgdg100+1)
(1 row)

Comparision of the various forms of server version information which are available:

postgres=# SELECT version(),
                  current_setting('server_version') AS server_version,
                  current_setting('server_version_num') AS server_version_num\gx
-[ RECORD 1 ]------+-------------------------------------------------------------------------------------------------------
version            | PostgreSQL 12.7 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 8.3.1 20191121 (Red Hat 8.3.1-5), 64-bit
server_version     | 12.7
server_version_num | 120007

Categories

GUC configuration item, PostgreSQL versioning, Preset configuration item

See also

server_version_num, version(), Obtain the PostgreSQL version number