oracle 多表插入

插入单表的多表插入

​insert all into people (person_id,first_name,last_name) values(person_id,first_name,last_name)into people (first_name,last_name,parent_id) values(child1,last_name,person_id)into people (first_name,last_name,parent_id) values(child2,last_name,person_id)into people (first_name,last_name,parent_id) values(child3,last_name,person_id)into people (first_name,last_name,parent_id) values(child4,last_name,person_id)into people (first_name,last_name,parent_id) values(child5,last_name,person_id)into people (first_name,last_name,parent_id) values(child6,last_name,person_id)
select person_id,first_name,last_name,child1,child2,child3,child4,child5,child6
from demo_perple;

多表插入

​insert allinto parents (person_id,first_name,last_name) values(person_id,first_name,last_name)into children (first_name,last_name,parent_id) values(child1,last_name,person_id)into children (first_name,last_name,parent_id) values(child2,last_name,person_id)into children (first_name,last_name,parent_id) values(child3,last_name,person_id)into children (first_name,last_name,parent_id) values(child4,last_name,person_id)into children (first_name,last_name,parent_id) values(child5,last_name,person_id)into children (first_name,last_name,parent_id) values(child6,last_name,person_id)
select children ,first_name,last_name,child1,child2,child3,child4,child5,child6
from demo_perple;

条件插入

​insert allwhen  1=1 theninto people (person_id,first_name,last_name) values(person_id,first_name,last_name)when child1 is not null then into people (first_name,last_name,parent_id) values(child1,last_name,person_id)when child2 is not null then into people (first_name,last_name,parent_id) values(child2,last_name,person_id)when child3 is not null then into people (first_name,last_name,parent_id) values(child3,last_name,person_id)when child4 is not null then into people (first_name,last_name,parent_id) values(child4,last_name,person_id)when child5 is not null then into people (first_name,last_name,parent_id) values(child5,last_name,person_id)when child6 is not null then into people (first_name,last_name,parent_id) values(child6,last_name,person_id)
select children ,first_name,last_name,child1,child2,child3,child4,child5,child6
from demo_perple;


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部