Tablestore allows you to use the SQL query feature to quickly query data. After you create a mapping table in the console, you can execute the SELECT statement to quickly query the required data.


  • If you want to use a RAM user to perform operations, make sure that a RAM user is created and all SQL operation permissions are granted to the RAM user. You can configure "Action": "ots:SQL*" in the custom policy to grant all SQL operation permissions to the RAM user. For more information, see Grant permissions to a RAM user.
  • A data table is created.


The SQL query feature is available in the China (Hangzhou), China (Shanghai), China (Beijing), China (Zhangjiakou), China (Shenzhen), and Singapore regions.

Create a mapping table

  1. Log on to the Tablestore console.
  2. In the top navigation bar, select a region, for example, China (Hangzhou) or China (Shenzhen).
  3. On the Overview page, click the name of the required instance or click Manage Instance in the Actions column of the required instance.
  4. On the Query by Executing SQL Statement tab, create a mapping table.
    Note You can also manually compile SQL statements to create a mapping table. For more information, see Create tables and mapping tables.
    1. Click the fig_createtablevitural icon. fig_createtablemapping
    2. In the Create Mapping Table dialog box, select a table, and click Generate SQL Statement.
      The system automatically generates the schema of the mapping table.
      Notice Make sure that the field data types in the mapping table match the field data types in the data table. For more information about data type mappings, see Data type mappings.
    3. After you modify the schema based on your business requirements, hold down the left mouse button to select an SQL statement and click Execute SQL Statement(F8).

      After the execution is successful, the execution result is displayed in the Execution Result section.

      • Before you execute an SQL statement, you must select the SQL statement that you want to execute. Otherwise, the system executes the first SQL statement by default.
      • You cannot select multiple SQL statements to execute at the same time. If you select multiple SQL statements, the system reports an error.

Query data

After a mapping table is created, you can execute the SELECT statement to query data on the Query by Executing SQL Statement tab. For more information, see Query data.