.sql
Send an arbitrary SQL command.
Synopsis
.sql query=<query> [catalog=<catalog>]
Words without brackets are required, [ ] marks optional parts, a | b alternatives, ... a repeatable argument and [,...] a comma separated list.
Description
Sends an arbitrary SQL statement to the catalog database and prints the result. The WebUI and scripts use it for evaluations no other command provides. The statement is executed without any check: UPDATE, DELETE or DROP change the catalog permanently, so use plain SELECT statements for reading.
If the text holds several statements separated by semicolons, all of them are executed but only the result of the last one is shown. Database errors are passed through as “Query failed: …”. In API mode 0 the result is a framed table, in mode 1 the cells are tab-separated on a single line, in mode 2 the rows are objects under “query” with all values as strings.
Arguments
| Argument | Type | Values / source | Default | Flags | Description |
|---|---|---|---|---|---|
query= | string | required | SQL statement. | ||
catalog= | resource | from .catalogs | Catalog name. |
Examples
Ids and names of all pools:
.sql query="SELECT poolid, name FROM pool"
Number of failed jobs in the catalog MyCatalog:
.sql query="SELECT count(*) FROM job WHERE jobstatus = 'E'" catalog=MyCatalog