CREATE TABLE ... AS Syntax
The parentheses around
<select statement> are optional.SELECT list.
Parameters
The following can be applied to
<select statement> to affect the resulting
table:
Table Property Clause
A subset of table properties can be applied to the created table at creation time. The Table Property Clause syntax is the same as that in the CREATE TABLE Table Property Clause, and theUSING keyword is optional in either. Of the properties available there,
only CHUNK SIZE, COMPRESSION_CODEC, & TTL take effect here; any
other is accepted without error and then discarded.
Examples
To create a replicated temporary table that is a copy of an existing table, failing if a table with the same name as the target table already exists:CREATE TABLE ... AS (Replicated/Temporary) Example
a, b, c, & d a new
shard key on columns a & b, and an index on column d, replacing a
table with the same name as the target table, if it exists:
CREATE TABLE ... AS (Reshard) Example
a, b, c, & d, preserving the
primary key on a, b, & c, and the foreign key from d; a new
table must be created to match the schema of the old one and then records can be
copied from the old one to the new one:
CREATE TABLE (Preserve Primary Key) Example, DDL Step
CREATE TABLE (Preserve Primary Key) Example, DML Step
This create/insert process is necessary, as neither primary keys nor
foreign keys can be preserved through hints.