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 ...方法

有些也是借鉴一些其余朋友的,我在这总结一下!!总结

相关文章
相关标签/搜索