PostgreSQL: Which version of PostgreSQL am I running?

后端 未结 16 853
迷失自我
迷失自我 2020-12-02 03:22

I\'m in a corporate environment (running Debian Linux) and didn\'t install it myself. I access the databases using Navicat or phpPgAdmin (if that helps). I also don\'t have

16条回答
  •  时光取名叫无心
    2020-12-02 04:04

    The accepted answer is great, but if you need to interact programmatically with PostgreSQL version maybe it's better to do:

    SELECT current_setting('server_version_num'); -- Returns 90603 (9.6.3)
    -- Or using SHOW command:
    SHOW server_version_num; -- Returns 90603 too
    

    It will return server version as an integer. This is how server version is tested in PostgreSQL source, e.g.:

    /*
     * This is a C code from pg_dump source.
     * It will do something if PostgreSQL remote version (server) is lower than 9.1.0
     */
    if (fout->remoteVersion < 90100)
        /*
         * Do something...
         */  
    

    More info here and here.

提交回复
热议问题