All Products
Search
Document Center

Tablestore:SQL query

Last Updated:Aug 19, 2024

After you enter the SQL mode, you can execute SQL statements to query mapping tables that are created for data tables in an instance, query information about a mapping table, and query the data in a table.

Enter the SQL mode

Run the sql command to enter the SQL mode.

Query mapping tables

Query the mapping tables that are created for tables in an instance.

Run the SHOW TABLES; command to query the mapping tables that are created for tables in an instance.

The following result is returned:

+----------------------+
| Tables_in_myinstance |
+----------------------+
| mytable              |
+----------------------+
| mytstable            |
+----------------------+
| mytstable::meta      |
+----------------------+

In the preceding command output, mytable is a mapping table that is created for a data table, mytstable is a mapping table that is created for a time series data table, and mytstable::meta is a mapping table that is created for a time series metadata table.

Query information about a mapping table

Query information about a mapping table.

  • Command syntax

    DESCRIBE table_name;
  • Examples

    The following sample code shows how to query the information about the mapping table named mytable:

    DESCRIBE mytable;

    The following result is returned:

    +-------+---------------+------+-----+-------+
    | Field | Type          | Null | Key | Extra |
    +-------+---------------+------+-----+-------+
    | uid   | varchar(1024) | NO   | PRI |       |
    +-------+---------------+------+-----+-------+
    | pid   | bigint(20)    | NO   | PRI |       |
    +-------+---------------+------+-----+-------+
    | b     | double        | YES  |     |       |
    +-------+---------------+------+-----+-------+
    | c     | tinyint(1)    | YES  |     |       |
    +-------+---------------+------+-----+-------+
    | d     | mediumtext    | YES  |     |       |
    +-------+---------------+------+-----+-------+

Query the data in a table

Query the data in a table by executing the SELECT statement.

Run the following command to query all time series data in the time series table named mytstable:

SELECT * FROM mytstable limit 10;

Exit the SQL mode

Run the exit; command to exit the SQL mode.

FAQ

References