Friday, May 09, 2014

Oracle Create Table As Select vs SQL Server Select Into

Oracle CTAS (create table as select) is a convenient way to create a new table based on an existing table.

SQL> select * from tbl_test;

       NUM
----------
         1
         2

SQL> create table tbl_test2 as select * from tbl_test;

Table created.

SQL> select * from tbl_test2;

       NUM
----------
         1
         2
In SQL Server, instead of using CTAS, we use "select.. into new_table from old_table" to create a new table based on old table.
select * into tbl_test2 from tbl_test;

No comments: