Skip to main content
Creates a new table from the given query in the specified schema.
CREATE TABLE ... AS Syntax
Any column aliases used must adhere to the supported naming criteria. While primary keys & foreign keys are not transferred to the new table, shard keys will be, if the column(s) composing them are part of the SELECT list.

Parameters

The following can be applied to <select statement> to affect the resulting table:

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
To create a permanent table with columns 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
To copy a table with columns 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.
See Limitations for other restrictions.