창고/Backup_2013_0121 [Oracle]multiple insert 사용하기 by 가능성1g 2011. 12. 1. 반응형 -- multiple-insert -- sub-query 에서 리턴된 행들을 조건에 따라 table1,2,3 에 insert 함 -- 문법 insert [all] -- [sub-query]에 의해 리턴된 행들의 컴첨냅?insert 문 실행시 모두 참조 [when condition1 then into [table1] values(col1, col2, ... )] [when condition2 then into [table2] values(col3, col4, ... )] [else into [table3] values(col5, col6, ... )] [sub-query]; -- ex1) unconditional insert insert all into sal_history values(empid, hiredate, sal) into mgr_history values(empid, mgr, sal ) select employee_id empid, hire_date hiredate, salary sal, manager_id mgr from employees where employee_id > 200; -- ex2) conditional insert insert all when sal > 10000 then into sal_history values(empid, hiredate, sal) when mgr > 200 then into mgr_history values(empid, mgr, sal ) select employee_id empid, hire_date hiredate, salary sal, manager_id mgr from employees where employee_id > 200; -- ex3) conditional-first insert insert first when sal > 10000 then into sal_history values(empid, hiredate, sal) when mgr > 200 then into mgr_history values(empid, mgr, sal ) else into etc_history values(empid, hiredate,mgr, sal ) select employee_id empid, hire_date hiredate, salary sal, manager_id mgr from employees where employee_id > 200; 반응형 공유하기 게시글 관리 Release Center 저작자표시 비영리 동일조건 관련글 이런 아이디어가!! Little Printer 2012년에는 C# 공부해야겠답=ㅅ= [Oracle] Level, Lpad 를 이용한 결재선 쿼리 만들기 [Oracle] 유저추가 외 기타 설정