Db/Oracle
join 된 테이블의 update 처리
seongsland
2012. 1. 30. 13:26
a 테이블의 내용을 b테이블의 내용으로 update 치기 위한 방법
1. 키가 보증되는 경우 사용
update
(select a.1, b.1 from a, b)
set a.1 = b.1
2. 키가 보증되지 않은 경우 사용 (ORA-01779 에러남)
update /*+ bypass_ujvc */
(select a.1, b.1 from a, b)
set a.1 = b.1
3. oracle 11 부터 bypass_ujvc를 지원하지 않는다고 함..
때문에 merge 문을 사용
merge into a using (select 1 from b) b
on (a.1 = b.1)
when matched then
update set a.1 = b.1
where a.2 = '2'
1. 키가 보증되는 경우 사용
update
(select a.1, b.1 from a, b)
set a.1 = b.1
2. 키가 보증되지 않은 경우 사용 (ORA-01779 에러남)
update /*+ bypass_ujvc */
(select a.1, b.1 from a, b)
set a.1 = b.1
3. oracle 11 부터 bypass_ujvc를 지원하지 않는다고 함..
때문에 merge 문을 사용
merge into a using (select 1 from b) b
on (a.1 = b.1)
when matched then
update set a.1 = b.1
where a.2 = '2'