user_id '열' 표 모두 가지고 있다. '때' 에서 't2' 에 필요한 데이터를 삽입하려면 t1 '는' 열 user_id 같다.
미리 감사합니다 모든 도움말에서는 제공되지 않았다.
update
table1 t1
set
(
t1.column1,
t1.column2
) = (
select
t2.column1,
t2.column2
from
table2 t2
where
t2.column1 = t1.column1
)
where exists (
select
null
from
table2 t2
where
t2.column1 = t1.column1
);
이 경우. = > < t2.column1 또는 t1.column1 및 그들 가운데 어느 한 것이 많다).
update
table1 t1
set
(
t1.column1,
t1.column2
) = (
select
t2.column1,
t2.column2
from
table2 t2
where
t2.column1 = t1.column1
and
rownum = 1
)
where exists (
select
null
from
table2 t2
where
t2.column1 = t1.column1
);
T1 의 일치하는 행뿐만 업데이트하려면 데이터로 t2 어졌다면:
update t1
set (c1, c2, c3) =
(select c1, c2, c3 from t2
where t2.user_id = t1.user_id)
where exists
(select * from t2
where t2.user_id = t1.user_id)
여기서 이 " exists"; it 부품 막을 수 없는 t1 업데이트하던 열을 nulll 해당되어서는 존재합니다.
업데이트하려면 할 수 있습니다.
UPDATE t1
SET <t1.col_list> = (SELECT <t2.col_list>
FROM t2
WHERE t2.user_id = t1.user_id)
WHERE EXISTS
(SELECT 1
FROM t2
WHERE t1.user_id = t2.user_id);
희망을 줍니다.
항상 flfile. 및 남겨두십시오 아웃해야 않을 때, 정합된 section" " 수 있습니다.
merge into table1 FromTable
using table2 ToTable
on ( FromTable.field1 = ToTable.field1
and FromTable.field2 =ToTable.field2)
when Matched then
update set
ToTable.fieldr = FromTable.fieldx,
ToTable.fields = FromTable.fieldy,
ToTable.fieldt = FromTable.fieldz)
when not matched then
insert (ToTable.field1,
ToTable.field2,
ToTable.fieldr,
ToTable.fields,
ToTable.fieldt)
values (FromTable.field1,
FromTable.field2,
FromTable.fieldx,
FromTable.fieldy,
FromTable.fieldz);