Viewing which version (or versions) of PostgreSQL is active on your system is a reasonably simple process, but there are a number of methods that can be used. In this tutorial we’ll briefly explore four methods for finding your version of PostgreSQL, including both the client and the server versions.
Note: As per usual when working with PostgreSQL, be sure you are logged into your shell prompt from a non-root user with Postgres privileges for these commands to function properly.
Using the Shell Command Line
Both the server and client Postgres installations can be queried using their respective command line utilities.
Viewing the Server Version
Execute the installation: $ sudo rpm -Uvh./dbeaver-ce-latest-stable.x8664.rpm. Now, find the launcher for DBeaver and hit it: DBeaver launcher. If you want, DBeaver can create a test database for you to begin exploring it. Otherwise, you can connect it to your own database and continue from there. I see the admin login page and all is well: I would like to connect to this postgres db via DBeaver sql client but am unable to, the connection just times out. Here’s my set up: Dockerfile: FROM postgres:latest. Docker-compose file: version: '3.1' services: db: build: context:. Dockerfile: Postgres/Dockerfile image: postgres restart: always.
To find the Postgres server version from the shell command line, simply issue a postgres
command with the -V
flag (for version):
In the event that the postgres
command is not found, you may need to locate the directory of the utility. This can be done by issuing the locate bin/postgres
command:
Now with the direct path to the postgres
utility, you can call it with the -V
flag as illustrated above:
Dbeaver Check Postgresql Version Download
Viewing the Client Version
To view the client version, again simply pass the -V
flag to the psql
client utility command:
Similar to the above, if you cannot find the utility – or have multiple installations of PostgreSQL on that machine – you can easily locate psql
:
Then issue a direct call to the located psql
utility for the version:
Using SQL
It is also possible to determine the Postgres version from within a Postgres SQL prompt via a simple SQL statement.
Viewing the Server Version
To determine the server version using an SQL statement, simply issue the SELECT version();
command:
You’ll see the full version output information as seen in the example above.
Dbeaver Check Postgresql Version Code
Alternatively, you can query for the specific server version, in the standard major.minor.patch
format, by using the SHOW
command:
Dbeaver Check Postgresql Version Free
SHOW
is used to display current run-time parameters, which are essentially just a table of name/setting
pairs. By issuing the SHOW server_version;
statement above, we’re asking Postgres to retrieve the current parameter value of server_version
, which of course is the version of PostgreSQL currently running.
Viewing the Client Version
In a similar vein, we can also issue a short SQL statement from a PostgreSQL prompt to query the client version of psql
. However, it’s worth noting that this is purely for convenience, as we’re effectively just asking Postgres to issue a command on the shell prompt, but from within the PostgreSQL prompt itself.
This is performed by using the !
flag while connected to the client, followed by the statement we wish to issue:
Just as before when we were issuing this command directly from the shell prompt, psql -V
may return your client version as above, or the path may not be found.
Dbeaver Check Postgresql Version Online
With that we’ve covered four simple yet effective ways to detect both the server and client versions of Postgres.