DECLARE
count1 NUMBER := 0;
total NUMBER := 0;
CURSOR del_record_cur IS
SELECT rowid FROM scott.emp WHERE empno<=20000;
BEGIN
FOR rec IN del_record_cur LOOP
DELETE FROM scott.emp WHERE rowid = rec.rowid;
total := total + 1;
count1 := count1 + 1;
IF (count1 >= 1000) THEN COMMIT;
count1 := 0;
END IF;
END LOOP;
COMMIT;
DBMS_OUTPUT.PUT_LINE(‘Deleted ‘ || total || ‘ records from scott.emp’);
END;
/
count1 NUMBER := 0;
total NUMBER := 0;
CURSOR del_record_cur IS
SELECT rowid FROM scott.emp WHERE empno<=20000;
BEGIN
FOR rec IN del_record_cur LOOP
DELETE FROM scott.emp WHERE rowid = rec.rowid;
total := total + 1;
count1 := count1 + 1;
IF (count1 >= 1000) THEN COMMIT;
count1 := 0;
END IF;
END LOOP;
COMMIT;
DBMS_OUTPUT.PUT_LINE(‘Deleted ‘ || total || ‘ records from scott.emp’);
END;
/
Note: Please test scripts in Non Prod before trying in Production.
bhanu
Easy and useful. Thankyou
Gayatri
Good