I am going to run one pl/sql block which deletes all the data which is older than 30 days in a table.
Condition is like this:
It will delete 200k data at a time and after deleting 200k data I have to give wait period for 10-15 sec. There are around 100 million records in that table. The whole deletion process I want to do it in automation script.
DECLARE
CURSOR c6
IS
SELECT /*+parallel(a,32)*/
a.rowid,a.*
FROM EB_O.CCO_DIR_CONTRS_ES_GG a
WHERE a.GG_CREATE_DATE < SYSDATE-30
AND ROWNUM <=200001;
TYPE contact_point_id_tab IS TABLE OF c6%ROWTYPE
INDEX BY PLS_INTEGER;
l_contact_point_id_tab contact_point_id_tab;
BEGIN
OPEN c6;
LOOP
FETCH c6
BULK COLLECT INTO l_contact_point_id_tab
LIMIT 10000;
EXIT WHEN l_contact_point_id_tab.COUNT = 0;
IF l_contact_point_id_tab.COUNT > 0
THEN
FORALL i
IN l_contact_point_id_tab.FIRST .. l_contact_point_id_tab.LAST
DELETE FROM EB_O.CCO_DIR_CONTRS_ES_GG
WHERE rowid =l_contact_point_id_tab (i).rowid;
COMMIT;
END IF;
l_contact_point_id_tab.delete;
END LOOP;
END;
This is the above plsql block I have written. How to do this operation in multiple loop and after every loop there will be wait period of 10-15 sec and again the deletion operation will happen for next 200k data. the loop will continue until all the data will be deleted.
N.B.: for wait period, grant is no there for DBMS_LOCK.sleep