oracle中判断记录是否存在

为了避免全表扫描, 应该这样写:
Sql代码 复制代码
  1. select spu_id  
  2.   from tbcat2.spu  
  3. where category_id = #value#  
  4.    and (status = 0 or status is null)  
  5.    and rownum < 2  
select spu_id from tbcat2.spu where category_id = #value# and (status = 0 or status is null) and rownum < 2

而不是实用count(*)函数, 对于海量数据全表扫描性能是极差的

posted on 2009-01-09 11:05  dhj  阅读(3993)  评论(0编辑  收藏  举报

导航