Use the AS option of the CREATE TABLE statement to copy some or all of an existing table. The following table describes several options for copying tables.
Use this statement … |
To copy an existing table as … |
CREATE GLOBAL TEMPORARY TABLE AS [tablename/query_expression] …WITH NO DATA |
a global temporary table. Use WITH NO DATA, because global temporary tables are not populated until they are materialized by being referenced in a query. If you want the table to inherit: The subquery form of CREATE GLOBAL TEMPORARY TABLE AS...WITH NO DATA does not copy indexes and defines a default primary index which might not be appropriate. Teradata highly recommends specifying explicitly an appropriate PI or specify NO PRIMARY INDEX. |
CREATE TABLE AS [tablename/query_expression] … WITH [NO] DATA [AND STATISTICS] |
a permanent table or a volatile table. You choose what columns you want to copy and whether the table should be populated automatically, as follows. If you want the table to inherit: The subquery form of CREATE TABLE AS...WITH [NO] DATA does not copy indexes or partitioning and defines a default primary index, which might not be appropriate. Teradata highly recommends specifying explicitly an appropriate PI or specify NO PRIMARY INDEX. |