Updated on 2022-11-18 GMT+08:00

CREATE TABLE LIKE

Syntax

CREATE TABLE [IF NOT EXISTS] table_name ({coulumn_name data_type [COMMENT comment] [WITH (property_name = expression [, ...])] | LIKE existing_table_name [{INCLUDING| EXCLUDING} PROPERTIES]}) [, ...] [COMMENT table_comment] [WITH (property_name = expression [, ...])]

Description

The LIKE clause allows you to include all column definitions of an existing table in a new table. You can use multiple LIKE statements to copy the columns of multiple tables.

If the INCLUDING PROPERTIES option is used, all attributes of the table are copied to the new table. This option takes effect for only one table.

You can use the WITH clause to modify the name of the attribute copied from the table.

The EXCLUDING PROPERTIES attribute is used by default.

Example

CREATE TABLE orders_like like orders INCLUDING PROPERTIES STORED AS TEXTFILE;