I am trying to do a delete operation from multiple tables. I am deleting 500k records from almost 30 tables, each of which may or may not have records against the deletion criteria. Each table is fairly big, more than 1 GB.
BEGIN
---Criteria for deletion
q_query:='
SELECT a,
b,
c
FROM T,
GTY,
GRUP,
GART,
T_category
WHERE T.ID = GTY.ID
AND GTY.ID = GRUP.ID
AND GRUP.ID = GART.ID
AND GART.ID = T_CATEGORY.ID;
open c_cursor for q_query;
--looping all the values in cursor for all the 30 tables.
loop fetch c_cursor into l_C,l_ID_V,l_ID_F;
exit when c_cursor %NOTFOUND;
begin
DELETE FROM T_TABLE WHERE ID=L_ID AND ID_F=L_ID_F;
.
.
.
DELETE FROM T WHERE ID-L_ID AND ID_F=L_ID_F;
end;
end loop;
END;
I am running to into undo tablespace issue. ORA-30036: unable to extend segment by 8 in undo tablespace 'UNDOTBS1'.
Things I have considered,
Resize the undo tablespace
alter DATABASE datafile 'D:\ORADATA\MBSA\MBSA\DATAFILE\O1_MF_UNDOTBS1_xxx_.DBF' autoextend on next 1G maxsize 32000M;
Add commit at 10k count, with this approach I am running into
ORA-01555: snapshot too old: rollback segment number string with name "string" too small
Tried adding additional undo datafiles, but they were never considered.
Increased undo retention : no impact
I even tried making undo tablespace as big file, and it corrupted the database.
Is there any way to overcome this issue? Please help.Thanks!
Oracle version is 19c.
undo retention setting are :
temp_undo_enabled boolean FALSE
undo_management string AUTO
undo_retention integer 1800
undo_tablespace string UNDOTBS1
undo_retention
setting? What version of Oracle are you using? Not sure why you're apparently using dynamic PL/SQL (and the string you posted doesn't appear to be a valid PL/SQL block). – Justin Caveselect ... bulk collect ...
to fill PL/SQL collection variable and then useforall
withdelete
to use bulk operations. They are hundred times faster and you do not need to hold a single cursor for hours, which introduces unnecessary contention. – astentxdbms_parallel_execute
which allows chunked execution: build chunks by record number or rowid and run in parallel or sequentially with controlled degree of parallelism and contention. – astentx