Creates a new LindormTable table with the same schema as an existing table. Only the schema is replicated — the data in the original table is not copied.
Applicable engines and versions
CREATE TABLE LIKE applies only to LindormTable (not applicable to other Lindorm engines). The minimum supported version is LindormTable 2.4.2.1 and later. For version information and upgrade instructions, see Release notes of LindormTable and Upgrade the minor engine version of a Lindorm instance.
Syntax
create_table_statement ::= CREATE TABLE new_table_identifier LIKE old_table_identifier
[ WITH '(' like_option (',' like_option)* ')']
like_option ::= option_identifier '=' string_literalParameters
new_table_identifier
The name of the new table. Names must meet the following requirements:
Contains only digits, letters, commas (,), hyphens (-), and underscores (_)
Does not start with a period (.) or hyphen (-)
Is 1 to 255 characters in length
old_table_identifier
The name of the source table to replicate. To view the schema of a table, use the DESCRIBE syntax. For more information, see DESCRIBE/SHOW/USE.
like_option
Additional replication options specified with the WITH keyword.
| Option | Type | Default | Description |
|---|---|---|---|
COPY_INDEX | STRING | false | Specifies whether to replicate the secondary index of the original table. Valid values: true (replicate the secondary index) and false (do not replicate the secondary index). |
COPY_SPLITKEYS | STRING | false | Specifies whether to replicate the partition start key of the original table. If set to true, the partitioning rules of the original table are also replicated. Valid values: true and false. |
Examples
All examples use the following source table:
CREATE TABLE sensor(
p1 INT NOT NULL,
p2 INT NOT NULL,
c1 VARCHAR,
c2 BIGINT,
PRIMARY KEY(p1, p2)
) WITH (SPLITKEYS = '100000,300000,500000,700000,900000');Replicate the table schema
Create table2 with the same schema as sensor:
CREATE TABLE table2 LIKE sensor;Replicate the schema and partition start key
Create table2 with the same schema and partitioning rules as sensor:
CREATE TABLE table2 LIKE sensor WITH (COPY_SPLITKEYS='true');