- Как проверить версию PostgreSQL
- Управление версиями PostgreSQL
- Использование командной строки
- Использование оболочки SQL
- Выводы
- Как узнать версию PostgreSQL в Ubuntu Linux
- Узнать версию PostgreSQL с помощью командной строки
- Использование SQL Shell
- Версия клиента PSQL
- Заключение
- How to View Which Postgres Version is Running
- Using the Shell Command Line
- Viewing the Server Version
- Viewing the Client Version
- Using SQL
- Viewing the Server Version
- Viewing the Client Version
- How to Check Which PostgreSQL Version is Running from CLI
- Using command line
- Using SQL Shell
- PSQL Client version
- Conclusion
- How to Check Your PostgreSQL Version
- Check PostgreSQL Version from Command Line
- How to Solve the “Command ‘postgres’ not found” Error
- Check Postgres Version from SQL Shell
- How to Check psql Client Version
Как проверить версию PostgreSQL
PostgreSQL, часто известный просто как Postgres, представляет собой универсальную объектно-реляционную систему управления базами данных с открытым исходным кодом.
В некоторых ситуациях важно знать, какая версия сервера PostgreSQL установлена и запущена в вашей системе. Например, если вы устанавливаете приложение, для которого требуется определенная версия PostgreSQL, вам необходимо узнать версию вашего сервера PostgreSQL.
В этой статье мы объясним, как узнать, какая версия сервера PostgreSQL работает в вашей системе.
Управление версиями PostgreSQL
Версии выпусков PostgreSQL контролируются по следующей схеме:
Например, в PostgreSQL 12.1 12 — это основная версия, а 1 — дополнительная версия.
MAJOR — Начиная с PostgreSQL 10, каждый новый основной выпуск увеличивает MAJOR часть версии на единицу, например, 10, 11 или 12. До PostgreSQL 10 основные версии представлялись десятичным числом, например 9.0 или 9.6.
MINOR — второстепенный номер выпуска — это последняя часть номера версии. Например, 11.4 и 11.6 являются второстепенными версиями, которые являются частью PostgreSQL версии 11, а 9.6.15 и 9.6.16 являются частью PostgreSQL версии 9.6.
Основные выпуски PostgreSQL с новыми функциями обычно выпускаются один раз в год. Каждый основной выпуск поддерживается в течение 5 лет.
Использование командной строки
Чтобы узнать, какая версия PostgreSQL работает в вашей системе, вызовите команду postgres с параметром —version или -V :
Команда выведет версию PostgreSQL:
В этом примере версия сервера PostgreSQL — 10.6 .
Если двоичный файл postgres отсутствует в системном PATH , вы получите сообщение об ошибке «postgres: команда не найдена». Обычно это происходит, когда пакет PostgreSQL не установлен из стандартных репозиториев дистрибутива.
Вы можете найти путь к двоичному файлу с помощью команды locate или find :
Результат должен выглядеть примерно так:
Найдя путь к двоичному файлу, вы можете использовать его для получения версии сервера PostgreSQL:
Версию клиентской утилиты PostgreSQL, psql можно найти с помощью следующей команды:
Результат будет выглядеть примерно так:
psql — это интерактивная утилита командной строки, которая позволяет вам взаимодействовать с сервером PostgreSQL.
Использование оболочки SQL
Другой способ определить версию сервера PostgreSQL — войти в запрос SQL сервера и использовать оператор SQL для печати версии.
Вы можете получить доступ к оболочке PostgreSQL с помощью клиента с графическим интерфейсом, например pgAdmin, или с помощью psql :
Следующий оператор отображает версию сервера PostgreSQL вместе с информацией о сборке:
Если вы хотите получить только номер версии сервера PostgreSQL, используйте следующий запрос:
Выводы
В этой статье мы показали несколько различных вариантов того, как найти версию сервера PostgreSQL, работающую в вашей системе.
Не стесняйтесь оставлять комментарии, если у вас есть вопросы.
Источник
Как узнать версию PostgreSQL в Ubuntu Linux
PostgreSQL — это система управления реляционными базами данных с открытым исходным кодом, которая обычно называется Postgres.
Администратору базы данных очень важно знать установленную версию Postgres в системе. Например, если вы разворачивайте приложение для которого требуется определенная версия Postgres, то вам может потребоваться выполнить поиск той же версии сервера PostgreSQL.
Существует множество способов узнать, какая версия сервера PostgreSQL установлена и запущена в вашей системе. В этой статье я объясню, как проверить ваш сервер PostgreSQL и клиент с помощью различных методов.
Если вы не знаете как установить PostgreSQL для Ubuntu, рекомендую эту статью к прочтению Установка PostgreSQL в Ubuntu.
Узнать версию PostgreSQL с помощью командной строки
Чтобы узнать запущенную версию PostgreSQL в вашей системе, откройте терминал и выполните команду postgres с параметром -V или -version:
Обе команды выдадут результат в виде:
В этом примере PostgreSQL имеет версию 12.5
Если двоичный файл postgres отсутствует в пути системы, тогда вы получите сообщение об ошибке «postgres: command not found». Чтобы обойти эту проблему, вам требуется найти двоичный каталог PostgreSQL. Введите следующую команду, чтобы найти двоичную папку PostgreSQL:
Полный путь к вашей двоичной папке postgresql отобразится в вашем терминале.
Путь к двоичной папке PostgreSQL
Введите полный путь и добавьте опцию –version или -V, после этого вы увидите текущую версию сервера PostgreSQL.
Обе команды выдадут результат в виде:
Отлично мы получили результат как и выше. PostgreSQL имеет версию 12.5
Использование SQL Shell
Версию Postgre так же можно узнать из командной строки самого PostgreSQL. Войдите в SQL запрос сервера и выполните SQL — команду для показа версии.
Введите следующую команду SQL, чтобы узнать установленную версию PostgreSQL:
В этом примере версия PostgreSQL так же как и в предыдущих примерах 12.5
Вы можете отобразить только версию сервера PostgreSQL, используя следующую инструкцию SQL.
Эта команда SQL выдаст следующие данные:
Версия PostgreSQL sever с использованием оператора SQL
Как можно увидеть из ответа сервера, запущена версия PostgreSQL 12.5
Версия клиента PSQL
psql — это терминальная интерактивная утилита командной строки, которая действует как интерфейс для PostgreSQL и позволяет вам взаимодействовать с сервером PostgreSQL. Для того чтоб узнать версию клиентской утилиты psql можно выполнить следующую команду:
Также вы можете запустить команду psql с опцией -V для показа версии клиентской утилиты psql.
Вы получите следующий результат в вашем терминале:
Версия клиента PostgreSQL psql
В этом примере утилита psql client Utility tool имеет версию 12.5
Заключение
Мы надеемся, что эта статья помогла Вам узнать версию PostgreSQL. Пожалуйста, не стесняйтесь оставляйте комментарии. Спасибо.
Источник
How to View Which Postgres Version is Running
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.
Using the Shell Command Line
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):
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:
Now with the direct path to the postgres utility, you can call it with the -V flag as illustrated above:
Viewing the Client Version
To view the client version, again simply pass the -V flag to the psql client utility command:
Similar to the above, if you cannot find the utility – or have multiple installations of PostgreSQL on that machine – you can easily locate psql :
Then issue a direct call to the located psql utility for the version:
Using SQL
It is also possible to determine the Postgres version from within a Postgres SQL prompt via a simple SQL statement.
Viewing the Server Version
To determine the server version using an SQL statement, simply issue the SELECT version(); command:
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 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.
Viewing the Client Version
In a similar vein, we can also issue a short SQL statement from a PostgreSQL prompt to query the client version of psql . However, it’s worth noting that this is purely for convenience, as we’re effectively just asking Postgres to issue a command on the shell prompt, but from within the PostgreSQL prompt itself.
This is performed by using the \! flag while connected to the client, followed by the statement we wish to issue:
Just as before when we were issuing this command directly from the shell prompt, psql -V may return your client version as above, or the path may not be found.
With that we’ve covered four simple yet effective ways to detect both the server and client versions of Postgres.
Источник
How to Check Which PostgreSQL Version is Running from CLI
PostgreSQL is an open-source relational database management system that is commonly known as Postgres.
As a system administrator as well as a database administrator, it is most important to know the installed and running version of Postgres in your system. For example, if you are deploying an application that requires a specific version of Postgres, you may need to search for the same version of PostgreSQL Server.
In this article, I will explain how to check your PostgreSQL version on server and client using different methods.
Using command line
To find the running PostgreSQL version on your system, access your terminal and execute command postgres with -V or —version option:
Both command will give output as:
In this example, the version of PostgreSQL is 12.5
If postgres binary file is not present in the system’s path you will get an error saying «postgres: command not found». To mitigate such problems you need to find the PostgreSQL binary directory. Enter the following command to locate the PostgreSQL binary folder:
The full path of your postgresql binary folder is displayed in your terminal.
PostgreSQL binary folder path
Type the full path and add —version or -V option to get the current PostgreSQL server version.
Both command will give output as:
In this example, Postgres version is 12.5.
Using SQL Shell
PostgreSQL version can be retrieved from PostgreSQL prompt. Log in into server SQL prompt and execute SQL command to print out the version.
Type following SQL command to check current PostgreSQL version:
Checking PostgreSQL version using SQL Shell
In this example, PostgreSQL version is 12.5
You can display only the PostgreSQL server version by using following SQL statement.
This SQL statement will print following output:
PostgreSQL sever version using SQL statement
In this example, running PostgreSQL version is 12.5
PSQL Client version
psql is a terminal-based interactive command-line utility tool that acts as a front-end to PostgreSQL which allows you to interact with the PostgreSQL server. You can run the following command to display the version of the psql client utility:
Also you can run psql command with -V option to print version of psql client utility.
You will get following output in your terminal:
PostgreSQL psql client version
In this example, the version of psql client utility tool is 12.5
Conclusion
We hope this article helped you to find the version of PostgreSQL in a different way. Please feel free to comment on us. Thank you.
Источник
How to Check Your PostgreSQL Version
Home » SysAdmin » How to Check Your PostgreSQL Version
New versions of PostgreSQL are released at regular intervals. Major releases are scheduled yearly and focus on improving key features and fixing known bugs. Minor releases are available approximately every three months and aim to resolve ongoing security concerns.
You might want to check if you have the latest security patch, or if the new software you want to implement is compatible with your PostgreSQL version.
This tutorial shows you how to check your PostgreSQL version using a few short commands.
Note: Have you considered installing SQL Workbench for Postgres? It’s a great tool for managing different database systems.
- Access to a terminal window/command line
- PostgreSQL database server
Check PostgreSQL Version from Command Line
Access your terminal and enter the following command to check your PostgreSQL version:
The version number is displayed in your terminal window. Another way to check your PostgreSQL version is to use the -V option:
These two commands work with installations initiated from official repositories. They might not be applicable for installations originating from third-party sources. Instead, you might receive the “Command ‘postgres’ not found” message.
How to Solve the “Command ‘postgres’ not found” Error
To solve the “Command ‘postgres’ not found” issue, locate the PostgreSQL binary folder. Enter the following command to locate the correct postgres path:
The path to your binary folder is now displayed in your terminal.
Type the full path and add the -V option to display the current PostgreSQL server version:
In this example, the Postgres version number is 10.12.
The PostgreSQL Development Group uses a standard MAJOR.MINOR semantic versioning system. In our example, the first section (10) signifies the MAJOR release number. The second part (12), represents the MINOR release number for that major version.
Note: Always update PostgreSQL to the latest available minor version that corresponds to the major version you have installed.
Check Postgres Version from SQL Shell
The version number can also be retrieved directly from the PostgreSQL prompt. Access the PostgreSQL shell prompt by typing the following command:
Type the following SQL statement within the prompt to check the current version:
The resulting output provides the full version and system information for the PostgreSQL server.
You can also instruct PostgreSQL to show the value associated with the server_version parameter:
The result displays the current value for server_version.
How to Check psql Client Version
Psql functions as a front-end terminal for PostgreSQL. It’s used to issue queries and display the provided results.
You can use the following command to determine the version of the psql client utility:
You’ll notice that the commands used to check the psql client version match the commands used to determine PostgreSQL server version. The -V option works in this instance as well:
The psql version is presented in the terminal.
The “Command not found” error can appear in this instance as well. If that is the case, enter the following command to locate the correct path to the psql utility:
The output provides the full path to the psql utility.
Use the resulting path and -V option to check the current psql version:
The resulting output shows you the current psql client version on your system.
Note: If you are in need of more PostgreSQL tutorials, be sure to check out:
The provided commands and SQL statements are the most effective way to determine the PostgreSQL version number. Use them to check the current version of your PostgreSQL database server or psql client utility.
Make sure that your systems are always up to date with the latest available version.
Источник