首页 > 其他 > 详细

18.一次性插入多条记录

时间:2016-10-14 06:50:05      阅读:175      评论:0      收藏:0      [点我收藏+]
use MySchool
--一次性插入多条记录--
insert into grade values(4,工具)

insert into Grade (GradeName)
select aaa union all --只有全部写了union all才不会去除重复记录
select aaa union all
select aaa union all
select aaa union all
select bb union all
select bb --union 最后一句不需要加union all,在union里面不能写Default

select * from Grade

---一次性插入多条记录
--1。select 字段列表/*  into 目的表 from  源表会生成一个与查询字段相同结构的新表,也就意味着新表不能先存在,它是系统生成的
select classname into newGrade from Grade
truncate table grade
--2. insert into 目的表名select * from 源表:目的表必须先存在,如果没有存在,就报错了
--select classname  into Grade from newGrade
insert into Grade select * from newgrade

select * into newGrade from Grade
--使用select into from 生成的新表字段的属性都会消失,除了标识列属性之外
select * from newGrade

 

18.一次性插入多条记录

原文:http://www.cnblogs.com/justqi/p/5958765.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!