Regla de Jira Automation cuando se fusiona una solicitud de incorporación de cambios
Posted by: AJ Welch
Viewing which version (or versions) of PostgreSQL is active on your system is a reasonably simple process, but there are a number of methods that can be used. In this tutorial we’ll briefly explore four methods for finding your version of PostgreSQL, including both the client and the server versions.
Note: As per usual when working with PostgreSQL, be sure you are logged into your shell prompt from a non-root user with Postgres privileges for these commands to function properly.
Más allá de la metodología ágil
Both the server and client Postgres installations can be queried using their respective command line utilities.
Viewing the server version
To find the Postgres server version from the shell command line, simply issue a postgres
command with the -V
flag (for version):
$ postgres -V
postgres (PostgreSQL) 9.3.10
In the event that the postgres
command is not found, you may need to locate the directory of the utility. This can be done by issuing the locate bin/postgres
command:
$ locate bin/postgres
/usr/lib/postgresql/9.3/bin/postgres
Now with the direct path to the postgres
utility, you can call it with the -V
flag as illustrated above:
$ /usr/lib/postgresql/9.3/bin/postgres -V
postgres (PostgreSQL) 9.3.10
Viewing the client version
To view the client version, again simply pass the -V
flag to the psql
client utility command:
$ psql -V
psql (PostgreSQL) 9.3.10
Similar to the above, if you cannot find the utility – or have multiple installations of PostgreSQL on that machine – you can easily locate psql
:
$ locate bin/psql
/usr/bin/psql
/usr/lib/postgresql/9.3/bin/psql
Then issue a direct call to the located psql
utility for the version:
$ /usr/lib/postgresql/9.3/bin/psql -V
psql (PostgreSQL) 9.3.10
Más allá de la metodología ágil
It is also possible to determine the Postgres version from within a Postgres SQL prompt via a simple SQL statement.
$ mysql --user=username
Viewing the server version
To determine the server version using an SQL statement, simply issue the SELECT version();
command:
=# SELECT version();
version
------------------------------------------------------------------------------------------------------
PostgreSQL 9.3.10 on x86_64-unknown-linux-gnu, compiled by gcc (Ubuntu 4.8.2-19ubuntu1) 4.8.2, 64-bit
(1 row)
You’ll see the full version output information as seen in the example above.
Alternatively, you can query for the specific server version, in the standard major.minor.patch
format, by using the SHOW command:
=# SHOW server_version;
server_version
----------------
9.3.10
(1 row)
SHOW
is used to display current run-time parameters, which are essentially just a table of name/setting
pairs. By issuing the SHOW server_version;
statement above, we’re asking Postgres to retrieve the current parameter value of server_version
, which of course is the version of PostgreSQL currently running.