version()

A function returning details of the server version

version() is a system function returning a description of the PostgreSQL server version, including the human-readable version number and details about how the server was built.

version() was added in PostgreSQL 6.4.

Usage

version () → text

Note that the string returned by version() is fairly arbitrary (it may for example be customised by packagers) and generally not suited for parsing (use server_version_num to obtain a machine-readable version number).

Change history

Examples

Basic usage example for version() on a source build:

postgres=# SELECT version();
                                                  version                                                  
-----------------------------------------------------------------------------------------------------------
 PostgreSQL 14beta2 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 8.3.1 20191121 (Red Hat 8.3.1-5), 64-bit
(1 row)

Package maintainers sometimes insert additional information (here Debian):

postgres=# SELECT version();
                                                      version
--------------------------------------------------------------------------------------------------------------------
 PostgreSQL 11.12 (Debian 11.12-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
(1 row)

The human-readable version number can be extracted via server_version:

postgres=# SHOW server_version;
 server_version
----------------
 14beta2
(1 row)

although it may contain additional details, e.g. here from a Debian package installation:

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

A machine-readable version number can be obtained from server_version_num:

postgres=# SHOW server_version_num;
 server_version_num
--------------------
 110012
(1 row)

Categories

PostgreSQL versioning, System function

See also

server_version, server_version_num, Obtain the PostgreSQL version number