Monday, June 25, 2012

Quickly Duplicate an Existing Table [Oracle]

This is a tip for quickly duplicating an existing table.


CREATE TABLE new_table_name AS
(SELECT * FROM existing_table)


While this is another tip for quickly creating a table with the same column name of an existing table.


CREATE TABLE new_table_name AS 
(SELECT * FROM existing_table WHERE 1 = 2)




Notice the where condition.  You could actually change it to any condition that returned false (e.g 1=0).  The select statement will select nothing.


No comments:

Post a Comment