我在一个企业环境中(运行Debian Linux),没有自己安装它。我使用Navicat或phpPgAdmin访问数据库(如果有帮助的话)。我也没有运行数据库的服务器的shell访问权。


当前回答

在shell psql.exe中执行

\! psql -V

其他回答

对我来说

$psql
postgres=# \g
postgres=# SELECT version();
                                                       version
---------------------------------------------------------------------------------------------------------------------
 PostgreSQL 8.4.21 on x86_64-pc-linux-gnu, compiled by GCC gcc-4.6.real (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3, 64-bit
(1 row)

希望它能帮助到一些人

使用pgadmin4,双击Servers > server_name_here > Properties选项卡> Version:

3.5版本:

4.1、4.5版本:

不知道这有多可靠,但你可以自动获得两个版本令牌:

psql --version 2>&1 | tail -1 | awk '{print $3}' | sed 's/\./ /g' | awk '{print $1 "." $2}'

所以你可以构建到二进制文件的路径:

/usr/lib/postgresql/9.2/bin/postgres

只需将9.2替换为此命令。

使用命令行 服务器:

postgres -V

客户:

psql -V

登录postgres,然后:

postgres=# select version();

或者来自cli:

psql -c "SELECT version();"

使用VERSION特殊变量 以postgres用户登录:

sudo su - postgres

然后:

psql -c "\echo :VERSION"

请查看这里的指南以获得完整的解释

在shell psql.exe中执行

\! psql -V