All Products
Search
Document Center

Tablestore:Create mapping tables

Last Updated:Aug 05, 2024

You can execute the CREATE TABLE statement to create a mapping table for an existing table or a search index. When you create a mapping table, specify the names and types of fields in the table, the primary key information about the table, and the execution engine for data queries based on your business requirements.

Note

For more information about the CREATE TABLE statement, see Create a mapping table for a table and Create mapping tables for search indexes.

Prerequisites

Parameters

Parameter

Description

query

The SQL statement. Configure this parameter based on the required feature.

Example

Note

This topic describes how to create a mapping table for a table. If you want to create a mapping table for a search index, replace the SQL statement in the sample code with the SQL statement that is used to create a mapping table for a search index.

The following sample code provides an example on how execute the create table test_table (pk varchar(1024), long_value bigint, double_value double, string_value mediumtext, bool_value bool, primary key(pk)) statement to create a mapping table for a table named test_table:

const params = {
  query: "create table test_table (pk varchar(1024), long_value bigint, double_value double, string_value mediumtext, bool_value bool, primary key(pk))",
}

client.sqlQuery(params, function (err, data) {
  if (err) {
    console.log('sqlQuery error:', err.toString());
  } else {
    console.log('sqlQuery success:', data);
  }
});

FAQ

How do I troubleshoot common errors of SQL queries?

References

  • If you want to accelerate data queries and computing by executing SQL statements, you can create a secondary index or a search index. For more information, see Index selection policy and Computing pushdown.

  • You can execute the SELECT statement to query and analyze data in the table for which you created a mapping table. For more information, see Query data.

  • If an attribute column is added to or removed from a data table, you can execute the ALTER TABLE statement to modify the mapping table that is created for the data table. For more information, see Update attribute columns of a mapping table.

  • If you want to query the description of a table, you can execute the DESCRIBE statement. For more information, see Query information about tables.

  • If you no longer require a mapping table that is created for a table or a search index, you can execute the DROP MAPPING TABLE statement to delete the mapping table. For more information, see Delete mapping tables.

  • If you want to view the index information about a table, you can execute the SHOW INDEX statement. For more information, see Query index information about tables.

  • If you want to query the names of mapping tables in the current database, you can execute the SHOW TABLES statement. For more information, see List the names of tables.