Oracle merge into原来可以这么写
发布时间:2020-12-12 16:32:36 所属栏目:百科 来源:网络整理
导读:前不久发现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 orde
前不久发现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; (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |