我正在运行哪个版本的PostgreSQL?

本文翻译自:Which version of PostgreSQL am I running?

I'm in a corporate environment (running Debian Linux) and didn't install it myself. 我在公司环境中(运行Debian Linux)并没有自己安装它。 I access the databases using Navicat or phpPgAdmin (if that helps). 我使用Navicat或phpPgAdmin访问数据库(如果有帮助的话)。 I also don't have shell access to the server running the database. 我也没有shell访问运行数据库的服务器。


#1楼

参考:https://stackoom.com/question/vclb/我正在运行哪个版本的PostgreSQL


#2楼

从PostgreSQL运行此查询:

SELECT version();

#3楼

I believe this is what you are looking for, 我相信这就是你要找的东西,

Server version: 服务器版本:

pg_config --version

Client version: 客户版本:

psql --version

#4楼

If Select version() returns with Memo try using the command this way: 如果Select version()返回Memo,请尝试使用以下命令:

Select version::char(100) 

or 要么

Select version::varchar(100)

#5楼

Using CLI: 使用CLI:

Server version: 服务器版本:

$ postgres -V  # Or --version.  Use "locate bin/postgres" if not found.
postgres (PostgreSQL) 9.6.1
$ postgres -V | awk '{print $NF}'  # Last column is version.
9.6.1
$ postgres -V | egrep -o '[0-9]{1,}\.[0-9]{1,}'  # Major.Minor version
9.6

If having more than one installation of PostgreSQL, or if getting the " postgres: command not found " error: 如果有多个PostgreSQL安装,或者如果收到“ postgres: command not found ”错误:

$ locate bin/postgres | xargs -i xargs -t '{}' -V  # xargs is intentionally twice.
/usr/pgsql-9.3/bin/postgres -V 
postgres (PostgreSQL) 9.3.5
/usr/pgsql-9.6/bin/postgres -V 
postgres (PostgreSQL) 9.6.1

If locate doesn't help, try find : 如果locate帮助,请尝试find

$ sudo find / -wholename '*/bin/postgres' 2>&- | xargs -i xargs -t '{}' -V  # xargs is intentionally twice.
/usr/pgsql-9.6/bin/postgres -V 
postgres (PostgreSQL) 9.6.1

Although postmaster can also be used instead of postgres , using postgres is preferable because postmaster is a deprecated alias of postgres . 虽然也可以使用postmaster而不是postgres ,但是使用postgres更好,因为postmasterpostgres一个弃用别名。

Client version: 客户版本:

As relevant, login as postgres . 相关,请postgres身份登录

$ psql -V  # Or --version
psql (PostgreSQL) 9.6.1

If having more than one installation of PostgreSQL: 如果有多个PostgreSQL安装:

$ locate bin/psql | xargs -i xargs -t '{}' -V  # xargs is intentionally twice.
/usr/bin/psql -V 
psql (PostgreSQL) 9.3.5
/usr/pgsql-9.2/bin/psql -V 
psql (PostgreSQL) 9.2.9
/usr/pgsql-9.3/bin/psql -V 
psql (PostgreSQL) 9.3.5

Using SQL: 使用SQL:

Server version: 服务器版本:

=> SELECT version();
                                                   version                                                    
--------------------------------------------------------------------------------------------------------------
 PostgreSQL 9.2.9 on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-4), 64-bit

=> SHOW server_version;
 server_version 
----------------
 9.2.9

=> SHOW server_version_num;
 server_version_num 
--------------------
 90209

If more curious, try => SHOW all; 如果更好奇,试试=> SHOW all; .

Client version: 客户版本:

For what it's worth, a shell command can be executed within psql to show the client version of the psql executable in the path. 对于它的价值,可以在psql执行shell命令,以在路径中显示psql可执行文件的客户端版本。 Note that the running psql can potentially be different from the one in the path. 请注意,正在运行的psql可能与路径中的psql不同。

=> \! psql -V
psql (PostgreSQL) 9.2.9

#6楼

In my case 就我而言

$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)

Hope it will help someone 希望它会帮助某人

发布了0 篇原创文章 · 获赞 3 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/p15097962069/article/details/105328372