Oracle merge into原来可以这么写

    前不久发现merge into原来还可以这么写:

drop table test purge;
drop table test_bak purge;

create table test as select * from user_objects where rownum <1000 order by object_name;
create table test_bak as select * from test where rownum <100 order by object_name;

merge into test a using(
 select test.object_id,test_bak.object_name from test, test_bak
  where test.object_type = 'TABLE'
    and test_bak.object_type = 'TABLE'
    and test.object_id = test_bak.object_id
    and test_bak.generated = 'N'
) b 
on (a.object_id = b.object_id) 
when matched then
 update set a.subobject_name = b.object_name;

原来可以改写成这样:
merge into (select * from test where object_type = 'TABLE') a
using (select * from test_bak
        where object_type = 'TABLE'
          and generated = 'N') b
on (a.object_id = b.object_id) 
when matched then
 update set a.subobject_name = b.object_name;




  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值