How to check postgresql version
How to check postgresql version
How to Check PostgreSQL Version
Major Version of PostgreSQL
Earlier, its major version was represented as a decimal number, e.g., 9.6 or 9.0. After PostgreSQL 10, the central part of the version increased by one number for major release versions, e.g., 10, 11, 12, etc.
Minor Version of PostgreSQL
The last part number of the version shows the minor release number. E.g., 10.4 or 10.6 are minor versions of PostgreSQL version 10. In the past, Version 13.3 of PostgreSQL has been available for installation. We will explore different methods to check PostgreSQL’s version in this tutorial.
How to Check PostgreSQL Version
You can check the PostgreSQL version in several ways. Here, we will understand all the methods and see how you can check the version of PostgreSQL in your system.
Check the PostgreSQL Version Using Command-Line
You can check the current PostgreSQL version running on your system with the help of the command line. You can do this by accessing the terminal and running the following command:
You can run any of the previous commands and check the PostgreSQL version. Both the commands will provide you with the same output.
You get an error of “Postgres: command not found” if the Postgres binary is not present in the path to the file system. Let us troubleshoot this problem by searching the PostgreSQL binary directory. Run the following command in a terminal window:
With this command, you can see the full path to the PostgreSQL binary folder in your terminal. Type the full path to find out what version of PostgreSQL you have:
Both these commands will provide you with the same output.
Check the PostgreSQL Version Using SQL Shell
You can retrieve the PostgreSQL version through the PostgreSQL prompt. PostgreSQL versions are displayed on the post-login screen after logging into the PostgreSQL server through the terminal.
The server should log into the SQL prompt and get its output by executing the SQL command.
Through Parameters
You can check the PostgreSQL version by preset parameter. Automatic version checking is also possible using the following method:
Through version() Function
By executing version(), you can also determine the PostgreSQL version. You can also check the PostgreSQL version in the automation script.
Check the PostgreSQL Version PSQL Client Version
Apart from being a PostgreSQL client, psql is also a terminal-based command-line utility. Psql gives users access to PostgreSQL databases. Version information for the psql client utility can be found using the following command:
The previous commands will provide you with the same output to use by anyone.
Postgres Version in pgAdmin4
The pgAdmin4 web interface is an excellent way to manage PostgreSQL servers. The web interface shows the Postgres version for the pgAdmin4 users. To find out the PostgreSQL version, follow these steps:
Conclusion
In this tutorial, we’ve discussed several methods to check the PostgreSQL version and see how easy it is to check each version. We hope that through this article, you have understood all the methods, and you will have learned to check the version of PostgreSQL by each method. Check the other Linux Hint articles for more tips and tutorials.
About the author
Prateek Jangid
A passionate Linux user for personal and professional reasons, always exploring what is new in the world of Linux and sharing with my readers.
How to Check Your PostgreSQL Version
Home » SysAdmin » How to Check Your PostgreSQL Version
New versions of PostgreSQL are released at regular intervals. Major releases are scheduled yearly and focus on improving key features and fixing known bugs. Minor releases are available approximately every three months and aim to resolve ongoing security concerns.
You might want to check if you have the latest security patch, or if the new software you want to implement is compatible with your PostgreSQL version.
This tutorial shows you how to check your PostgreSQL version using a few short commands.
Note: Have you considered installing SQL Workbench for Postgres? It’s a great tool for managing different database systems.
Check PostgreSQL Version from Command Line
Access your terminal and enter the following command to check your PostgreSQL version:
The version number is displayed in your terminal window. Another way to check your PostgreSQL version is to use the -V option:
These two commands work with installations initiated from official repositories. They might not be applicable for installations originating from third-party sources. Instead, you might receive the “Command ‘postgres’ not found” message.
How to Solve the “Command ‘postgres’ not found” Error
To solve the “Command ‘postgres’ not found” issue, locate the PostgreSQL binary folder. Enter the following command to locate the correct postgres path:
The path to your binary folder is now displayed in your terminal.
Type the full path and add the -V option to display the current PostgreSQL server version:
In this example, the Postgres version number is 10.12.
The PostgreSQL Development Group uses a standard MAJOR.MINOR semantic versioning system. In our example, the first section (10) signifies the MAJOR release number. The second part (12), represents the MINOR release number for that major version.
Note: Always update PostgreSQL to the latest available minor version that corresponds to the major version you have installed.
Check Postgres Version from SQL Shell
The version number can also be retrieved directly from the PostgreSQL prompt. Access the PostgreSQL shell prompt by typing the following command:
Type the following SQL statement within the prompt to check the current version:
The resulting output provides the full version and system information for the PostgreSQL server.
You can also instruct PostgreSQL to show the value associated with the server_version parameter:
The result displays the current value for server_version.
How to Check psql Client Version
Psql functions as a front-end terminal for PostgreSQL. It’s used to issue queries and display the provided results.
You can use the following command to determine the version of the psql client utility:
You’ll notice that the commands used to check the psql client version match the commands used to determine PostgreSQL server version. The -V option works in this instance as well:
The psql version is presented in the terminal.
The “Command not found” error can appear in this instance as well. If that is the case, enter the following command to locate the correct path to the psql utility:
The output provides the full path to the psql utility.
Use the resulting path and -V option to check the current psql version:
The resulting output shows you the current psql client version on your system.
Note: If you are in need of more PostgreSQL tutorials, be sure to check out:
The provided commands and SQL statements are the most effective way to determine the PostgreSQL version number. Use them to check the current version of your PostgreSQL database server or psql client utility.
Make sure that your systems are always up to date with the latest available version.
How to View Which Postgres Version is Running
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
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:
Viewing the Client Version
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.
Alternatively, you can query for the specific server version, in the standard major.minor.patch format, by using the SHOW command:
Viewing the Client Version
This is performed by using the \! flag while connected to the client, followed by the statement we wish to issue:
With that we’ve covered four simple yet effective ways to detect both the server and client versions of Postgres.
How to Check the PostgreSQL Version
PostgreSQL is an advanced, open-source relational database management system. It is written in C programming language and was developed at the University of California, Berkeley in 1996. Initially, version 1.0 of Postgres95 was announced on September 5, 1995. The first non-university version of PostgreSQL was provided on July 8, 1996, by Marc Fournier at Hub.org Networking Services. Which is the first version of PostgreSQL for public use.
As of today, PostgreSQL 13.3 is the latest stable version available for installation. PostgreSQL version 9.5 and lower versions are no more supported by the team.
In this tutorial, you will learn, how to check the PostgreSQL version on your system.
How to Find PostgreSQL Version using Command line
Use one of the following methods to check the PostgreSQL version via the command line.
Check Version with Login
Once you login to the PostgreSQL server via terminal, The post login screen displays the PostgreSQL version you have connected to.
The above output displays, that you are running version 13.3 of PostgreSQL server.
Check Version with version() Function
You can also execute version() function to find out the PostgreSQL version. This method can also help you to check PostgreSQL version in automation scripts.
Check Version with Parameters
Alternatively, you can also find the PostgreSQL version by the preset parameters, and you can also use this method for automatic version checks.
Check the below screenshot for all commands in action to check the Postgres version on command line.
How to Find Postgres Version in pgAdmin4
pgAdmin4 is an excellent web interface for managing the PostgreSQL servers. So the pgAdmin4 users can also find the Postgres version on the web interface.
To get the version, follow:
Conclusion
In this tutorial, you have learned 3 methods to check the PostgreSQL version via the command line. Also provided the steps to find version in pgAdmin4.
How to Check Which PostgreSQL Version is Running from CLI
PostgreSQL is an open-source relational database management system that is commonly known as Postgres.
As a system administrator as well as a database administrator, it is most important to know the installed and running version of Postgres in your system. For example, if you are deploying an application that requires a specific version of Postgres, you may need to search for the same version of PostgreSQL Server.
In this article, I will explain how to check your PostgreSQL version on server and client using different methods.
Using command line
Both command will give output as:
In this example, the version of PostgreSQL is 12.5
If postgres binary file is not present in the system’s path you will get an error saying «postgres: command not found». To mitigate such problems you need to find the PostgreSQL binary directory. Enter the following command to locate the PostgreSQL binary folder:
The full path of your postgresql binary folder is displayed in your terminal.
PostgreSQL binary folder path
Both command will give output as:
In this example, Postgres version is 12.5.
Using SQL Shell
PostgreSQL version can be retrieved from PostgreSQL prompt. Log in into server SQL prompt and execute SQL command to print out the version.
Type following SQL command to check current PostgreSQL version:
Checking PostgreSQL version using SQL Shell
In this example, PostgreSQL version is 12.5
You can display only the PostgreSQL server version by using following SQL statement.
This SQL statement will print following output:
PostgreSQL sever version using SQL statement
In this example, running PostgreSQL version is 12.5
PSQL Client version
psql is a terminal-based interactive command-line utility tool that acts as a front-end to PostgreSQL which allows you to interact with the PostgreSQL server. You can run the following command to display the version of the psql client utility:
You will get following output in your terminal:
PostgreSQL psql client version
In this example, the version of psql client utility tool is 12.5
Conclusion
We hope this article helped you to find the version of PostgreSQL in a different way. Please feel free to comment on us. Thank you.