码迷,mamicode.com
首页 > 数据库 > 详细

Sql中根据旧表创建新表的SQL语句

时间:2017-09-03 11:14:55      阅读:239      评论:0      收藏:0      [点我收藏+]

标签:...   span   答案   根据   creat   其他   where   table   bsp   

今天在网上查了下,根据旧表创建新表的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 ...

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

 

Sql中根据旧表创建新表的SQL语句

标签:...   span   答案   根据   creat   其他   where   table   bsp   

原文地址:http://www.cnblogs.com/Gary-P/p/7468802.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!