insert all
insert first
把一张表b的数据插入另一张表a的常规操作如下:
insert into a select * from b;
all只要满足条件,就会插入
first只要有一个满足条件,后面的条件不再判断
insert all分为无条件插入和有条件插入
insert all
into a1(deptno,dname)
into a2(deptno,dname)
select deptno,dname from b;
insert all
when deptno <30 then
into a1(deptno,dname)
when deptno <50 then
into a2(deptno,dname)
select deptno,dname from b;
insert first
when deptno <30 then
into a1(deptno,dname)
when deptno <50 then
into a2(deptno,dname)
select deptno,dname from b;
使用一个SQL语句实现了插入了多张表数据,而且这种方式要比写多个insert into 语句效率要高。在上面的SQL中不论插入多少张表,test表只会被读取一次