How to Check Which Version of Postgres is Running?

Hello! Today we will talk about how to check which version of Postgres is running? Checking PostgreSQL version is the first step of inspecting an environment, to understand characteristics, defects and buggy features.

I have done many health checks for Db2, WebSphere, FileNet before, always, learning the version of running product was the first step. After learning running version and customers complaints it becomes easier to analyze customer’s complaint with bug / defect information on the internet or vendors website.

How to check which version of postgres is running?

Today, i will show you 4 different options to check PostgreSQL version, 2 of them are SQL statements and 2 of them are bash commands.

Option 1

psql -V is our first option. With single dash and capital V with psql will display version of the PostgreSQL. To learn postgresql version you can use psql -V command.

How to check which version of postgres is running?

This will output the version of the postgresql.

This option can be used for bash scripts. Consider using option #1 and #2 to check version information from bash or from bash scripts.

Option 2

Second option to learn running PostgreSQL version is similar with previous one but argument changes to –version. You can use psql –version to find Postgresql version information.

postgres@a5dd0e71635a:~$ psql --version
psql (PostgreSQL) 16.1 (Debian 16.1-1.pgdg120+1)

As you can see, this outputs the same with the previous command.

This option can be used for bash scripts. Consider using option #1 and #2 to check version information from bash or from bash scripts.

Option 3

PostgreSQL can supply the version information via an SQL statement as well. SELECT VERSION() statement can be used to find running PostgreSQL version.

postgres=# SELECT VERSION();
                                                       version
---------------------------------------------------------------------------------------------------------------------
 PostgreSQL 16.1 (Debian 16.1-1.pgdg120+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit
(1 row)

This option can be used while collecting information about installation using SQL statements. Option #4 can be more useful for version information only but this option is more useful to have deeper information.

Option 4

There is another way to learn PostgreSQL version using SQL Statements as well:

postgres=# SHOW SERVER_VERSION;
         server_version
--------------------------------
 16.1 (Debian 16.1-1.pgdg120+1)
(1 row)

This option can be used while collecting information via SQL Statements. This options prints clean and only required information.

To Sum Up

Version information is a critical information to understand how an environment performs, bugs and defect related with that version.

Today we covered how to check which version of postgres is running topic, please leave a comment below if you have any question or just drop a hi below. I am looking forward to meet you!

Please ask your questions below!


Hi! I’m an IT Specialist

I want to hear from you! I am Working with enterprises for 10+ years to improve their infrastructure and efficiency.

Get in touch with me.

A new post everyday, subscribe now and don’t miss it!

Subscribe to our newsletter for cool news

Hi! I’m an IT Specialist

I want to hear from you! I am Working with enterprises for 10+ years to improve their infrastructure and efficiency.

Get in touch with me.

Leave a Reply

Discover more from Empower. Innovate. Transform.

Subscribe now to keep reading and get access to the full archive.

Continue reading