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 `tableName` (`PK0` BIGINT(20),`PK1` VARCHAR(1024),`geo` MEDIUMTEXT,`boolean` BOOL,`array` MEDIUMTEXT,`double` DOUBLE,`text` MEDIUMTEXT,`keyword` MEDIUMTEXT,`nested` MEDIUMTEXT,`long` BIGINT(20),PRIMARY KEY(`PK0`,`PK1`)); statement to create a mapping table for the table named tableName:

$request = array(
    'query' => 'CREATE TABLE `tableName` (`PK0` BIGINT(20),`PK1` VARCHAR(1024),`geo` MEDIUMTEXT,`boolean` BOOL,`array` MEDIUMTEXT,`double` DOUBLE,`text` MEDIUMTEXT,`keyword` MEDIUMTEXT,`nested` MEDIUMTEXT,`long` BIGINT(20),PRIMARY KEY(`PK0`,`PK1`));',
);
$response = $this->otsClient->sqlQuery($request);
print json_encode($response, JSON_PRETTY_PRINT);