PostgreSQL version() Function

The PostgreSQL version() function returns the version of the current PostgreSQL server.

version() Syntax

Here is the syntax of the PostgreSQL version() function:

version() -> text

Parameters

The PostgreSQL version() function does not require any parameters.

Return value

The PostgreSQL version() function returns a string describing the version information of the current PostgreSQL server.

version() Examples

To get the version number of the PostgreSQL server, use the following statement with the version() function:

SELECT version();
                          version
------------------------------------------------------------
 PostgreSQL 14.2, compiled by Visual C++ build 1914, 64-bit

Additionally, you can read the version number of PostgreSQL from the server_version and server_version_num variables.

Read the version number of PostgreSQL from the server_version variable:

SHOW server_version;
 server_version
----------------
 14.4

Read the version number of PostgreSQL from the server_version_num variable:

SHOW server_version_num;
 server_version_num
--------------------
 140004