CREATE TABLE LIKE
CREATE TABLE LIKE creates an identical empty table based on the definition of another table. The definition includes column definition, partitions, and table properties. You can copy an external table such as MySQL.
v3.2 allows you to specify a different partitioning method, bucketing method, and properties for the new table than the source table.
tip
This operation requires the CREATE TABLE privilege on the database in which you want to create a table, and the SELECT privilege on the source table based on which to create a table.
Syntaxβ
- Syntax supported in versions earlier than v3.2.
CREATE [EXTERNAL] TABLE [IF NOT EXISTS] [database.]<table_name>
LIKE [database.]<source_table_name>
- v3.2 supports specifying properties for the new table.
CREATE [TEMPORARY] [EXTERNAL] TABLE [IF NOT EXISTS] [database.]<table_name>
[partition_desc]
[distribution_desc]
[PROPERTIES ("key" = "value",...)]
LIKE [database.]<source_table_name>
Parametersβ
TEMPORARY: Creates a temporary table. From v3.3.1, StarRocks supports creating temporary tables in the Default Catalog. For more information, see Temporary Table.database: the database.table_name: the name of the table you want to create. For the naming conventions, see System limits.source_table_name: the name of the source table you want to copy.-
partition_desc: the partitioning method. For more information, see CREATE TABLE.
distribution_desc: the bucketing method. For more information, see CREATE TABLE.PROPERTIES: the properties of the table. All the table properties are supported. For more information, see ALTER TABLE.