Commit delete

Hello,
I'm trying something new on this and I am wondering if anyone has ideas. In the past rollback segment size wasn't something that mattered. We could make them as big as we wanted. We can no longer do that so when I go to delete 4 million records from a table (can't use truncate because I'm using a where clause) I get "unable to extend rollback...." error. So I wrote this script that I thought would delete 10 records and then quit. (I would change it later to something larger.) Instead it gives the rollback error again. I've looked at other posts on this board but they seem a little complicated. Any ideas why this won't work?
set time on
set echo on
declare
cnt number(7) := 0;
tot number(7) := 0;
cursor C1 is select a.row_id from activity a
where a.row_id in (select b.row_id from activity2 b);
begin
for row_id in C1 loop
Delete from activity a where a.row_id in (select b.row_id from activity2 b);
tot := tot + 1;
cnt := cnt + 1;
if (cnt >= 10) then
          commit;
          close c1;
cnt := 0;
end if;
end loop;
commit;
dbms_output.put_line('activity records deleted: '||tot);
end;
/

Andrew:
Which sketch?
I have no real metrics for this, but I use this approach fairly regularly when refreshing a test environment from our production data to get rid of uneeded history. For a several million row table, the threshold appears to be deleting 40% or more of the table. I suspect that as table size increases, the threshold will decrease somewhat. One of these days, I will do some metrics.
Finding space is realtively easy, unless you are seriously constrained at the filesystem level. What I usually do if there is no space in an existing tablespace is create a new tablespace to hold the temporary data, then drop it when finished. This beats expanding rollback to accomodate the delete, since the space is not permanently allocated.
Also, you can usually enable constraints with NOVALIDATE, since the data was good originally. In John's case, I suspect that there are no foreign keys since he is deleting such a large percentage of the table.
TTFN
John

Similar Messages

  • How can I implement the equivilent of a temporary table with "on commit delete rows"?

    hi,
    I have triggers on several tables. During a transaction, I need to gather information from all of them, and once one of the triggers has all the information, it creates some data. I Can't rely on the order of the triggers.
    In Oracle and DB2, I'm using temporary tables with "ON COMMIT DELETE ROWS" to gather the information - They fit perfectly to the situation since I don't want any information to be passed between different transactions.
    In SQL Server, there are local temporary tables and global.  Local temp tables don't work for me since apparently they get deleted at the end of the trigger. Global tables keep the data between transactions.
    I could use global tables and add some field that identifies the transaction, and in each access to these tables join by this field, but didn't find how to get some unique identifier for the transaction. @@SPID is the session, and sys.dm_tran_current_transaction
    is not accessible by the user I'm supposed to work with.
    Also with global tables, I can't just wipe data when "operation is done" since at the triggers level I cannot identify when the operation was done, transaction was committed and no other triggers are expected to fire.
    Any idea which construct I could use to acheive the above - passing information between different triggers in the same transaction, while keeping the data visible to the current transaction?
    (I saw similar questions but didn't see an adequate answer, sorry if posting something that was already asked).
    Thanks!

    This is the scenario: If changes (CRUD) happen to both TableA and TableB, then log some info to TableC. Logic looks something like this:
    Create Trigger TableA_C After Insert on TableA {
      If info in temp tables available from TableB
            Write info to TableC
       else
           Write to temp tables info from TableA
    Create Trigger TableB_C After Insert on TableB {
      If info in temp tables available from TableA
            Write info to TableC
       else
           Write to temp tables info from TableB
    So each trigger needs info from the other table, and once everything is available, info to TableC is written. Info is only from the current transaction.
    Order of the triggers is not defined. Also there's no gurantee that both triggers would fire - changes can happen only to TableA / B and in that case I don't want to write anything to TableC.
    The part that gets and sets info to temp table is implemented as temp tables with "on commit delete rows" in DB2 / Oracle.
    What do you think? As I've mentioned, I could use global temp tables with a field that would identify the transaction, but didn't find something like that in SQL Server. And, the lifespan of local temp tables is too short.

  • Cannot commit delete row from VO

    I have a VO that I have no problem create new row, update existing row and commit. But I can't commit deleted row to database. no exception or error message etc... and All other VOs are working fine,
    anybody has any idea why? is that an option or something on VO? or is it an BC4J bug?
    Thanks,
    -Ming
    Edited by: user715460 on Oct 16, 2008 3:40 PM

    You are in the wrong forum. Try your question JDeveloper and ADF .
    And please consider this too (copied from this thread Concerned in delayed response
    a) Use a good subject line that briefly describes the issue. This will attract those familiar with that area to come and help.
    b) Tell us what database version you are using. Not just saying e.g. "10g" but more specifically "10.2.0.3"
    c) Describe the issue clearly stating what you have tried, and what you are trying to achieve.
    d) Don't use txt spk because this is a professional forum, not a chat room and not everyone can follow it.
    e) Don't USE CAPITAL LETTERS IN YOUR DESCRIPTION as this is considered shouting and agressive.
    f) Provide sample data for us to use if necessary either with the CREATE TABLE and INSERT statements to create it or providing a WITH clause that we can use. This saves us from having to type in and format the sample data for ourselves and is more likely to attract us to help.
    g) Show the code that you have already tried (if you haven't tried any code yet then why not? have a go yourself and only ask for help when you get stuck).
    h) Show us any error messages you are getting, in full, and with information of the line numbers where the error is occurring
    i) Wherever you provide data or code remember to use the tag before and after or the [code] tag before and the [/code] tag after, so that it keeps it's layout and is clear to read.
    j) Perhaps one of the most important things of all... never suggest that you need a solution "urgently" or that your issue is "urgent". This implies that your issue is somehow more important than the issues posted by other people. Everybody would like an answer to their issue promptly, but it just depends when people are online who can answer the question and nobody is being paid to answer it, so it is arrogant and rude to demand urgent attention to your own. If something is that urgent then you should raise it through oracle metalink as a priority issue or pay for someone with the necessary skills to come and do the work for you.
    Timo                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • ADF view : auto commit delete  operation

    I have created a ADF table with add and delete operation. When I perform delete operation it is not committing automatically.
    Can you please suggest the way to auto commit the delete operation.
    Thanks,
    Kiran

    User,
    please always tell us your jdev version as the solution might depend on it.
    There is no auto commit in ADF. You can program it so that after an add or delete the data gets committed but there is nothing done automatically.
    if you use a bounded task flow you can drag the operation from the data control onto the task flow and navigate to it after you have done the add or delete operation.
    Timo

  • Interesting scenario on Partial Commit - Deletion of EO

    Hi all,
    Jdev Version: Studio Edition Version 11.1.1.7.0
    Business Requirement: Need to partially commit the deletion of one row (say Row-A) in EO and serialize another row (an addition say Row-B) for committing after approval.
    How we achieve this:
    Step 1 - Make the change in Row-A & Row-B on my main AM (AM1).
    Step 2 - create a parallel new root AM (AM2) and make the changes that need to be partially committed on the VO/EO in this new root AM (AM2) and issue commit on this AM (AM2).
    Step 3 - Now after the partial commit, am back to AM1 where I would like to serialize only the change on Row-B. So I call the remove() on Row-A and passivate.
    Step 4- On my offline approval page, I invoke activate to show the new addition Row-B for approval post which I can invoke commit.
    Issue we face: When we passivate in Step 3, the deletion of Row-A also gets passivated. As a result, this row shows up on my approval screen. On my approval screen, only Row-B should be displayed.
    Appreciate your inputs on this issue.
    Thanks,
    Srini

    Hi,
    row A will be deleted with the next commit the way you put it. My interpretation is you want to remove it from the collection in which case you would call removeRowFromCollection on the VO. Instead of what you are doing here I would consider a soft-delete in which you set a delete flag on a row instead of deleting or commiting it. You can then use a custom RowMatcher on a VO to filter those entities out in which case you only see those for approval that you need to see.
    For partial commits, I would use a different strategy. Create a headless task flow (no view activity just a method activity and a return activity) and have it configured to not share the Data Control (isolated) You then pass in the information for the row to commit, query it in the method activity (through a VO) update the VO and commit the change using the commit method from the DataControl frame (you get this through the BindingContext class.
    This is more declarative and reusable than creating an AM just for this purpose. However, keep in mind that the callingg task flow still things Row A is changed (as it doesn't participate in the commit. So what you do is to call row.refresh() and issue DB forget changes as an argument so Row A is reset to the state that is in the database
    Frank

  • Commit after deleting records

    Hi All,
    I wrote one delete command .This command deletes 20 millions of records.But I want to give "commit" after deleting every 100000 records. How to give "commit" for this requirement.
    please guide me.
    Thank you.

    Depends on your delete statement.
    Sometime you can group the delets into logical units.
    Compare and consider the following three approaches.
    1) This deletes all data from all previous months.Delete from myTable where insertDate < trunc(sysdate,'mm'))
    2) Delete each month separately and commit in between.Delete from myTable where insertDate < trunc(sysdate,'year'));
    commit;
    Delete from myTable
    where insertDate >= trunc(sysdate,'year'))
    and insdate < add_months(trunc(sysdate,'year'),1) -- "january"
    and insdate < trunc(sysdate,'mm')) -- do not delete too much!
    commit;
    Delete from myTable
    where insertDate >= trunc(sysdate,'year'))
    and insdate < add_months(trunc(sysdate,'year'),2) -- "February"
    and insdate < trunc(sysdate,'mm')) -- do not delete too much!
    commit;
    Delete from myTable
    where insertDate >= trunc(sysdate,'year'))
    and insdate < add_months(trunc(sysdate,'year'),3) -- "March"
    and insdate < trunc(sysdate,'mm')) -- do not delete too much!
    commit;
    Delete from myTable
    where insertDate >= trunc(sysdate,'year'))
    and insdate < add_months(trunc(sysdate,'year'),12) -- "December"
    and insdate < trunc(sysdate,'mm')) -- do not delete too much!
    commit;
    3) Delete based on ID and logical groups
    Select min(id), max(id) into v_min, v_max
    from myTable where insertDate < trunc(sysdate,'mm'));
    for i in 1..trunc(v_max-v_min)/100000)+1 loop
      delete from myTable
      where id >= v_min+((i-1)*100000)
      and id < v_min+(i*100000)
      and id <= v_max
      and insertDate < trunc(sysdate,'mm')) -- this line is not really needed, maybe remove it depending on the execution plan.
      commit;
    end loop;

  • Data lost/Rows deleted after commit

    Dear all,
    I am struggling with a very critical issue in oracle 10g express.
    I have done following steps...
    01. Create table Sawan
    02. insert into Sawan
    03. select count(*) from Sawan; (This returns 1)
    04. commit;
    05. select count(*) from Sawan; (This returns 0)
    The problem here is after commitng, rows has been deleted.
    Please suggest for any possible reason as soon as possible.
    Thanks
    Sawan

    As soon as possible,hmmm!
    Well this is only possible if you have created a temp table.See this,
    SQL> create global temporary table temptab
      2  on commit delete rows
      3  as select * from dept;
    SP2-0640: Not connected
    SQL> conn scott/tiger
    Connected.
    SQL> create global temporary table temptab
      2  on commit delete rows
      3  as select * from dept;
    Table created.
    SQL> select * from temptab;
    no rows selected
    SQL> insert into temptab select * from dept;
    4 rows created.
    SQL> select * from temptab;
        DEPTNO DNAME          LOC
            10 ACCOUNTING     NEW YORK
            20 RESEARCH       DALLAS
            30 SALES          CHICAGO
            40 OPERATIONS     BOSTON
    SQL> commit;
    Commit complete.
    SQL> select * from temptab;
    no rows selected
    SQL>This is on 11106,win xp prof.
    If this i not what you have done than you want to try out XE forum.Yo may have hit a bug of it.
    Aman....

  • Making a delete commit automatically with ADF BC, Struts and ADF UIX

    I'm trying to create a delete action that commits to the database automatically using ADF Business Components, Struts and ADF UIX.
    I have a browse page from which the user can view all records in the table, and perform edit, create and delete actions on the data.
    When the user selects a record and clicks edit they are taken to a screen where they can amend the details of that record. Create works in a similar way, but the create action on the view object is invoked before taking the user to the edit page (this is done by linking the browse page to an ADF DataAction (bound to Create) on the Struts page flow diagram, and then linking the ADF DataAction to the edit page).
    When the user clicks submit on the edit page, the container follows a forward from the edit page to an ADF DataAction bound to the Commit method, and then from there a forward back to the browse page.
    This seems to work fine for edit and create, but when I try to do something similar for delete, it behaves unpredictably - sometimes the delete is committed to the database, sometimes not.
    To be more specific, the way I have tried to implement the auto commit delete is as follows:
    There is a UIX submitButton on the browse page called Delete. When clicked, this button triggers an event, which is caught by an event handler inside the page. The event handler causes the UIX servlet to take a forward to an ADF DataAction bound to the Delete method on the relevant view object. It thens follows a forward from the previously mentioned DataAction to another ADF DataAction bound to the Commit method for the application module. There is then a forward leading back to the browse page.
    Has anyone else encountered similar problems?

    did you figure this out?

  • Delete DML statment tales more time than Update or Insert.

    i want to know whether a delete statement takes more time than an update or insert DML command. Please help in solving the doubt.
    Regards.

    I agree: the amount of ROLLBACK (called UNDO) and ROLLFORWARD (called REDO) information written by the various statement has a crucial impact on the speed.
    I did some simple benchmarks for INSERT, UPDATE and DELETE using a 1 million row simple table. As an alternative to the long UPDATEs and DELETEs, I tested also the usual workarounds (which have only partial applicability).
    Here are the conclusions (quite important in my opinion, but not to be taken as universal truth):
    1. Duration of DML statements for 1 million rows operations (with the size of redo generated):
    --- INSERT: 3.5 sec (redo: 3.8 MB)
    --- UPDATE: 24.8 sec (redo: 240 MB)
    --- DELETE: 26.1 sec (redo: 228 MB)
    2. Replacement of DELETE with TRUNCATE
    --- DELETE: 26.1 sec (rollback: 228 MB)
    --- TRUNCATE: 0.1 sec (rollback: 0.1 MB)
    3. Replacement of UPDATE with CREATE new TABLE AS SELECT (followed by DROP ols and RENAME new AS old)
    --- UPDATE: 24.8 sec (redo_size: 240 MB)
    --- replacement: 3.5 sec (rollback: 0.3 MB)
    -- * Preparation *
    CREATE TABLE ao AS
        SELECT rownum AS id,
              'N' || rownum AS name
         FROM all_objects, all_objects
        WHERE rownum <= 1000000;
    CREATE OR REPLACE PROCEDURE print_my_stat(p_name IN v$statname.NAME%TYPE) IS
        v_value v$mystat.VALUE%TYPE;
    BEGIN
        SELECT b.VALUE
          INTO v_value
          FROM v$statname a,
               v$mystat   b
         WHERE a.statistic# = b.statistic# AND lower(a.NAME) LIKE lower(p_name);
        dbms_output.put_line('*' || p_name || ': ' || v_value);
    END print_my_stat;
    -- * Test 1: Comparison of INSERT, UPDATE and DELETE *
    CREATE TABLE ao1 AS
        SELECT * FROM ao WHERE 1 = 2;
    exec print_my_stat('redo_size')
    *redo_size= 277,220,544
    INSERT INTO ao1 SELECT * FROM ao;
    1000000 rows inserted
    executed in 3.465 seconds
    exec print_my_stat('redo_size')
    *redo_size= 301,058,852
    commit;
    UPDATE ao1 SET name = 'M' || SUBSTR(name, 2);
    1000000 rows updated
    executed in 24.786 seconds
    exec print_my_stat('redo_size')
    *redo_size= 545,996,280
    commit;
    DELETE FROM ao1;
    1000000 rows deleted
    executed in 26.128 seconds
    exec print_my_stat('redo_size')
    *redo_size= 783,655,196
    commit;
    -- * Test 2:  Replace DELETE with TRUNCATE *
    DROP TABLE ao1;
    CREATE TABLE ao1 AS
        SELECT * FROM ao;
    exec print_my_stat('redo_size')
    *redo_size= 807,554,512
    TRUNCATE TABLE ao1;
    executed in 0.08 seconds
    exec print_my_stat('redo_size')
    *redo_size= 807,616,528
    -- * Test 3:  Replace UPDATE with CREATE TABLE AS SELECT *
    INSERT INTO ao1 SELECT * FROM ao;
    commit;
    exec print_my_stat('redo_size')
    *redo_size= 831,525,556
    CREATE TABLE ao2 AS
        SELECT id, 'M' || SUBSTR(name, 2) name FROM ao1;
    executed in 3.125 seconds
    DROP TABLE ao1;
    executed in 0.32 seconds
    RENAME ao2 TO ao1;
    executed in 0.01 seconds
    exec print_my_stat('redo_size')
    *redo_size= 831,797,608

  • Problem with deleting record from the report.

    This is my first post here, just to let you know I just started playing with Apex.
    Here we go:
    I have a page with report where the link to the record I have changed with ULR to the javascript:
    javascript:doDelete(#RECORD_ID#)
    I have created javascript in the HTML Header of the page
    <script>
    function doDelete(id) {
    if (confirm("Are you sure you want to delete selected record?"))
    $x('P3_DEL_ID').value=id;
    doSubmit('DELETE');
    </script>
    and finally created a process for the page On Submit - After Computations and Validations.
    declare
    var_id number := :p3_del_id;
    begin
    commit;
    Delete from mytable where record_id = var_id;
    commit;
    end;
    I don't get error messages but record is not deleted.
    Thanks for help in advance.
    Robert

    Robert,
    That's the problem. With that type selected, change the value in the textbox to just: DELETE
    Regards,
    Dan
    http://danielmcghan.us
    http://sourceforge.net/projects/tapigen
    http://sourceforge.net/projects/plrecur
    You can reward this reply by marking it as either Helpful or Correct ;-)

  • Global Temporary Table not deleting Rows

    why is my Global temp table not deleting the rows after commit see below,
    CREATE GLOBAL TEMPORARY T_CHG
    TBE VARCHAR2(7),
    ABC VARCHAR2(8),
    EFDA VARCHAR2(6),
    ABD VARCHAR2(9),
    A_ID VARCHAR2(128),
    C_DATE,
    ON COMMIT DELETE ROWS;

    Quite a few syntax issues with your create statement. It would have helped if you had posted a SQL*Plus session showing your results. Here is mine which works just fine:
    sql>create global temporary table t_chg
      2  (
      3  tbe varchar2(7),
      4  abc varchar2(8),
      5  efda varchar2(6),
      6  abd varchar2(9),
      7  a_id varchar2(128),
      8  c_date date
      9  )
    10  on commit delete rows;
    Table created.
    sql>insert into t_chg values ('1', '2', '3', '4', '5', sysdate);
    1 row created.
    sql>select count(*) from t_chg;
    COUNT(*)
            1
    1 row selected.
    sql>commit;
    Commit complete.
    sql>select count(*) from t_chg;
    COUNT(*)
            0
    1 row selected.

  • Commit in sp  having  globle table and function with autonomus transaction

    hi gurus,
    1)  i want to know if we populate a globle table in sp  then give  commit  then weather data will be present in globle table or not ..?
    globle table :-
    ON COMMIT delete  ROWS
    NOCACHE;
    2)  in same sp if we call a function having  autonomus transaction  and commit  then wath will happen ..

    1) i want to know if we populate a globle table in sp then give commit then weather data will be present in globle table or not ..?
    globle table :-
    ON COMMIT delete ROWS
    NOCACHE;Data will be deleted from the Global Temporary Table.
    2) in same sp if we call a function having autonomus transaction and commit then wath will happen ..Data Will not be deleted from the Global Temporary Table.

  • How Increase performance of delete operation

    Hi,
    How Increase performance of delete operation. This delete is done on a table which has around millions of records and loaded back every day .
    The statement is in a procedure and is as follows.
    #$%%$#$;
    commit;
    delete from TVRBC_SITE_ROLLUP_T;
    commit;

    Hi,
    execute immediate 'truncate table TVRBC_SITE_ROLLUP_T';
    Regards,
    Oleg
    Message was edited by:
    tsiboleg

  • DDL time changes on commit of Global temporary table

    Hi,
    I have created a global temporary table with on commit delete rows.
    Whenever I execute commit command the DDL time of the global temporary table changes.
    Just wanted to know whether commit on Global temporary table is DDL. I had expected it to be an DML operation.
    Thanks,
    Pawan

    I do not get that effect:
    orcl112> create global temporary table gtt1(c1 date);
    Table created.
    orcl112> select last_ddl_time from user_objects where object_name='GTT1';
    LAST_DDL_TIME
    2013-07-22 12:44:02
    orcl112> insert into gtt1 values(sysdate);
    1 row created.
    orcl112> commit;
    Commit complete.
    orcl112> select last_ddl_time from user_objects where object_name='GTT1';
    LAST_DDL_TIME
    2013-07-22 12:44:02
    orcl112> select * from v$version;
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    PL/SQL Release 11.2.0.3.0 - Production
    CORE    11.2.0.3.0      Production
    TNS for 64-bit Windows: Version 11.2.0.3.0 - Production
    NLSRTL Version 11.2.0.3.0 - Production
    orcl112>

  • How to display warning message before deleting a record?

    Hi all
    I want to display a warning popup message( "Do you realy want to delete the record? Yes - No" ) before user delete a record. My page fragment contains simple <af:table> which display the employees data and operations buttons "commit - delete - rollback"
    I use Jdeveloper release 11.1.4
    Database : oracle 10g
    Thanks in advance

    Thank you so much for replaying
    I have another question related to creating popup
    I have page template and only one jspx page based on the template named"UIShell.jspx"
    I make a lot of page fragments , I have - untill now- about 15 page fragments.
    all these fragments are shown as dynamic regions within UIShell.jspx"
    My question is
    Should I create popup dialog window in each page fragment in order to display the messages?
    If the answer is "YES" this will not be a good approach - I think.
    Is there a way to create just one popup dialog and use it an any page fragments.
    Regards
    Edited by: ta**** on Apr 17, 2011 8:44 AM

Maybe you are looking for

  • Agentry HTTP-XML Step Bad Request Error

    Hi, I try to get data via HTTP-XML connection on Agentry. 1)  I defined HTTPXML Sytem Connection then added Validate User Request for GET method with URL: http://www.thomas-bayer.com/sqlrest/PRODUCT/      I did not defined Request Argumanets because

  • MM consigment stock : how to do statistical GR

    dear all we are in the process of prototyping an MM consigment route. we have done the following 1. Info record created with Info type as consigment 2. PO created with Item category as K 3. GR with Movement type 101 done with Category K the part is s

  • Wont vibrate any more

    My iPhone wont vibrate anymore, I've tried restarting it, and checking the vibrate settings. It says its on but nothing happens.

  • Creating video aps for Iphone downloads?

    I didn't want to cross post the same post. I made the original one in the Compressor forum since my question dealt with video compression first. Here's the thread: http://discussions.apple.com/thread.jspa?threadID=2582515&stqc=true Can you create vid

  • RH7: import HTMLHelp

    We have cracked our skulls because of this one, and now we are afraid that this is just a really dumb question. Simple scenario (and this also happens with other scenarios of course): In RoboHelp 7 HTML: 1) create a new Microsoft HTML Help project 2)