oracle中判断记录是否存在

为了避免全表扫描, 应该这样写,而不是实用count(*)函数, 对于海量数据全表扫描性能是极差的

  1. select fieldName1   
  2.   from tableName   
  3.  where fieldName2 = xxx   
  4.    and rownum < 2   
  5.   
  6. select fieldName1   
  7.   from tableName   
  8.  where fieldName2 = xxx   
  9.    and rownum <= 1   
  10.   
  11. select fieldName1   
  12.   from tableName   
  13.  where fieldName2 = xxx   
  14.    and rownum = 1   
  1. da shang
    donate-alipay
               donate-weixin weixinpay

发表评论↓↓