eg:
有两个表A,B 根据两个表身份证字段a2,b2相等的条件,改变B表b3字段的值,固定改成1。
–1.数据量不大时,使用update
update b
set b.b3 = 1
where exists(select null from a where a.a2 = b.b2);
commit;
–2.数据量大时,使用 merge into
merge into b using a on b.b2 = a.a2
when matched then
set b.b3 = 1;
commit;
–1.数据量不大时,使用update(存储)
create or replace procedure p_test
is
begin
update b
set b.b3 = 1
where exists(select null from a where a.a2 = b.b2);
commit;
end;
–2.数据量大时,使用 merge into(存储)
create or replace procedure p_test
is
begin
merge into b using a on b.b2 = a.a2
when matched then
set b.b3 = 1;
commit;
end;