You can execute the create table statement to create tables and mapping tables. If a table with the specified name exists, only the mapping table is created. If a table with the specified name does not exist, both the table and the mapping table are created.

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

Prerequisites

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

Usage notes

Tablestore SDK for Java V5.13.0 or later supports the SQL query feature. Before you use the SQL query feature, make sure that Tablestore SDK for Java V5.13.0 or later is obtained. For more information about the version history of Tablestore SDK for Java, see Tablestore SDK for Java.

Parameters

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

Example

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.

private static void createTable(SyncClient client) {
    // Create a SQL request. 
    SQLQueryRequest request = new SQLQueryRequest("create table test_table (pk varchar(1024), long_value bigint, double_value double, string_value mediumtext, bool_value bool, primary key(pk))");

    // Obtain the response to the SQL request. 
    SQLQueryResponse response = client.sqlQuery(request);
}