ITPub博客

首页 > Linux操作系统 > Linux操作系统 > not in的使用

not in的使用

原创 Linux操作系统 作者:Kevene 时间:2010-04-07 10:35:50 0 删除 编辑

最近做做一些关于数据比对的东西,经常用到not in来比对,对于小的数据的情况那肯定是没有问题,not in是不能走索引的,如果表的数据很大的话根本就行不同,google了下用not exists来地带,效果很好

 

select * from tablename@dblink
where id not in(select id from tablename);


select * from tablename@tdblink a
where not exists(select 1 from tablename b where a.id=b.id);

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/16719800/viewspace-631458/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2008-11-16

  • 博文量
    52
  • 访问量
    215367