YouTube Icon

Code Playground.

How to Check the PostgreSQL Version

CFG

How to Check the PostgreSQL Version

PostgreSQL, regularly referred to just as Postgres, is an open-source universally useful item social information base administration framework. 

Comprehending what rendition of the PostgreSQL worker is introduced and running on your framework can be significant in certain circumstances. For instance, on the off chance that you are introducing an application that requires a particular PostgreSQL form, you'll have to discover the adaptation of your PostgreSQL worker. 

In this article, we'll disclose how to discover what variant of the PostgreSQL worker is running on your framework. 

PostgreSQL Versioning

PostgreSQL discharges are formed utilizing the accompanying plan: 

MAJOR.MINOR

For instance, in PostgreSQL 12.1, 12 is a significant variant, and 1 is a minor rendition. 

MAJOR - Starting with PostgreSQL 10, each new significant delivery builds the MAJOR aspect of the rendition by one, e.g., 10, 11 or 12. Prior to PostgreSQL 10, significant variants were spoken to with a decimal number e.g., 9.0 or 9.6. 

MINOR - Minor delivery number is the last aspect of the form number. For instance, 11.4 and 11.6 are minor forms that are important for the PostgreSQL rendition 11, and 9.6.15 and 9.6.16 are essential for the PostgreSQL adaptation 9.6. 

PostgreSQL significant deliveries with new highlights are normally conveyed once per year. Each significant delivery is upheld for a very long time. 

Using the Command Line

To discover what form of PostgreSQL is running on your framework, conjure the postgres order with the - variant or - V choice: 

postgres --version

The order will print the PostgreSQL rendition: 

postgres (PostgreSQL) 10.6

In this model, the variant of the PostgreSQL worker is 10.6. 

On the off chance that the postgres double isn't in framework's PATH , you'll get a mistake saying "postgres: order not found". This normally happens when the PostgreSQL bundle isn't introduced from the circulation's standard archives. 

You can discover the way to the double either with the find or discover order: 

sudo find /usr -wholename '*/bin/postgres'
sudo updatedb
locate bin/postgres

The yield should look something like this: 

/usr/lib/postgresql/9.6/bin/postgres

When you discover the way to the twofold, you can utilize it to get the form of the PostgreSQL worker: 

/usr/lib/postgresql/9.6/bin/postgres -V

The variant of the PostgreSQL customer utility, psql can be discovered utilizing the accompanying order: 

psql --version

The yield will look something like this: 

postgres (PostgreSQL) 10.6

psql is an intelligent order line utility that permits you to collaborate with the PostgreSQL worker. 

Using the SQL Shell

Another approach to decide the PostgreSQL worker form is to sign in to the worker SQL brief and utilize a SQL articulation to print out the rendition. 

You can get to the PostgreSQL shell utilizing a GUI customer like pgAdmin or with psql: 

sudo -u postgres psql

The accompanying articulation shows the PostgreSQL worker form alongside the assemble data: 

SELECT version();
                                                  version                                                   
------------------------------------------------------------------------------------------------------------
 PostgreSQL 10.6 on x86_64-redhat-linux-gnu, compiled by gcc (GCC) 8.2.1 20180905 (Red Hat 8.2.1-3), 64-bit
(1 row)

In the event that you need to get just the PostgreSQL worker adaptation number utilize the accompanying inquiry: 

SHOW server_version;
 server_version 
----------------
 10.6
(1 row)

Conclusion

In this article, we have told a few unique choices about the best way to discover the form of the PostgreSQL worker running on your framework. 

Don't hesitate to leave a remark on the off chance that you have any inquiries.




CFG