Tuesday 9 April 2013

Create table structure from existing table without coping the data and with coping the data.



In oracle we can create a new table from an existing table as:

CREATE TABLE new table name  AS SELECT * FROM existing table name;

The upper SQL will create a copy of existing table and new table will contain all the data of existing table.

CREATE TABLE new table name  AS SELECT * FROM existing table name WHERE 1=2;

The upper SQL will also create the copy of existing table with the new table name but the new table will not contain any data because the where clause condition will never be true. So this will only copy he structure of the table not the data.

No comments:

Post a Comment