You need to query data records in ApsaraDB for Lindorm when you develop, debug, or maintain your services.
To query data, go to the SQL queries page of the cluster management system. Before you query a table, you must select the namespace that stores the table. After you select a namespace, the table list on the right side displays all the tables in the namespace. You can click a table name to view the schema of the table. ROW represents a rowkey, and COL represents a predefined column. You can write a SELECT query based on the table schema.
To implement an SQL query, perform the following steps:
- Select a namespace. Example: default.
- Check the schema of the table that you want to query in the right-side table list.
- Enter an SQL statement in the editor.
- Click Run to run the SQL statement. If you use a Windows system, you can press
Ctrl+Enter. If you use a macOS system, press Command+Return.
- The query results are displayed below the editor. You can also check error messages in this section.
The following figure shows the steps.
Before you perform an SQL query, make sure that you have read and understand the following limits:
- ApsaraDB for Lindorm supports only the
- To ensure data security, ApsaraDB for Lindorm returns a maximum of 100 data records for each query.
- To query varbinary data with conditions, you must use hexadecimal strings as values.
ROWfield corresponds to the rowkey in ApsaraDB for Lindorm. The
qualifierfields are of the
varbinarydata type. If the
qualifierdoes not belong to the
, you must specify thefamily
, such asselect 'ROW', q1, 'f1:q2' from...
COLare SQL reserved words. Therefore, you must use backticks (`) to enclose them in your queries. When you specify a family for a
qualifier, you must also use backticks (`) to enclose the family.
Convert binary strings to hexadecimal strings
Data is stored in byte arrays (
varbinary values in the query results are displayed as binary strings on the SQL Queries page.
If you want to query varbinary fields with conditions (using the
WHERE clause that contains rowkey or other fields), you must specify the
values of the query conditions as hexadecimal strings. Example: To query data with the rowkey
where condition in the SQL query must be
where rowkey='7321'. The hexadecimal value of string
A converter is provided on the SQL Queries page for you to convert binary strings to hexadecimal strings. After you enter a binary string in the text box, the corresponding hexadecimal value is automatically displayed in the SQL editor. The following figure shows an example.
If you want to view query results that are displayed as hexadecimal strings, select the HexString option next to Run. ApsaraDB for Lindorm automatically converts varbinary values to hexadecimal strings. The following figure shows an example.