How To Check the PostgreSQL Version

Introduction

In this tutorial we learn how to check the PostgreSQL version installed on a system. There are multiple methods to check PostgreSQL version and we will learn each of the method.

PostgreSQL Versioning

Starting from version 10. PostgreSQL using the following pattern for it’s versioning number

MAJOR.MINOR

For example 10.1, 11.2, 12.3, and 13.0.

Before version 10. The major version use two number separated by dot.

For example:

  • PostgreSQL version 9.5.10 the major version is 9.5 and minor 10.
  • PostgreSQL version 9.6.4 the major version is 9.6 and minor version 4.

Understanding this difference is important to know if you need to do upgrade or have to match application requirements with specific major version of PostgreSQL or minor version of PostgreSQL

Check PostgreSQL Version From Command Line

The first method to check the PostgreSQL version is to use the command line. On the system running PostgreSQL we can use the command below:

postgres --version

Another method to check the version of PostgreSQL from the command line is using the command below:

postgres -V

Check PostgreSQL Version From SQL

The second method that we can use to check the PostgreSQL version is from the SQL shell. First, we need to change the user to the postgres user.

Then we connect to the local PostgreSQL database using the psql command.

psql

After connected to PostgreSQL shell we can use one the following query:

SELECT version();

Another query that we can run on PostgreSQL shell to get the running version is using the following query

SHOW server_version;

Video Tutorial

Summary

In this tutorial we learn how to check the version of PostgreSQL on the running system using two different methods, the first one is using shell command line and the second method is using SQL shell.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.