例如:
insert into tbl_stu(stu_id,stu_name,stu_sex,stu_age) VALUES ('1003','周宏伟','男','12');
insert into tbl_stu(stu_id,stu_name,stu_sex,stu_age) VALUES ('1004','何小飞','女','43');
insert into tbl_stu(stu_id,stu_name,stu_sex,stu_age) VALUES ('1005','李华','女','15');
insert into tbl_stu(stu_id,stu_name,stu_sex,stu_age) VALUES ('1006','赵婷','女','31');
如何将这样繁琐的sql语句整理为一句去执行?
--SQL 2000
insert into tbl_stu(stu_id,stu_name,stu_sex,stu_age)
select '1003','周宏伟','男','12' union
select '1004','何小飞','女','43' union
select '1005','李华','女','15' union
select '1006','赵婷','女','31'
--SQL 2008
insert into tbl_stu(stu_id,stu_name,stu_sex,stu_age)
VALUES ('1003','周宏伟','男','12'),
VALUES ('1004','何小飞','女','43'),
VALUES ('1005','李华','女','15'),
VALUES ('1006','赵婷','女','31')
用union all效率更高一些。