Oracle查询两表相差的数据
原来以为not exists 会比not in 效率高,但在实际运用过程中,发现两表数据差不多的情况下,用另一种方式效率会更好.
原设计语句:
select * from (select * from ex_22222 where exattribute1 = '13') K1 where not exists
(
select * from
(
select ex_22222.entityid from ex_22222,ut_users where exattribute1 = '13'
and ex_22222.entityid = ut_users."UID"
) K2
where K1.ENTITYID = K2.ENTITYID
)
新改进语句:
select K1.ENTITYID,K2.ENTITYID from (select * from ex_22222 where exattribute1 = '13') K1,
(
select * from
(
select ex_22222.entityid from ex_22222,ut_users where exattribute1 = '13'
and ex_22222.entityid = ut_users."UID"
)
) K2
where K1.ENTITYID = K2.ENTITYID(+)
and K2.ENTITYID is null
相关推荐
oraclemch 2020-11-06
Seandba 2020-08-16
dbasunny 2020-08-16
娜娜 2020-06-22
专注前端开发 2020-10-21
苏康申 2020-11-13
vitasfly 2020-11-12
liuyang000 2020-09-25
FellowYourHeart 2020-10-05
赵继业 2020-08-17
whyname 2020-08-16
拼命工作好好玩 2020-08-15
langyue 2020-08-15
写程序的赵童鞋 2020-08-03
Accpcjg 2020-08-02
tydldd 2020-07-30
好记忆也需烂 2020-07-28