由于大批量删除数据,必须考虑其删除数据需要的资源最少,因此可按照如下的方式删除。
DECLARE ln_count NUMBER(10); ln_rownum NUMBER(10); BEGIN LOOP FOR cur IN (SELECT t.rowid FROM os_mail_fs_send_detail t WHERE mail_title = '邮箱攻略' AND provcode = 16 AND rownum <= 10000) LOOP ln_count := ln_count + 1; DELETE os_mail_fs_send_detail WHERE ROWID = cur.rowid; IF ln_count > 10000 THEN ln_count := 1; COMMIT; END IF; END LOOP; SELECT COUNT(1) INTO ln_rownum FROM os_mail_fs_send_detail t WHERE mail_title = '邮箱攻略' AND provcode = 16 AND rownum <= 1; IF ln_rownum <= 0 THEN EXIT; END IF; END LOOP; END;
来源:http://www.cnblogs.com/blogyuan,欢迎转载