t1表
COL1 COL2 COL3
----- ----- ----------
A1 1 abcdef
A2 2 abcdef
A3 3 111111
t2表
COL1 COL2 COL3
----- ----- ----------
A1 1 123456
A2 2 123456
A3 3 111111
方法一:
declare
cursor c1 is select col1,col2,t1.col3 from t1 join t2 using(col1,col2) where t1.col3<>t2.col3 ;
begin
for r1 in c1 loop
update t2 set col3=r1.col3 where col1=r1.col1 and col2=r1.col2;
end loop;
end;
/
方法二:
update t2 set col3=(select col3 from t1 where t1.col1=t2.col1 and t1.col2=t2.col2) where col3<>(select col3 from t1 where t1.col1=t2.col1 and t1.col2=t2.col2);