There might be severe problems if the bulk number of rows are deleted fromt the production table. As this will lock the table in shared mode. And resource of the server will be used, offcourse it will use the UNDO tablespace heavily.
Following is the procedure which can be used to delete the bulk rows in batches on certain conditions. Also it will run in loops which can be controlled and also once it will delete the records it will put the message into purge_history table.
declare
type table_rowid_Array is table of rowid index by binary_integer;
l_rids table_rowid_Array;
v_counter number := 0;
v_counter_total number := 0;
v_id_counter number := 0;
begin
for i in 1 .. 500
loop
v_id_counter := i;
select rowid
bulk collect into l_rids
from BIG_LOG_TABLE where log_date < '1-JUN-2008' and rownum < 25001;
for i in 1 .. l_rids.count
loop
delete from BIG_LOG_TABLE where rowid = l_rids(i);
v_counter := v_counter +1 ;
end loop;
dbms_output.put_line( v_counter ' rows deleted' );
v_counter_total := v_counter_total + v_counter;
v_counter := 0;
insert into purge_history values (v_id_counter,v_counter_total,sysdate,BIG_LOG_TABLE );
commit;
end loop;
dbms_output.put_line( v_counter_total ' total rows deleted' );
end;
This blog contains different things for Oracle DBA, APPS DBA and Middleware technologies. All these things should be tested first on test environments before applying in the Prod environments, please follow the standard Change control to apply all the PreProd and Prod changes. Also to make this blog more useful, please give your comments and share your experience. Thanks
Search This Blog
Subscribe to:
Posts (Atom)
Oracle 19c - patch 19.22 unavailability for Windows platform
Oracle 19c - patch 19.22 unavailability for Windows platform Having upgraded the Oracle 11g 11.2.0.4 database to Oracle 19c 19.3.0.0.0 whi...
-
Oracle 12c Installer error - [INS-10102] Installer initialization failed - no oraInstaller in java.library.path - make sure oraInst.lo...
-
Introduction: This post is related to describe the Report server issue with Oracle 9i AS R2. For this release of Application Server, the X S...
-
Introduction: In this article we will see, the impact of "Parallel" clause of rebuilding a partition index. We would also enable t...