how to check postgresql version

How to Check PostgreSQL version

Sometimes you may need to find PostgreSQL version to determine if a specific command or feature is supported in it. In this article, we will look at the different ways to check PostgreSQL version.

How to Check PostgreSQL version

Here are the steps to check PostgreSQL version. You can find PostgreSQL version for both database server and client, via Shell command as well as SQL queries. We will look at each of these approaches one by one.

Find out PostgreSQL version using Shell Command

You can get PostgreSQL version for Server from terminal/command line by simply issuing postgres command with -V option.

$ postgres -V
Postgres (PostgreSQL) 10.3.10

If postgres command is not directly supported, find the path of its binary using locate command

$ locate bin/postgres

Now use the full path with -V option to get its version.

$ /usr/lib/postgresql/10.3/bin/postgres -V
Postgres (PostgreSQL) 10.3.10

Also read : How to Change User to Superuser in PostgreSQL

Similarly, you can determine the PostgreSQL client version using psql command with -V option.

$ psql -V
psql (PostgreSQL) 10.3.10

Again, if psql command is not supported, use locate command to find out the path of its binary.

$ locate bin/psql

Now run the full path with -V option

$ /usr/bin/psql -V
psql (PostgreSQL) 10.3.10

By the way, when you log into PostgreSQL shell, it automatically displays the client version above the prompt.

Also Read : How to Limit Access to Database in PostgreSQL

Find PostgreSQL version using SQL

You can also find PostgreSQL version using SQL queries. Here are two SQL queries to get PostgreSQL version. One uses version() function while the other uses server_version system variable.

-# SELECT version();
PostgreSQL 10.3.10, compiled by Visual C++ build 1800, 64-bit


-# SHOW server_version;

Also read : How to Set up remote connection in PostgreSQL

Similarly, you can also view PostgreSQL client version using psql query as shown below.

=# \! psql -V 
psql (PostgreSQL) 10.3.10

We have provided four ways to get PostgreSQL version, for both server as well as client. Hope it helps.

Ubiq makes it easy to visualize data, and monitor them in real-time dashboards. Try Ubiq for free.


About Ubiq

Ubiq is a powerful dashboard & reporting platform. Build dashboards, charts & reports for your business in minutes. Try it for free!