The query Command
The query command line tool can be used to issue SQL statements against a database.
Usage
query [options]
Where:
| Option | Description |
|---|---|
-conf [path] | Configuration file that contains values for connection properties (url, user and password). |
-file [path] | File containing the SQL commands to run. If missing, read SQL commands from STDIN. |
-password | Prompt for password. |
-url [jdbcurl] | JDBC url of the database to connect to. |
-user [user] | User used to connect to the database. |
The queries can either be entered via STDIN, or read in from a text file
The following example shows a SELECT statement issued via STDIN
shell> query -url "jdbc:mysql:thin://db2:13306/" -user tungsten -password
Enter password: ********
select * from tungsten_nyc.trep_commit_seqno;
[
{
"statement":"select * from tungsten_alpha.trep_commit_seqno;","rc":0,"results":
[
[
{
"task_id":0,
"seqno":1,
"fragno":-1,
"last_frag":"1",
"source_id":"db1",
"epoch_number":0,
"eventid":"mysql-bin.000013:0000000000001171;93",
"applied_latency":null,
"update_timestamp":"2025-02-20 10:58:41.0",
"shard_id":null,
"extract_timestamp":"2025-02-20 10:58:41.0",
"connection_id":183
}
]
],
"error":null
}
]