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:
Or
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:
Or
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:
Or
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:
- Login to the pgAdmin4.
- Select your Postgres server by expanding servers in the left sidebar.
- Now, go to the properties tab.
- The last step is to check the PostgreSQL version under the general section.
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.