You may need to query a data entry stored in ApsaraDB for HBase when you develop, debug, or maintain your services. You can use HBase Shell to create Get and Scan queries. You can also use the easy-to-use SQL query interface in Lindorm Insight to query data. In the interface, you can use the SQL syntax to query data from ApsaraDB for HBase Performance-enhanced Edition (Lindorm) tables.

Prerequisites

You are logged on to Lindorm Insight of your cluster. For more information, see Log on to Lindorm Insight.

Limits

  • To ensure data security, Lindorm returns only up to 100 entries for each query.
  • The ROW field is equivalent to RowKey in Lindorm. The data types of the ROW and qualifier fields are varbinary. If the qualifier field does not belong to a family, you must specify a family.
  • The ROW and COL fields are reserved fields in SQL. When you use these fields in queries, you must enclose the fields in grave accents (`). When you specify a family for the qualifier field, you must also enclose the field in grave accents (`).

Query data in a Lindorm wide table

  1. In the left-side navigation pane of the cluster management system, select Data Query > SQL Executor.
  2. Select a namespace from the namespace drop-down list. Tables in the namespace are displayed on the right side of the page.
  3. Enter the SQL statement for query in the editor.
  4. Click Execute.

Obtain hexadecimal strings

To query varbinary data with conditions, you must use hexadecimal strings as values. For example, to query data whose rowkey is r1, set the WHERE condition to WHERE rowkey='7321' in the SQL statement. The hexadecimal string of r1 is 7321. The Data Query page of the cluster management system provides a conversion tool for you to convert values to hexadecimal strings.

Method 1

  1. In the left-side navigation pane of the cluster management system, select Data Query.
  2. Select a namespace from the namespace drop-down list.
  3. Turn on the HexString switch.
  4. Enter the SQL statement for query in the editor.
  5. Click Execute.
  6. In the returned results, obtain the hexadecimal string that is converted from the condition value.

Method 2

  1. In the left-side navigation pane of the cluster management system, select Data Query > SQL Executor.
  2. Select a namespace from the namespace drop-down list. Tables in the namespace are displayed on the right side of the page.
  3. Execute the following statement to view the structure of the table that stores the data you want to query.
    SELECT * FROM <table_name>;// Replace <table_name> with the name of the table that stores the data you want to query.
  4. In the Binary hex conversion text box, enter the condition value that you want to convert to a hexadecimal string.
  5. Obtain the hexadecimal string converted from the value in the first row in the editor.
  6. Enter the SQL statement that you want to execute and replace the condition value in the statement with the converted hexadecimal string.
    For example, you want to execute the following SQL statement to query data:
    SELECT * FROM task WHERE ROW = "master_ttl";
    After you replace the condition value with the corresponding hexadecimal string, you can execute the following statement to query data:
    SELECT * FROM task WHERE ROW = "6d61737465725f74746c";
  7. Click Execute.