Bulk Delete in Oracle 8i

Hi,
We have a requirement where in we need to archive the old records in the production into history tables. After archiving we need to delete the records from the production tables around 50 in number. From our experience we have found that the delete operation consumes the maximum time. Due to this a large archive of old records have piled up in the production tables. We have found ways to expeditie the process of moving the data to the history tables.
Can someone give us advice on the different techniques available to expedite the delete process along with the pros and cons of the respective technique?
Thanks in advance!!!

Hi,
1. How do I partition only the set of data that I want to historise?For example, a table SALES. This table contains date_sale, on which we can base the partition. One partition for one month. Each month, create a new partition.
If you want an historic for the last 12 months, only drop (or offline correspondant tablespace) sales older than 12 months (drop partition n-12).
But all data in this table are repartioned on parititions.
Paritioned tables is not anly for historise, but to equiibrate access.
2. There are After Delete triggers on some of these tables. Will these triggers get fired >when we use this concept? (or) Do we need to find someother way to trigger them ?No change about your actual code.
A partitioned table is a table, even if there are too many table behind the tree.
3. Will the other DB objects be affected when we use this concept?Like point 2, no change for all others objects.
4. Some tables are accessed by other applications using DB links. Will those >applications be impacted in anyway?Like points 2&3, no change for application program or dblink...
I adise you to read Oracle doc about thisd concept :
http://download-west.oracle.com/docs/cd/B14117_01/server.101/b10743/partconc.htm
Hope this help you,
Nicolas.
Note Any table can be partitioned except those tables containing columns with LONG or LONG RAW datatypes.
Message was edited by:
N. Gasparotto

Similar Messages

  • Forall bulk delete is too slow to work,seek advice.

    I used PL/SQL stored procedure to do some ETL work. It is pick up refeshed records from staging table, then check to see whether the same record exists in target table, then do a Forall bulk deletion first, then do a Forall insert all refreshed records into target atble. the insert part is working fine. Only is the deleteion part, it is too slow to get job done. My code list below. Please advise where is the problem? Thansk.
    Declare
    TYPE t_distid IS TABLE OF VARCHAR2(15) INDEX BY BINARY_INTEGER;
    v_distid t_distid;
    CURSOR dist_delete IS
    select distinct distid FROM DIST_STG where data_type = 'H';
    OPEN dist_delete;
    LOOP
    FETCH dist_delete BULK COLLECT INTO v_distid;
    FORALL i IN v_distid.FIRST..v_distid.LAST
    DELETE DIST_TARGET WHERE distid = v_distid(i);
    END LOOP;
    COMMIT;
    end;
    /

    citicbj wrote:
    Justin:
    The answers to your questions are:
    1. why would I not use a single DELETE statement? Because this PL/SQL procedure is part of ETL process. The procedure is scheduled by Oracle scheduler. It will automatically run to refresh data. Putting DELETE in stored procedure is better to executed by scheduler.You can compile SQL inside a PL/SQL procedure / function just as easily as coding it the way you have so that's really not an excuse. As Justin pointed out, the straight SQL approach will be what you want to use.
    >
    2. The records in dist_stg with data_type = 'H' vary by each month. It range from 120 to 5,000 records. These records are inserted into target table before. But they are updated in transactional database. We need to delete old records in target and insert updated ones in to replace old ones. But the distID is the same and unique. I use distID to delete old one and insert updated records with the same distID into target again. When user run report, the updated records will show up on the report. In plain SQL statement, delete 5,000 records takes about seconds. In my code above, it take forever. The database is going without any error message. There is no trigger and FK associated
    3. Merge. I haven't try that yet. I may give a try.Quite likely a good idea based on what you've outlined above, but at the very least, remove the procedural code with the delete as suggested by Justin.
    >
    Thanks.

  • FORALL bulk delete statement requires lot of time even for 10 rows deletion

    Hi,
    when I execute FORALL bulk delete statement it requires lot of time even for 10 rows deletion.so how to avoid this problem? I checked SGA_TARGET and PGA_TARGET cureent_size and max_size are same for both. Is their memory problem?
    I execute following code
    DECLARE
    TYPE t_id_tab IS TABLE OF test.c1%TYPE;
    l_id_tab t_id_tab := t_id_tab();
    Begin
    select c1 bulk collect into l_id_tab from TEST where c1<=10;
    dbms_output.put_line(DBMS_UTILITY.get_time);
    FORALL i IN l_id_tab.first .. l_id_tab.last
    delete from TEST where c1= l_id_tab(i);
    dbms_output.put_line(DBMS_UTILITY.get_time);
    commit;
    End;
    thanks in advance
    Vaibhav
    Edited by: Vaibhav on Oct 10, 2011 10:47 PM

    hi
    i am working on oracle 11g. Actually i have to test which is the faster method to delete 150000 records.
    1st by using FOR Loop bunch of 10000 records
    2nd by using FORALL delete
    kindly find below FORALL delete code
    DECLARE
    TYPE t_id_tab IS TABLE OF test.c1%TYPE;
    l_id_tab t_id_tab := t_id_tab();
    Begin
    select c1 bulk collect into l_id_tab from TEST where c1<=10;
    dbms_output.put_line(DBMS_UTILITY.get_time);
    FORALL i IN l_id_tab.first .. l_id_tab.last
    delete from TEST where c1= l_id_tab(i);
    dbms_output.put_line(DBMS_UTILITY.get_time);
    commit;
    End;
    Edited by: Vaibhav on Oct 10, 2011 10:56 PM

  • Which is fast bulk delete or id's in a table and a where exists ....?

    I have some parent objects and that I use bulk collect with fetch limit and I currently store the primary keys of these parent objects to identify their child objects later by using where exists with a correlated subquery.
    I'm essentially moving objects graphs that span partitions from table to table.
    when I've done my SQL insert into select... I eventually do a delete.
    currently the delete uses the parent objects in this working table to identify the children to delete later.
    Q. What is likely to be faster?
    using a "temporary" table to requery for child objects based on the parents that I have for each batch or
    using returning clause from my insert into select so that I have rowid's or primary keys to work with later on
    when I want to perform my delete operation?
    I essentially have A's that have child B's which in tern have child C's.
    I store a batch of A pk's in a table and use those to identify the B's
    currently I don't store the B's pk but use the A pk's again to identify the B's which in turn are used to identify the C's later.
    I'm thinking if I remember the pk's I'm using at each level I can then use those later when it comes to the deletes.
    typically that's done in a returning clause and using a bulk delete from that collection later.
    thoughts?

    Parallel DML is one option. Another is to ceate a procedure (or package) that does a discreet unit of work (e.g. process parent and its children as a single business transaction). And then write a "+thread manager+" that runs x number copies of these at the same time (via DBMS_JOB for example).
    Let's say the procedure's signature is as follows:
    create or replace procedure ProcessFamily( parentID number ) is ..
    --// processes a family (parent and children)
    ..Using DBMS_JOB is pretty easy - when you start a job you get a job number for it. Looking at USER_JOBS will tell you whether that job is still in the job queue, or has completed (once off jobs are removed from the queue). The core of the this code will be a loop that checks how many jobs (threads) are running, and if less than the ceiling (e.g. it may only use 20 threads), start more ProcessFamily jobs.
    If the total number of threads/jobs to execute are known up front, then this ThreadManager can manually create a long operation entry. Such an entry contains the number of unit of works to do and then is updated with the number of units done thus far. Oracle provides time estimates for completion and percentage progress. This long operation can be tracked by most Oracle-based monitoring software and provide visibility as to what the progress is of the processing.
    The ProcessFamly procedure can also use parallel DML (if that makes sense). Or bulk processing (if needed). This approach is also scalable as h/w increases (server upgrades, new server h/w), so too does your ability to run more threads (aka jobs) at the same time.
    Now I'm not suggesting that you write a ProcessFamily() proc - I do not know the actual data and problem you're trying to solve. What I'm trying to convey is the basic principle for writing multi-thread/parallel processing software using PL/SQL. And it is not that complex. The critical thing is simply that the parallel procedure or thread be entirely thread safe - meaning that multiple copies of the same code can be started and these copies will not cause serialisation, dead locking, and other (application designed) problems.

  • Procedure hangs while bulk delete

    Hi,
    I have the following situation:
    I'm trying to delete the records using oracle bulk delete feature using SAVE EXCEPTIONS clause so that I can count how many were actually deleted and how many were not due to referential integrity constraint. I tried this on one table which has ca. 40,000 child records... this means that 40,000 exceptios were recorded by the SAVE EXCEPTIONS clause. Could this be the reason for the procedure to go in hang state ?
    Could someone please advise me on this as to what might be going wrong. I'm working Oracle Database 10g Enterprise Edition Release 10.1.0.4.0 - 64bit.
    Thanks.
    -Patza

    Anything could be the reason why something is hanging given that you've provided very little detail. So lets start at the beginning.
    1. What platform? CPU? Operating system? RAM?
    2. How long have you let it run?
    3. Have you checked the alert log?
    4. Have you tried starting with a delete of 100 rows, then increased to 1000, 5000, 10000, etc? If not why not? Have you then tried incrementally adding the child records to force the exceptions? If not why not? Start with generating 1, then 10, then 100 exceptions.

  • I borrowed a hard drive from a friend that contains many thousands of songs. Somehow when tranferring these to iTunes I managed to get several copies of each song. How can i do a bulk delete of all the copies leaving just one version of each song?

    I need help please. I borrowed a hard drive from a friend which contains many thousands of songs. When adding them to my iTunes library I somehow managed to make multiple copies of each song. Is there a way to do a bulk delete of all the duplicates? If I have to go one by one it will take a lifetime.

    I have the same problem. I keep backups on a home server and this is where my library pointed to. I changed it to the local drive and now I have two copies in the library. I need to either bulk delete or clear the library (without deleting the files) and then rebuild. How do I do either of these things?

  • Table space not reduce after delete in oracle 11G

    Hi Team,
    I have a DB 11.1.0.7 on unix.
    I have execute delete tables on tablespace, but this not reduce.
    Thanks

    935299 wrote:
    What segment space management type is defined for the tablespace in question?
    MANUAL
    Then you should check out the documentation some more.
    But even if you shrink the table segement what is that going to do for the data file size?
    I don't undertand you.
    ThanksYour thread is titled "Table space not reduce after delete in oracle 11G" which implies to me that you are interested in reducing the size of a tablespace (which really means reducing the size of the underlying datafile(s)).
    So, if you shrink the size of the sys.aud$ table, will that cause the datafile(s) to become smaller? Will it accomplish your goal? What else, if anything, needs to happen?

  • Is there a way to bulk delete records

    It seems that I have a a lot of duplicated records in my " central " area so I wanted to either filter by Area then delete the duplicates if there is a way to do that or bulk delete every record that is "Central" in the Area column..
    is that possible?

    Are you able to select more than 100 through the Content and Structure manager?
    OR
    I found a technet article that uses powershell to perform a bulk-delete, it might be your best bet to start here:
    http://social.technet.microsoft.com/wiki/contents/articles/19036.sharepoint-using-powershell-to-perform-a-bulk-delete-operation.aspx
    Edit: is this you?
    http://sharepoint.stackexchange.com/questions/136778/is-there-a-way-to-bulk-delete-records ;)

  • How can I bulk delete 50,000+ photos from Revel online?

    I have already deleted the photos in my catalog that were associated with my Revel online Carosel but they are still showing up on the Revel online Carosel via web or iPad. I can delete individual photos or by date through Revel online via the web or iPad but that takes forever. I need a way to bulk delete all Revel Carosel photos that are showing up online.

    charleston spottail
    With so many photos (50,000+) involved, I think it would be in your best interests to post your thread in the Adobe Revel Forum here.
    Revel
    The top participants in the Adobe Revel Forum are identified as Staff.
    Please let us know the outcome.
    Thank you.
    ATR

  • Send bulk mail in oracle apps 11i with pdf/Xls attachment

    hi,
    I have a task how can i send bulk emails in one go ( aprrox 150-200 emails in one go) in oaracle apps 11 with attachment pdf/xls
    thanks

    Duplicate post.
    how to send bulk mail in oracle apps 11i with pdf/Xls attachment
    Re: how to send bulk mail in oracle apps 11i with pdf/Xls attachment

  • Can emails be bulk deleted from Iphone 4s or does each have to be marked individually then deleted.  Trash can be bulk deleted.

    Can emails be bulk deleted from Iphone 4s or does each have to be marked individually then deleted.  Trash can be bulk deleted.

    Each has to be deleted.
    But it can go faster if the iPhone is held in the horizontal position, then on the left side listing tap Edit in the upper raight bar of that pane, and just tap each email to be deleted, then when you have a batch to delete, tap delete at the bottom left.  That is the fastest way I have found.

  • Can I bulk delete duplicate pictures in Elements 11?

    I imported about 2600 pictures from iPhoto to Elements 11 on my iMac OS 10.8.2.  Now there are hundreds of duplicates; deleting one at a time is a real pain.  Can I identify and bulk delete duplicates in Elements 11?

      Yes you can select thumbnails in the Organizer and hit delete. Then choose also delete from hard disk.
    If you want to use iPhoto it’s best to set up the Elements Editor application for external editing in iPhoto preferences. That will avoid duplication on your hd. See link for notes:
    http://helpx.adobe.com/photoshop-elements/kb/photoshop-elements-iphoto-mac-os.html

  • Bulk insert into oracle using ssis

    Hi ,
    Can someone please suggest me the way to Bulk insert data into oracle database? I'm using oledb which doesnt support bulk insert into oracle.
    Pls note I cant use Oracle ATTUnity as it requires enterprise edition but i have only Standard edition and hence that option is ruled out.
    Is there any other way that I can accompolish BULK insert?
    Please help me out.
    Thanks,
    Prabhu

    Hi Prabhu,
    I am very late to help you solve the query but following is the solution to 'Bulk Insert into Oracle' that worked for me.
    To use below code for SSIS 2008 R2 in a
    Script Task component you would need following API references.
    Prerequisites:
    1. C:\Program Files (x86)\Microsoft SQL Server\100\SDK\Assemblies\Microsoft.SQLServer.DTSRuntimeWrap.dll
    2. Install "Oracle Data Provider For .NET 11.2.0.1.0" and add a reference to
    Oracle.DataAccess.dll.
       Microsoft SQL Server Integration Services Script Task
       Write scripts using Microsoft Visual C# 2008.
       The ScriptMain is the entry point class of the script.
     *  Description : SQL to Oracle Bulk Copy/Insert
     *  Created By  : Mitulkumar Brahmbhatt
     *  Created Date: 08/14/2014
     *  Modified Date   Modified By     Description
    using System;
    using System.Data;
    using Microsoft.SqlServer.Dts.Runtime;
    using System.Windows.Forms;
    using Oracle.DataAccess.Client;
    using Microsoft.SqlServer.Dts.Runtime.Wrapper;
    using System.Data.OleDb;
    namespace ST_6e18a76102dd4312868504c4ef95279d.csproj
        [System.AddIn.AddIn("ScriptMain", Version = "1.0", Publisher = "", Description = "")]
        public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
            #region VSTA generated code
            enum ScriptResults
                Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
                Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
            #endregion
            public void Main()
                ConnectionManager cm;
                IDTSConnectionManagerDatabaseParameters100 cmParams;
                OleDbConnection oledbConn;
                DataSet ds = new DataSet();
                string sql;
                try
                    /********** Pull Sql Source Data into a Dataset *************/
                    cm = Dts.Connections["SRC_CONN"];
                    cmParams = cm.InnerObject as IDTSConnectionManagerDatabaseParameters100;
                    oledbConn = (OleDbConnection)cmParams.GetConnectionForSchema() as OleDbConnection;
                    sql = @"Select * from [sourcetblname]'';
                    OleDbCommand sqlComm = new OleDbCommand(sql, oledbConn);
                    OleDbDataAdapter da = new OleDbDataAdapter(sqlComm);
                    da.Fill(ds);
                    cm.ReleaseConnection(oledbConn);
                    /***************** Bulk Insert to Oracle *********************/
                    cm = Dts.Connections["DEST_CONN"];
                    cmParams = cm.InnerObject as IDTSConnectionManagerDatabaseParameters100;
                    string connStr = ((OleDbConnection)cmParams.GetConnectionForSchema() as OleDbConnection).ConnectionString;
                    cm.ReleaseConnection(oledbConn);
                    sql = "destinationtblname";
                    using (OracleBulkCopy bulkCopy = new OracleBulkCopy(connStr.Replace("Provider=OraOLEDB.Oracle.1", "")))
                        bulkCopy.DestinationTableName = sql;
                        bulkCopy.BatchSize = 50000;
                        bulkCopy.BulkCopyTimeout = 20000;
                        bulkCopy.WriteToServer(ds.Tables[0]);
                    /***************** Return Result - Success *********************/
                    Dts.TaskResult = (int)ScriptResults.Success;
                catch (Exception x)
                    Dts.Events.FireError(0, "BulkCopyToOracle", x.Message, String.Empty, 0);
                    Dts.TaskResult = (int)ScriptResults.Failure;
                finally
                    ds.Dispose();
    Mitulkumar Brahmbhatt | Please mark the post(s) that answered your question.

  • Is it possible to do a bulk delete in email?

    I got so discusted a couple of weeks a go at having to edit/highlight/ each individual email that I just stopped using my iPad for email. I now have over 700 emails in the inbox. Is there anyway to do a bulk delete without having to manually (activate the red dot)  check each email? I like to swipe and do a group delete.
    ie. empty the mailbox with one command.

    I just accidently found a way to delete all.  I went to search to find an app that I had buried in a folder.  When I typed it in, all references to it came up, including deleted emails.  I chose one of the deleted emails. It opened, but had Trash as the main folder, with an arrow to take me back to windstream (my POP account).  When I clicked the windstream option, Trash was one of the choices available. I chose trash, hit Edit at the top.  DELETE ALL was available at the bottom. I hope this helps.
    I apologize.  Your question was about deleting the inbox messages, which is what I was searching for when I found this.  Not only that, but you can get to trash much easier by just going down to your accounts. Duh!  Sorry I jumped the gun.  I hope you find a way to mass delete your inbox. If you do, please share!

  • How can I bulk delete songs from the playlist, if original file could not be found.

    I deleted the original files from the Library iTines. The songs are still in the playlist. How can I bulk delete songs from the playlist, if original file could not be found. Thank.

    Take a look at my FindTracks script. Download it and test it out on a few tracks first. Use the No option first time around to manually confirm each path that it wants to fix so you can see how it works. When you're happy it does what you want select a larger group of tracks to process automatically.
    tt2

Maybe you are looking for

  • Need help to connect from MacBook Air to a Dell 1610HD projector.

    I need to mirror the display on my MacBook Air to a projector, I've gone to the System Preferences and it detects my Apple TV but not the Projector need help.

  • Problem in message mapping while generating multiple record

    Hi experts,                  I am doing an idoc to file scenario in which E1FISEG SEGMENT is coming multiple time and if it contains two field ebeln & sgtxt then only it has to create corresponding data record I used following logic .............. ei

  • Scroll bar in Tree item

    hi I would like to know if there is a way to get rid of the scroll bar in a tree item.. normally in other applications, windows explorer for eg. when the contents of the explorer is within the view, the scroll bar disappears automatically and when th

  • Bank deposit not shown,

    dear experts , please you help me, my issue is  i am posting rs.10 00 000 in the house bank , but it is not shown, please help me , i am the new in sap fi, plz give me solution , and which t.code i use to solved the issue, thanks, akshaya

  • Help! Broken bezel or front moniter plate

    I tripped over my **** dial up internet cord and brought my ibook crashing to the ground, the front panel on the screen is broke i'm not sure what its called but its like warped, the LCD itself is perfectly fine (THANK GOD) but i'm not sure what to d