Previous Next JavaScript must be enabled to correctly display this content

## get

Encapsulates commands that get key/value pairs from store or get rows from table. The subcommands are as follows:

- get kv

- get table

### get kv

    get kv [-key <keyString>] [-file <output>] [-all] [-keyonly]
    [-valueonly] [-start <prefixString>] [-end <prefixString>]

Perform a simple get operation using the specified key. The obtained value is printed out if it contains displayable characters, otherwise the bytes array is encoded using Base64 for display purposes. "[Base64]" is appended to indicate this transformation. The arguments for the get command are:

- `-key <keyString>`

  Indicates the full or the prefix key path to use. If `<keyString>` is a full key path, it returns a single value information. The format of this `get` command is: `get -key <keyString>.` If `<keyString>` is a prefix key path, it returns multiple key/value pairs. The format of this `get` command is: `get -key <keyString> -all.` Key can be composed of both major and minor key paths, or a major key path only. The <keyString> format is: "major-key-path/-/minor-key-path". Additionally, in the case of the prefix key path, a key can be composed of the prefix part of a major key path.

  For example, with some sample keys in the KVStore:

      /group/TC/-/user/bob
      /group/TC/-/user/john
      /group/TC/-/dep/IT
      /group/SZ/-/user/steve
      /group/SZ/-/user/diana

  A get command with a key containing only the prefix part of the major key path results in:

      kv -> get kv -key /group -all -keyonly
      /group/TC/-/user/bob
      /group/TC/-/user/john
      /group/TC/-/dep/IT
      /group/SZ/-/user/steve
      /group/SZ/-/user/diana

  A get command with a key containing a major key path results in:

      kv -> get kv -key /group/TC -all -keyonly
      /group/TC/-/user/bob
      /group/TC/-/user/john
      /group/TC/-/dep/IT

  Get commands with a key containing major and minor key paths results in:

      kv -> get kv -key /group/TC/-/user -all -keyonly
      /group/TC/-/user/bob
      /group/TC/-/user/john
      kv -> get kv -key /group/TC/-/user/bob
      {
          "name"  : "bob.smith",
          "age"   : 20,
          "email" : "bob.smith@example.com",
          "phone" : "408 555 5555"
      }

- `-file <output>`

  Specifies an output file, which is truncated, replacing all existing content with new content.

  In the following example, records from the key `/Smith/Bob` are written to the file `"data.out".`

      kv -> get kv -key /Smith/Bob -all -file ./data.out

  In the following example, contents of the file `"data.out"` are replaced with records from the key `/Wong/Bill.`

      kv -> get kv -key /Wong/Bill -all -file ./data.out

- `-all`

  Specified for iteration starting at the specified key. If the key argument is not specified, the entire store will be iterated.

- `-keyonly`

  Specified with `-all` to return only keys.

- `-valueonly`

  Specified with `-all` to return only values.

- `-start <prefixString>` and `-end <prefixString>`

  Restricts the range used for iteration. This is particularly helpful when getting a range of records based on a key component, such as a well-formatted string. Both the `-start` and `-end` arguments are inclusive.

  Note:

  `-start` and `-end` only work on the key component specified by `-key <keyString>`. The value of `<keyString>` should be composed of simple strings and cannot have multiple key components specified.

  For example, a log where its key structure is:

      /log/<year>/<month>/-/<day>/<time>

  puts all log entries for the same day in the same partition, but splits the days across shards. The `time` format is: "hour.minute".

  In this way, you can do a `get` of all log entries in February and March, 2013 by specifying:

      kv-> get kv -all -keyonly -key /log/2013 -start 02 -end 03
      /log/2013/02/-/01/1.45
      /log/2013/02/-/05/3.15
      /log/2013/02/-/15/10.15
      /log/2013/02/-/20/6.30
      /log/2013/02/-/28/8.10
      /log/2013/03/-/01/11.13
      /log/2013/03/-/15/2.28
      /log/2013/03/-/22/4.52
      /log/2013/03/-/31/11.55

  You can be more specific to the `get` command by specifying a more complete key path. For example, to display all log entries from April 1st to April 4th:

      kv-> get kv -all -keyonly -key /log/2013/04 -start 01 -end 04
      /log/2013/04/-/01/1.03
      /log/2013/04/-/01/4.05
      /log/2013/04/-/02/7.22
      /log/2013/04/-/02/9.40
      /log/2013/04/-/03/4.15
      /log/2013/04/-/03/6.30
      /log/2013/04/-/03/10.25
      /log/2013/04/-/04/4.10
      /log/2013/04/-/04/8.35

See the subcommand get table

### get table

    kv-> get table -name <table_name> [-index <name>]
        [-field <name> -value <value>]+
        [-field <name> [-start <value>] [-end <value>]]
        [-ancestor <name>]+ [-child <name>]+
        [-json <string>] [-file <output>] [-keyonly]
        [-pretty] [-report-size]

Identifies a table name, which can be any of the following:

- `-name`

  Identifies any of the following tables:

  - `table_name` – The target table is a top level table created in the default namespace, `sysdefault`. The default namespace (`sysdefault:`) prefix is not required to identify such tables.
  - `table_name.child_name` – The target table is the child of a parent table. Identify the child table by preceding it with the parent `table_name`, followed by a period (.) separator before `child_name`.
  - `namespace_name:table_name` – The target table was not created in the default (`sysdefault`) namespace. Identify `table_name` by preceding it with its `namespace_name`, followed by a colon (:).
  - `namespace_name:table_name.child_name` – The target table is the child of a parent table that was created in a namespace. Identify `child_name` by preceding it with both `namespace_name:` and the parent `table_name`, , followed by a period (.) separator.

  `-field` and `-value` pairs are used to specify the field values of the primary key or index key if using an index, specified by `-index`, or with an empty key to iterate the entire table.

- `-field` flag, along with its `-start` and `-end` flags, can be used to define a value range for the last field specified.

- `-ancestor` and `-child` flags are used to return results from specific ancestor and/or descendant tables as well as the target table.

- `-json` indicates that the key field values are in JSON format.

- `-file` is used to specify an output file, which is truncated.

- `-keyonly` is used to restrict information to keys only.

- `-pretty` is used for a nicely formatted JSON string with indentation and carriage returns.

- `-report-size` is used to show key and data size information for primary keys, data values, and index keys for matching records. When `-report-size` is specified no data is displayed.