搜出来一个老帖
http://topic.csdn.net/u/20090508/18/a3a84432-f43f-4973-87ba-34c94cc38149_2.html里面有几种写法
Insert into Student(Sno,Sname,Ssex,Sage,sdept) 
select '95001','李勇','男','20','CS' union all
select '95002','刘晨','女','19','IS' union all
...... Insert into Student(Sno,Sname,Ssex,Sage,sdept) 
  values('95001','李勇','男','20','CS')
union all select ('95001','李勇','男','20','CS')
union all select('95001','李勇','男','20','CS')
.
.
.
union all select('95001','李勇','男','20','CS')Insert into Student(Sno,Sname,Ssex,Sage,sdept) select '95001','李勇','男',20,'CS'
Insert into Student(Sno,Sname,Ssex,Sage,sdept) select '95002','刘晨','女',19,'IS' 
Insert into Student(Sno,Sname,Ssex,Sage,sdept) select '95003','王敏','女',18,'IS' 
Insert into Student(Sno,Sname,Ssex,Sage,sdept) select '95004','张立','男',19,'MA' 
Insert into Student(Sno,Sname,Ssex,Sage,sdept) select '96001','徐一','男',20,'IS' 
Insert into Student(Sno,Sname,Ssex,Sage,sdept) select '96002','张三','女',21,'CS' 
Insert into Student(Sno,Sname,Ssex,Sage,sdept) select '96003','李四','男',18,'IS' Insert into Student(Sno,Sname,Ssex,Sage,sdept) values( '95001','李勇','男','20','CS') 
 Insert into Student(Sno,Sname,Ssex,Sage,sdept) values( '95002','刘晨','女',19,'IS') 
 Insert into Student(Sno,Sname,Ssex,Sage,sdept) values( '95003','王敏','女',18,'IS') 
 Insert into Student(Sno,Sname,Ssex,Sage,sdept) values( '95004','张立','男',19,'MA') 
 Insert into Student(Sno,Sname,Ssex,Sage,sdept) values( '96001','徐一','男',20,'IS') 
 Insert into Student(Sno,Sname,Ssex,Sage,sdept) values( '96002','张三','女',21,'CS') 
 Insert into Student(Sno,Sname,Ssex,Sage,sdept) values( '96003','李四','男',18,'IS')Insert into Student(Sno,Sname,Ssex,Sage,sdept)
values( '95001','李勇','男','20','CS')
,( '95002','刘晨','女',19,'IS')
,( '95003','王敏','女',18,'IS')
,( '95004','张立','男',19,'MA')
,( '96001','徐一','男',20,'IS')
,( '96002','张三','女',21,'CS')
,( '96003','李四','男',18,'IS') 哪样写比较好?

解决方案 »

  1.   

    union all的是作为一个事务
    value是多个事务
    values( '95001','李勇','男','20','CS')
    ,( '95002','刘晨','女',19,'IS')
    ,( '95003','王敏','女',18,'IS')
    ,( '95004','张立','男',19,'MA')
    ,( '96001','徐一','男',20,'IS')
    ,( '96002','张三','女',21,'CS')
    ,( '96003','李四','男',18,'IS')
    是08写法
    应该也算一个事务的
    个人支持第一种的union all
    和最后一种
      

  2.   

    如果一次插入庞大数量的数据
    独立的一个个事务(value类型)
    可能比整个事务的效率好
      

  3.   

    多谢回复意思是union all之后比逐条的效率要好吗?