Tuesday, 15 April 2014

How to create a copy of existing table




      Using below command we can create a new table using existing table.
Syntax:
CREATE TABLE <New Table Name> AS SELECT * FROM <Existing table name>

Example:
CREATE TABLE SAMPLE_TBL_BKP AS SELECT * FROM SAMPLE_TBL

If you need only table structure then use below command:
CREATE TABLE SAMPLE_TBL_BKP AS SELECT * FROM SAMPLE_TBL WHERE 1 = 2



Note: If we use this command to create a new table, that new table will have only super projection (It will come from source). Source table user define projections will not come.

No comments:

Post a Comment