Oracle Delete Set of rows in a table

Share via:
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;
/
Share via:
Note: Please test scripts in Non Prod before trying in Production.
1 Star2 Stars3 Stars4 Stars5 Stars (13 votes, average: 5.00 out of 5)
Loading...

2 thoughts on “Oracle Delete Set of rows in a table

Add Comment