You can execute the create table statement to create a mapping table for an existing table or search index.

Note For more information about the create table statement, see Create mapping tables for tables and Create mapping tables for search indexes.

Prerequisites

A Tablestore client is initialized. For more information, see Initialization.

Parameters

Parameter Description
query The SQL statement. Configure the parameter based on the required feature.

Examples

Note The following code provides an example on how to create a mapping table for a table.

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 the 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);
  }
});