How to check the PostgreSQL version

Akademily
3 min readSep 27, 2020

--

How to check the PostgreSQL version

PostgreSQL, often referred to simply as Postgres, is a universal open-source object and relational database management system.
Knowing which version of the PostgreSQL server is installed and running in your system may be important in some situations. For example, if you are installing an application that requires a certain PostgreSQL version, you need to find out which version of your PostgreSQL server you are running.

In this article, we will explain how to find out which version of PostgreSQL server is running on your system.

POSTGRESQL VERSION

PostgreSQL has versions in the following scheme:

MAJOR.MINOR

For example, in PostgreSQL 12.1 12 is the main version and 1 is the additional version.

  • MAJOR — Starting with PostgreSQL 10, each new major release increases a part of the MAJOR version by one, for example by 10, 11, or 12. Prior to PostgreSQL 10, the major versions were represented by a decimal number, such as 9.0 or 9.6.
  • MINOR — The minor release number is the last part of the version number. For example, 11.4 and 11.6 are minor versions, which are part of PostgreSQL version 11 9.6.15, and 9.6.16 are part of PostgreSQL version 9.6.

Major PostgreSQL releases with new features are usually released once a year. Each major release is supported for 5 years.

COMMAND-LINE USE

To find out which PostgreSQL version works on your system, call the Postgres command with the -version or -V parameter:

postgres --version

The command will print the PostgreSQL version:

postgres (PostgreSQL) 10.6

This example uses the PostgreSQL server version 10.6.

If the Postgres binary file is absent in the system PATH, you will get the error message “Postgres: command not found”. This usually happens when PostgreSQL package is not installed from standard distribution repositories.

You can find the path to the binary with the locate or find command:

sudo find /usr -wholename '*/bin/postgres'.
sudo updatedb
locate bin/postgres

The conclusion should look like this:

/usr/lib/postgresql/9.6/bin/postgres

Once you find the path to the binary file, you can use it to get a version of the PostgreSQL server:

/usr/lib/postgresql/9.6/bin/postgres -V

The version of the psql client utility in PostgreSQL can be found with the following command:

psql --version

The conclusion will look like this:

postgres (PostgreSQL) 10.6

psql is an interactive command-line utility that allows you to interact with the PostgreSQL server.

USING SQL SHELL

Another way to determine the version of the PostgreSQL server is to log in to the server SQL query and use the SQL instruction to print the version.

You can access the PostgreSQL shell using a GUI client such as pgAdmin or using psql:

sudo -u postgres psql

The following operator displays the PostgreSQL server version together with the build information:

SHOW server_version;

server_version
----------------
10.6
(1 row)

CONCLUSION

In this article, we showed you several different options on how to find the PostgreSQL server version running on your system.

--

--

Akademily
Akademily

Written by Akademily

We conduct reviews, guides and comparative tests of gaming laptops, monitors, graphics cards, keyboards, mouses, headsets and chairs to help you buy the best ga

No responses yet