oracle存储过程plsql中,判断符合条件的记录是否存在,建议使用rownum

 

select count(1) into v_count from tableName where 条件... and rownum = 1;
if v_count <> 0 then
    -- 符合条件的记录存在
end if;

因为 rownum=1,所以oracle只要扫描到一条符合条件的记录,就不会在继续扫描下去了,当符合同条件的数据量越大时,性能的提高越明显。

猜你喜欢

转载自blog.csdn.net/li_tiantian/article/details/86061051