어떤 버전의 PostgreSQL을 실행하고 있습니까?
회사 환경 (Debian Linux 실행)에 있으며 직접 설치하지 않았습니다. Navicat 또는 phpPgAdmin을 사용하여 데이터베이스에 액세스합니다 (도움이되는 경우). 또한 데이터베이스를 실행하는 서버에 대한 셸 액세스 권한이 없습니다.
PostgreSQL에서이 쿼리를 실행합니다.
SELECT version();
나는 이것이 당신이 찾고있는 것이라고 믿습니다.
서버 버전 :
pg_config --version
클라이언트 버전 :
psql --version
CLI 사용 :
서버 버전 :
$ 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
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
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
postmaster
대신을 사용할 수도 있지만 은 더 이상 사용되지 않는 별칭 이므로 postgres
사용하는 postgres
것이 좋습니다 .postmaster
postgres
클라이언트 버전 :
관련이 있으면로 로그인하십시오postgres
.
$ psql -V # Or --version
psql (PostgreSQL) 9.6.1
둘 이상의 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
SQL 사용 :
서버 버전 :
=> 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;
.
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. Note that the running psql
can potentially be different from the one in the path.
=> \! psql -V
psql (PostgreSQL) 9.2.9
If you're using CLI and you're a postgres
user, then you can do this:
psql -c "SELECT version();"
Possible output:
version
-------------------------------------------------------------------------------------------------------------------------
PostgreSQL 11.1 (Debian 11.1-3.pgdg80+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 4.9.2-10+deb8u2) 4.9.2, 64-bit
(1 row)
Execute command
psql -V
Where
V must be in capital.
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...
*/
in shell psql.exe , execute
\! psql -V
Using pgadmin4
it can be seen by double clicking Servers > server_name_here > Properties tab > Version:
Version 3.5:
Version 4.1, 4.5:
A simple way is to check the version by typing psql --version
in terminal
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
The pg_config command will report the directory where the PostgreSQL programs are installed (--bindir), the location of C include files (--includedir) and object code libraries (--libdir), and the version of PostgreSQL (--version):
$ pg_config --version
PostgreSQL 9.3.6
If you have shell access to the server (the question mentions op does not have, but in case you have,) on a debian/ubuntu system
sudo apt-cache policy postgresql
which will output the installed version,
postgresql:
Installed: 9.6+184ubuntu1.1
Candidate: 9.6+184ubuntu1.1
Version table:
*** 9.6+184ubuntu1.1 500
500 http://in.archive.ubuntu.com/ubuntu artful-updates/main amd64 Packages
500 http://in.archive.ubuntu.com/ubuntu artful-updates/main i386 Packages
500 http://security.ubuntu.com/ubuntu artful-security/main amd64 Packages
500 http://security.ubuntu.com/ubuntu artful-security/main i386 Packages
100 /var/lib/dpkg/status
9.6+184ubuntu1 500
500 http://in.archive.ubuntu.com/ubuntu artful/main amd64 Packages
500 http://in.archive.ubuntu.com/ubuntu artful/main i386 Packages
where the Installed: <version>
is the installed postgres package version.
Don’t know how reliable this is, but you can get two tokens of version fully automatically:
psql --version 2>&1 | tail -1 | awk '{print $3}' | sed 's/\./ /g' | awk '{print $1 "." $2}'
So you can build paths to binaries:
/usr/lib/postgresql/9.2/bin/postgres
Just replace 9.2 with this command.
If Select version()
returns with Memo try using the command this way:
Select version::char(100)
or
Select version::varchar(100)
참고URL : https://stackoverflow.com/questions/13733719/which-version-of-postgresql-am-i-running
'developer tip' 카테고리의 다른 글
easy_install보다 pip를 사용하는 이유는 무엇입니까? (0) | 2020.09.28 |
---|---|
글로벌 Git 구성을 어떻게 표시합니까? (0) | 2020.09.28 |
Mac OS X에서 PostgreSQL 서버를 시작하는 방법은 무엇입니까? (0) | 2020.09.28 |
파이썬에서 XML을 어떻게 구문 분석합니까? (0) | 2020.09.28 |
JavaScript로 어떻게 리디렉션합니까? (0) | 2020.09.28 |