Outdated Version
You are viewing an older version of this section. View current production version.
query
A convenience wrapper for executing arbitrary SQL queries on a node on this host.
Usage
A convenience wrapper for executing arbitrary SQL queries on a node on this host
Usage:
memsqlctl query [flags]
Flags:
-h, --help Help for query
--host string The cluster-addressable hostname for the node
--memsql-id string The MemSQL ID of the node to query
-p, --password STRING The user's password for connecting to MemSQL
--port PORT The cluster-addressable port for the node
--row-timeout duration Maximum time to wait for each row in the result (e.g., 30s, 10m, 1.5h); defaults to 1 minute (default 1m0s)
-e, --sql string The SQL query to run
--user string The MemSQL database user
Global Flags:
-c, --config FILE_PATH Path to the memsqctl config file
--default-install-dir DIRECTORY_PATH Path to the default install directory
-j, --json Print output in JSON format
--node-metadata-file FILE_PATH Path to the node metadata file
--parallelism POSITIVE_INTEGER Maximum amount of operations to be run in parallel
--ssl-ca FILE_PATH Path to the CA certificate file in PEM format to authenticate the MemSQL server certificate
--timeout duration Maximum time for operation to complete (e.g., 30s, 10m, 1.5h)
-v, --verbosity count Increase logging verbosity
-y, --yes Enable non-interactive mode and assume the user would like to move forward with the proposed actions by default
Remarks
This command is interactive unless you use either the --yes
or --json
flags to override interactive behavior.
The memsqlctl query
command is equivalent to the memsql-admin query command.
Output
The following shows how to use the query
command to run SHOW DATABASES
against the master aggregator on the local host machine.
$ sudo memsqlctl query --sql "SHOW DATABASES"
+-------+------------+--------+------+---------------+---------+
| Index | MemSQL ID | Role | Port | Process State | Version |
+-------+------------+--------+------+---------------+---------+
| 1 | 29EB592436 | Master | 3306 | Running | 6.5.14 |
| 2 | 035F453938 | Leaf | 3307 | Running | 6.5.14 |
+-------+------------+--------+------+---------------+---------+
Select an option: 1
+--------------------+
| Database |
+--------------------+
| cluster |
| information_schema |
| memsql |
+--------------------+
Another example executes the same query on the master aggregator from its local host machine without specifying the memsql-id
of the master aggregator node and printing the output in JSON format.
$ sudo memsqlctl list-nodes -q -r master | xargs -I % sudo memsqlctl query --sql "SHOW DATABASES" --memsql-id % --json
{
"columns": [
"Database"
],
"rows": [
{
"Database": "cluster"
},
{
"Database": "information_schema"
},
{
"Database": "memsql"
}
]
}