• Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate
TecNStuff
Menu
  • Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate

How to Check the PostgreSQL Version

Written by Admin, Updated On June 22, 2020
postgresql
How to Check the PostgreSQL Version

PostgreSQL is also known as Postgres and it’s an open-source object-relational database management system. It is important to know the version of the PostgreSQL server which is installed on your system when your application is based on specific version. This tutorial will show you how to check the PostgreSQL server version which is running on your system.

Check PostgreSQL Version#

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

Using the Command Line#

You can check the which PostgreSQL version is running on your system using command line by invoking postgres command with --version or -V option:

postgres --version

It will show you output like below:

postgres (PostgreSQL) 12.3

At the time of writing this article, the latest version of postgres is 12.3.

If you will get an error saying “postgres: command not found”, that means you have not postgres binary in system’s PATH or the PostgreSQL package is not installed from the distribution’s standard repositories.

To find the path to the binary either with the locate or find command:

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

Output will looks like below:

/usr/lib/postgresql/12/bin/postgres

Now you can use the path to the binary, to get the version of the PostgreSQL server:

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

To know the version of PostgreSQL client utility use psql as following:

psql --version

It will print output as below:

postgres (PostgreSQL) 12.3

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

Using the SQL Shell#

Alternate way to get the PostgreSQL server version is by logging in to the SQL server prompt and print out the version using an SQL statement.

Access the PostgreSQL shell using with psql:

sudo -u postgres psql

Following statement displays the PostgreSQL server version along with the build information:

SELECT version();
PostgreSQL 12.3 on x86_64-unknown-linux-gnu, compiled by gcc (Ubuntu 4.8.2-19ubuntu1) 4.8.2, 64-bit
(1 row)

To get the only PostgreSQL server version number type:

SHOW server_version;
 server_version 
----------------
 12.3
(1 row)

Conclusion#

We have shown you different ways to determine the PostgreSQL server version which is running on your system.

If you have any questions or suggestion, please leave a comment below.

If our content helps you, please consider buying us a coffee

Thank you for your support.

Share On
Share on Facebook
Share on Twitter
Share on Reddit
Share on Tumblr
 Previous Article How to Install Mono on Debian 10 Buster
Next Article   How to Install Skype on Debian 10 Buster

Related Posts

  • How to Install PostgreSQL on Ubuntu 20.04

    How to Install PostgreSQL on Ubuntu 20.04

    May 23, 2020
  • How to Install PostgreSQL on CentOS 8

    How to Install PostgreSQL on CentOS 8

    December 23, 2019
  • How to Install PostgreSQL on CentOS 7

    How to Install PostgreSQL on CentOS 7

    July 30, 2019

Leave a Reply Cancel reply

Popular Posts

  • How to Install Python 3.9 on Debian 10
    How to Install Python 3.9 on Debian 10 December 25, 2020
  • How to Install Python 3.9 on Ubuntu 20.04
    How to Install Python 3.9 on Ubuntu 20.04 December 21, 2020
  • How to Install GIMP on Ubuntu 20.04
    How to Install GIMP 2.10 on Ubuntu 20.04 December 22, 2020
  • How to Install Notepad++ on Debian 10
    How to Install Notepad++ on Debian 10 December 23, 2020
  • How to Install Php 8 on Debian 10
    How to Install PHP 8 on Debian 10 January 2, 2021
© 2020 TecNStuff All rights reserved. This website is using and storing cookies on your browser. By using this website you agree our Privacy Policy.  Follow us -  Twitter | Facebook