CREATE TABLE
The optional clause causes the error to be suppressed if the table already exists.
The optional WITH
clause can be used to set properties on the newly created table or on single columns. To list all available table properties, run the following query:
SELECT * FROM system.metadata.table_properties
The LIKE
clause can be used to include all the column definitions from an existing table in the new table. Multiple LIKE
clauses may be specified, which allows copying the columns from multiple tables.
If INCLUDING PROPERTIES
is specified, all of the table properties are copied to the new table. If the WITH
clause specifies the same property name as one of the copied properties, the value from the WITH
clause will be used. The default behavior is . The INCLUDING PROPERTIES
option maybe specified for at most one table.
orderkey bigint,
orderstatus varchar,
totalprice double,
orderdate date
Create the table orders
if it does not already exist, adding a table comment and a column comment:
Create the table bigger_orders
using the columns from orders
plus additional columns at the start and end:
CREATE TABLE bigger_orders (
another_orderkey bigint,
LIKE orders,
)