You can execute the create table statement to create a mapping table for an existing data 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

An OTSClient instance 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.

The following code provides an example on how to execute the CREATE TABLE `test_table` (`pk0` VARCHAR(1024), `pk1` BIGINT(20), `col0` MEDIUMTEXT, `col1` BIGINT(20), `col2` DOUBLE, `col3` BOOL, `col4` MEDIUMBLOB, `date_col` MEDIUMTEXT, `geo_col` MEDIUMTEXT, `col0_v1` MEDIUMTEXT, `col0_v2` MEDIUMTEXT, PRIMARY KEY(`pk0`,`pk1`)); statement to create a mapping table for a table named test_table:

/// <summary>
/// Create a mapping table for a table. 
/// </summary>
/// <param name="otsClient"></param>
public static void CreateMappingTable(OTSClient otsClient)
{
    string sqlCommand = @"CREATE TABLE `test_table` (
        `pk0` VARCHAR(1024),
        `pk1` BIGINT(20),
        `col0` MEDIUMTEXT,
        `col1` BIGINT(20),
        `col2` DOUBLE,
        `col3` BOOL,
        `col4` MEDIUMBLOB,
        `date_col` MEDIUMTEXT,
        `geo_col` MEDIUMTEXT,
        `col0_v1` MEDIUMTEXT,
        `col0_v2` MEDIUMTEXT,
        PRIMARY KEY(`pk0`,`pk1`)
    );";

    SQLQueryRequest sqlQueryRequest = new SQLQueryRequest(sqlCommand);

    SQLQueryResponse sqlQueryResponse = otsClient.SQLQuery(sqlQueryRequest);
}