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


今天在網上查了下,根據舊表創建新表的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 ...

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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM