常规Oracle语句与存储过程语句

来源:互联网 发布:初中微机考试模拟软件 编辑:程序博客网 时间:2024/06/05 05:13

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_testisbegin    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_testisbegin    merge into b using a on b.b2 = a.a2     when matched then        set b.b3 = 1;    commit; end;