1、使用子查询插入数据
insert into employee select * from emp;
使用子查询执行直接装载
insert /*+APPEND*/into employee insert into employee select * from emp;
尽管上面两条语句的执行结果一样,但是当装载大批量的数据时,采用第二种方法的速度要远优于第一种方法
2、使用insert all操作符执行多表插入
create table dept10 as select * from emp where 1=2
create table dept20 as select * from emp where 1=2
create table dept30 as select * from emp where 1=2
create table clerk as select * from emp where 1=2
create table other as select * from emp where 1=2
下面的语句,会将部门10的雇员的信息插入到dept10中,会将部门20的雇员的信息插入到dept20中,会将部门30的雇员的信息插入到dept30中,将岗位为clerk的所有雇员插入到clerk,将其他信息插入到other表中
insert all
when deptno=10 then into dept10
when deptno=20 then into dept20
when deptno=30 then into dept30
when job='CLERK' THEN INTO CLERK
ELSE INTO OTHER
SELECT * FROM EMP
3、使用insert first操作符执行多表插入
delete from dept10;
delete from dept20;
delete from dept30;
delete from clerk ;
delete from other;
使用insert first操作执行多表插入时,如果数据已经满足先前的条件,并且已经被插入到某个表,那么该行的数据在后面的插入中将不会再次被使用
insert first
when deptno=10 then into dept10
when deptno=20 then into dept20
when deptno=30 then into dept30
when job='CLERK' THEN INTO CLERK
ELSE INTO OTHER
SELECT * FROM EMP
当查询数据时可以看到clerk中没有数据,应为该数据在前面的操作中已经被插入到dept10,或dept20,或dept30中