query
Description
A convenience wrapper for executing arbitrary SQL queries on a node.
A cluster node is specified using the --memsql-id
flag. This will use memsqlctl
to execute the query.
The --password
flag is optional and specifies the SingleStoreDB root
password. You can use this flag in conjunction with the --user
flag to specify a SingleStoreDB user that is different from the root
user and the user’s password. Note that the MEMSQL_PASSWORD
environment variable is a safer alternative option for setting the password.
Wrap the password string in single quotes (') to avoid having the shell try to interpret any special characters included in the string.
A node may alternatively be specified using a combination of --host
, --port
, --user
, and --password
. This is not recommended because it can result in connecting to a node outside the cluster.
Examples
sdb-admin query --sql 'select * from data' --memsql-id 0123ABCDEF
sdb-admin query --sql 'select * from data' --host memsql-01 --port 3306 --password mypassword
Usage
Usage: sdb-admin query [flags] Flags: -h, --help Help for query --host string The cluster-addressable hostname for the node --max-column-width int The maximum width of a column in a query result. The supplied value cannot be less than 60. To disable the limitation, set the value to 0 (default 60) --memsql-id MemsqlID The node ID of the node to query -p, --password STRING The database user's password. If a password is specified on the command line, it must not contain an unescaped '$' character as it will be replaced by the shell. If a password is not specified on the command line and user is not "root", Toolbox will attempt to read the password from the ‘MEMSQL_PASSWORD’ environment variable. If this variable is present but does not contain a value, or if the variable does not exist, Toolbox will prompt for a password --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) --sql string The SQL query to run --user string The database user Global Flags: --backup-cache FILE_PATH File path for the backup cache --cache-file FILE_PATH File path for the Toolbox node cache -c, --config FILE_PATH File path for the Toolbox configuration --disable-colors Disable color output in console, which some terminal sessions/environments may have difficulty with --disable-spinner Disable the progress spinner, which some terminal sessions/environments may have issues with -j, --json Enable JSON output --parallelism POSITIVE_INTEGER Maximum number of operations to run in parallel --runtime-dir DIRECTORY_PATH Where to store Toolbox runtime data --ssh-control-persist SECONDS Enable SSH ControlPersist and set it to the specified duration in seconds --ssh-max-sessions POSITIVE_INTEGER Maximum number of SSH sessions to open per host, must be at least 3 --ssh-strict-host-key-checking Enable strict host key checking for SSH connections --ssh-user-known-hosts-file FILE_PATH Path to the user known_hosts file for SSH connections. If not set, /dev/null will be used --state-file FILE_PATH Toolbox state file path -v, --verbosity count Increase logging verbosity: valid values are 1, 2, 3. Usage -v=count or --verbosity=count -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 --yes
or --json
flag to override interactive behavior.