Use ADCM to run SQL

You can use the ADCM UI to execute SQL queries.

Execute an SQL query

To execute a query, open the CLUSTERS → ADPG cluster → Services tab. Click green arrow in the Actions column to display a list of possible actions. Select the Run SQL action. The Run SQL action executes SQL queries on behalf of the postgres superuser.

adcm run sql action
Select the Run SQL action

In the opened form, specify the required database name in the Database for query field and an SQL query in the SQL query field.

run sql form
The Run SQL action form

In the image above, the SQL query adds Leo Tolstoy to the author table and information about his book — "War and Peace" to the book table. The author and book tables belong to the test books_store database, the creation of which is described in the following article: Example of working with tables via psql.

View the result

To see the SQL query result, open the JOBS tab and click the Run SQL action name.

job tab
The JOBS tab with action results

In the opened form, expand the Result SQL query item. SQL query and its result are displayed.

sql query result
The SQL query result

The query result contains SQL query,rc, stdout, and stderr fields described in the table below.

Query result fields
Field name Description

SQL query

SQL query text


Contains the psql exit status:

  • 0 — the command is executed successfully without any errors.

  • 1 — a psql fatal error occurs (e.g., out of memory, file not found).

  • 2 — the connection to the server is bad and the session is not interactive.

  • 3 — an error occurs in a script and the ON_ERROR_STOP variable is set.


Contains the psql output with the query result


Contains an error message if an error occurs during the query execution

Found a mistake? Seleсt text and press Ctrl+Enter to report it