229

How can I find out which version of PostGIS I have?

Jason Swett
  • 43,526
  • 67
  • 220
  • 351

7 Answers7

351

Since some of the functions depend on other libraries like GEOS and proj4 you might want to get their versions too. Then use:

SELECT PostGIS_full_version();
Brad Koch
  • 19,267
  • 19
  • 110
  • 137
Nicklas Avén
  • 4,706
  • 1
  • 18
  • 15
35

Did you try using SELECT PostGIS_version();

juliomalegria
  • 24,229
  • 14
  • 73
  • 89
Jon Conley
  • 451
  • 3
  • 4
  • 10
    Caution: `PostGIS_version()` outputs the major and minor version (e.g., "2.1"), but not the revision number (e.g., "2.1.4"), like `PostGIS_full_version()` and `PostGIS_Lib_Version()` do. – Sean the Bean Jan 26 '15 at 17:59
16

PostGIS_Lib_Version(); - returns the version number of the PostGIS library.

http://postgis.refractions.net/docs/PostGIS_Lib_Version.html

andrewsi
  • 10,807
  • 132
  • 35
  • 51
tino
  • 221
  • 3
  • 4
12

As the above people stated, select PostGIS_full_version(); will answer your question. On my machine, where I'm running PostGIS 2.0 from trunk, I get the following output:

postgres=# select PostGIS_full_version();
postgis_full_version                                                                  
-------------------------------------------------------------------------------------------------------------------------------------------------------
POSTGIS="2.0.0alpha4SVN" GEOS="3.3.2-CAPI-1.7.2" PROJ="Rel. 4.7.1, 23 September 2009" GDAL="GDAL 1.8.1, released 2011/07/09" LIBXML="2.7.3" USE_STATS
(1 row)

You do need to care about the versions of PROJ and GEOS that are included if you didn't install an all-inclusive package - in particular, there's some brokenness in GEOS prior to 3.3.2 (as noted in the postgis 2.0 manual) in dealing with geometry validity.

Pete Clark
  • 584
  • 4
  • 8
10

Other way to get the minor version is:

SELECT extversion
FROM pg_catalog.pg_extension
WHERE extname='postgis'
Matias Barone
  • 168
  • 1
  • 8
  • The above methods gave me `No function matches the given name and argument types. You might need to add explicit type casts.` but this one worked. The problem with the above not working was fixed by doing the `CREATE EXTENSION Postgis` from the console rather than from the db-migrate.js – Eric Darchis Sep 16 '16 at 09:55
2

Using SELECT PostGIS_version();

Leo
  • 121
  • 1
  • 5
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – lemon May 23 '22 at 11:00
1

Using: SELECT PostGIS_full_version();

Viettel Solutions
  • 1,519
  • 11
  • 22