您的位置:首页 > 数据库 > Oracle

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

2017-11-25 21:51 183 查看
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;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  存储 oracle