Hello Experts,
Oracle DB version : Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64 bit Production
We have a requirement to delete data from 100+ tables.
We have currently implemented this requirement using DELETE statements on each of the 100+ tables.
After deleting the records from all the tables , we issue a COMMIT.
Below is a Pseudo Code for each table :
DECLARE
CURSOR c1 is
SELECT 'x' from tab1 where id = :b1 for update nowait; --acquire row lock
BEGIN
OPEN c1;
DELETE FROM tab1 where id = :b1;
CLOSE c1;
.
.
.
.
.
.
.
.
.
.
.
COMMIT;
EXCEPTION
..............
END;
/
Column ID is indexed.
The current implementation performs poorly. It takes around 1 hour to delete 1000 id's from the 100+ tables in a certain order due to integrity constraints.
Our target is to delete 10,000 id's from all tables.
In order to improve performance we have thought of using BULK COLLECT and FORALL in order to DELETE records.
However, I have the following queries :
1. Could you please suggest how to acquire row level locks on a table while using collections.
2. Could you please suggest how to issue a COMMIT after every 1000 records in order to ensure that I don't run out of the available in the UNDO tablespace.
I would be grateful if you could also suggest a better appraoch apart from the one I mentioned above.
Thank You.