Oracle多表插入
1. 測試資料
建立4張測試表
customer,customer1,customer2,customer3
create table tested.customer(
column1 varchar2(10 char),
column2 varchar2(10 char),
column3 varchar2(10 char)
);
create table tested.customer1(
column1 varchar2(10 char),
column2 varchar2(10 char)
);
create table tested.customer2(
column1 varchar2(10 char),
column2 varchar2(10 char)
);
create table tested.customer3(
column1 varchar2(10 char),
column2 varchar2(10 char)
);
插入測試資料
insert into tested.customer values('1','haha','321');
insert into tested.customer values('2','hehe','321');
insert into tested.customer values('3','heihei','321');
commit;
2. 多表插入
将customer表中的資料分别插入到customer1,customer2,customer3中
insert all
when column1 = '1'
then into tested.customer1
when column1 = '2'
then into tested.customer2
when column1 = '3'
then into tested.customer3
select column1,column3
from tested.customer;
commit;