Copy table with or without data
Introduction#
Example of how to copy existing table structure with/without data
Syntax#
- CREATE TABLE schemaName.table AS (SELECT columns FROM schemaName.table) WITH DATA
Copy Table With Data
CREATE TABLE myschema.tableNew AS (
SELECT *
FROM myschema.tableOld
) WITH DATA
Copy Table without data
CREATE TABLE myschema.tableNew AS (
SELECT *
FROM myschema.tableOld
) WITHOUT DATA
Copy Table with where clause
CREATE TABLE myschema.tableNew AS (
SELECT *
FROM myschema.tableOld
WHERE column1 = 'myCriteria'
) WITH DATA