vtctl Query Command Reference

The following vtctl commands are available for administering queries.

Commands #

VtGateExecute #

Executes the given SQL query with the provided bound variables against the vtgate server.

These commands have been deprecated and will be removed in a future release!

Example #

VtGateExecute -- --server <vtgate> [--bind_variables <JSON map>] [--keyspace <default keyspace>] [--tablet_type <tablet type>] [--options <proto text options>] [--json] <sql>

Flags #

NameTypeDefinition
jsonBooleanOutput JSON instead of human-readable table
optionsstringexecute options values as a text encoded proto of the ExecuteOptions structure
serverstringVtGate server to connect to
targetstringkeyspace:shard@tablet_type

Arguments #

  • <vtgate> – Required.
  • <sql> – Required.

Errors #

  • the <sql> argument is required for the <VtGateExecute> command This error occurs if the command is not called with exactly one argument.
  • query commands are disabled (set the --enable_queries flag to enable)
  • error connecting to vtgate '%v': %v
  • Execute failed: %v

VtTabletExecute #

Executes the given query on the given tablet. --transaction_id is optional. Use VtTabletBegin to start a transaction.

Example #

VtTabletExecute -- [--username <TableACL user>] [--transaction_id <transaction_id>] [--options <proto text options>] [--json] <tablet alias> <sql>

Flags #

NameTypeDefinition
jsonBooleanOutput JSON instead of human-readable table
optionsstringexecute options values as a text encoded proto of the ExecuteOptions structure
transaction_idInttransaction id to use, if inside a transaction.
usernamestringIf set, value is set as immediate caller id in the request and used by vttablet for TableACL check

Arguments #

  • <TableACL user> – Required.
  • <tablet alias> – Required. A Tablet Alias uniquely identifies a vttablet. The argument value is in the format <cell name>-<uid>.
  • <sql> – Required.

Errors #

  • the <tablet_alias> and <sql> arguments are required for the <VtTabletExecute> command This error occurs if the command is not called with exactly 2 arguments.
  • query commands are disabled (set the -enable_queries flag to enable)
  • cannot connect to tablet %v: %v
  • Execute failed: %v

VtTabletBegin #

Starts a transaction on the provided server.

Example #

VtTabletBegin -- [--username <TableACL user>] <tablet alias>

Flags #

NameTypeDefinition
usernamestringIf set, value is set as immediate caller id in the request and used by vttablet for TableACL check

Arguments #

  • <TableACL user> – Required.
  • <tablet alias> – Required. A Tablet Alias uniquely identifies a vttablet. The argument value is in the format <cell name>-<uid>.

Errors #

  • the <tablet_alias> argument is required for the <VtTabletBegin> command This error occurs if the command is not called with exactly one argument.
  • query commands are disabled (set the --enable_queries flag to enable)
  • cannot connect to tablet %v: %v
  • Begin failed: %v

VtTabletCommit #

Commits the given transaction on the provided server.

Example #

VtTabletCommit -- [--username <TableACL user>] <transaction_id>

Flags #

NameTypeDefinition
usernamestringIf set, value is set as immediate caller id in the request and used by vttablet for TableACL check

Arguments #

  • <TableACL user> – Required.
  • <transaction_id> – Required.

Errors #

  • the <tablet_alias> and <transaction_id> arguments are required for the <VtTabletCommit> command This error occurs if the command is not called with exactly 2 arguments.
  • query commands are disabled (set the -enable_queries flag to enable)
  • cannot connect to tablet %v: %v

VtTabletRollback #

Rollbacks the given transaction on the provided server.

Example #

VtTabletRollback -- [--username <TableACL user>] <tablet alias> <transaction_id>

Flags #

NameTypeDefinition
usernamestringIf set, value is set as immediate caller id in the request and used by vttablet for TableACL check

Arguments #

  • <TableACL user> – Required.
  • <tablet alias> – Required. A Tablet Alias uniquely identifies a vttablet. The argument value is in the format <cell name>-<uid>.
  • <transaction_id> – Required.

Errors #

  • the <tablet_alias> and <transaction_id> arguments are required for the <VtTabletRollback> command This error occurs if the command is not called with exactly 2 arguments.
  • query commands are disabled (set the --enable_queries flag to enable)
  • cannot connect to tablet %v: %v

VtTabletStreamHealth #

Executes the StreamHealth streaming query to a vttablet process. Will stop after getting <count> answers.

Example #

VtTabletStreamHealth -- [--count <count, default 1>] <tablet alias>

Flags #

NameTypeDefinition
countIntnumber of responses to wait for

Arguments #

  • <count default 1> – Required.
  • <tablet alias> – Required. A Tablet Alias uniquely identifies a vttablet. The argument value is in the format <cell name>-<uid>.

Errors #

  • the <tablet alias> argument is required for the <VtTabletStreamHealth> command This error occurs if the command is not called with exactly one argument.
  • query commands are disabled (set the --enable_queries flag to enable)
  • cannot connect to tablet %v: %v

See Also #