How To Check the PostgreSQL Version
Posted on April 25, 2021 (Last modified on July 14, 2022) • 2 min read • 306 wordsIn this tutorial we learn how to check the PostgreSQL version. We will check the version using shell command line and SQL Shell.
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.
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:
9.5.10
the major version is 9.5
and minor 10
.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
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
```bash
Another method to check the version of PostgreSQL from the command line is using the command below:
```bash
postgres -V
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
```bash
After connected to PostgreSQL shell we can use one the following query:
```bash
SELECT version();
Another query that we can run on PostgreSQL shell to get the running version is using the following query
SHOW server_version;
```bash
## Video Tutorial {#h-video-tutorial}
## Summary {#h-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.