Running a query
You can use the table query execute
subcommand to run single ad-hoc queries of certain types, for the purposes of testing and troubleshooting.
General format of the command:
ydb [global options...] table query execute [options...]
global options
: Global parameters.options
: Parameters of the subcommand.
View the description of the YQL query command:
ydb table query execute --help
Parameters of the subcommand
Name | Description |
---|---|
--timeout |
The time within which the operation should be completed on the server. |
-t , --type |
Query type. Acceptable values:
data . |
--stats |
Statistics mode. Acceptable values:
none . |
-s |
Enable statistics collection in the basic mode. |
--tx-mode |
Specify the transaction mode (for data queries).Acceptable values:
serializable-rw . |
-q , --query |
Text of the YQL query to be executed. |
-f, --file |
Path to the text of the YQL query to be executed. |
-p , --param |
Query parameters (for data queries and scan queries). You can specify multiple parameters. To change the input format, use the --input-format subcommand parameter. |
--input-format |
Input format. Acceptable values: |
--format |
Input format. Default value: pretty .Acceptable values:
|
Examples
Note
The examples use the db1
profile. To learn more, see Creating a connection profile.
Run the data query:
ydb table query execute \
--query "SELECT season_id, episode_id, title \
FROM episodes \
WHERE series_id = 1 AND season_id > 1 \
ORDER BY season_id, episode_id \
LIMIT 3"
Result:
┌───────────┬────────────┬──────────────────────────────┐
| season_id | episode_id | title |
├───────────┼────────────┼──────────────────────────────┤
| 2 | 1 | "The Work Outing" |
├───────────┼────────────┼──────────────────────────────┤
| 2 | 2 | "Return of the Golden Child" |
├───────────┼────────────┼──────────────────────────────┤
| 2 | 3 | "Moss and the German" |
└───────────┴────────────┴──────────────────────────────┘