Create Table from another Table

CREATE TABLE new_table
AS
  (SELECT * FROM old_table
   WHERE 1 = 2);

This would create a new_table that will not included data from old_table. It will only copy the table structure.
 
To create a new table from the existing multiple table.

CREATE table new_table
AS
  (SELECT column1,column2,..column_n
     FROM old_table1,old_table2,..old_table_n);

 

To Create new table from existing table along with the data.
CREATE TABLE new_table
AS
  (SELECT * FROM old_table
   WHERE 1 = 1);

No comments:

Post a Comment