今天在網上查了下,根據舊表創建新表的SQL語句,網上給了兩個答案
create table tab_new like tab_old (使用舊表創建新表)
create table tab_new as select col1,col2… from tab_old definition only
兩個語句都試了一下,報錯了。
正確的方法是 select * into newtable from oldtable; 如果不想導記錄,只想生成表結構 :select * into newtable from oldtable where 1=2;
如果newtable已存在,想導入記錄:insert into newtable select * from oldtable where ...
有些也是借鑒一些其他朋友的,我在這總結一下!!