Sql中根據舊錶建立新表的SQL語句

今天在網上查了下,根據舊錶建立新表的SQL語句,網上給了兩個答案spa

create table tab_new like tab_old (使用舊錶建立新表)it

create table tab_new as select col1,col2… from tab_old definition onlyio

 

兩個語句都試了一下,報錯了。table

正確的方法是 select * into newtable from oldtable; 若是不想導記錄,只想生成表結構 :select * into newtable from oldtable where 1=2;select

若是newtable已存在,想導入記錄:insert into newtable select * from oldtable where ...方法

有些也是借鑑一些其餘朋友的,我在這總結一下!!總結

相關文章
相關標籤/搜索