PostgreSQL – Get Database Version

To get the version of your PostgreSQL database, you can use the SQL query below when connected to the database:

SELECT version();

When you run this query, it will return a result similar to the following:

PostgreSQL x.x.x on x86_64-pc-linux-gnu, compiled by ...

In the result, “x.x.x” represents the PostgreSQL version number. It also provides information about the platform and compilation details.

Alternatively, you can use the pg_version system view to retrieve version information programmatically:

SELECT version_num, version() AS full_version FROM pg_catalog.pg_version;

This query will return the version number in a structured format as well as the full version string.

Similar Posts