How to update a table with huge data

Hi,
I have a scenario where I need to update tables that are having huge data (each table is having more than 10,00000)
I am writing this update in PLSQL block.
Is there any way to improve the performance of this update statement? Please suggest...
Thanks.

user10403630 wrote:
I am storing all tables and columns that needs to be updated in tab_list and forming a dynamic qry.
for i in (select * from tab_list)
loop
v_qry := 'update '||i.table_name||' set '|| i.column_name ' = '''||new_value||'''' ||' where '||i.column_name = ''||old_value||'''';
execute immediate v_qry;
end loop;Sorry to say so but this code is aweful!
Well the only thing to make this even more slow would be to add a commit inside the loop.
Some advices. But I'm not sure which one works in your case.
The fastest way to update a million rows is: write a single update statement. On typical systems this should only run for like a couple of minutes.
if you need to update several tables then write a single update for each table.
If you have different values that need to be updated then find a way how to consider those different values in a single update or merge statement. Either by joining another table or by using some in-lists.
e.g.
update myTable
set mycolumn = decode(mycolumn
                                 ,'oldValue1','newvalue1'
                                 ,'oldValue2','newvalue2'
                                 ,'oldValue3','newvalue3')
where mycolumn in ('oldValue1','oldvalue2','oldvalue3'....);If you need to do this in pl/sql then
1) use bind variables to avoid hard parsing the same statement again and again
2) use bulk binding to avoid pl/sql context switches

Similar Messages

  • How to update two tables with trigger

    Hi:
    how to update two tables with trigger ?
    I have two tables :
    (1)ASIA
    MI number;
    (2)ASIA_P
    ID number;
    When I insert a new value into the asia.MI ,I also can
    insert the same value into the asia_p.id field.
    I have write a trigger as follows but it does't work.
    create or replace trigger MI_TRG
    before insert on asia
    for each row
    declare
    seq number;
    begin
    select MI_SEQ.Nextval into seq from dual;
    :new.MI:=seq;
    insert into ASIA_PRO(MI_ID)
    values
    (seq);
    end MI_TRG;
    How to realize it ?
    thanks
    zzm

    Why do you say it does not work?

  • How to fill internal table with no data in debugging mode

    Hi all,
             I modified one existing program.Now I want to test it.I am not given test data.So in the middle of my debugging, I found that one internal table with no data.My problem is how to fill that internal table with few records in that debugging mode just as we change contents in debugging mode.If I want to proceed further means that internal table must have some records.
    Please I dont know how to create test data so I am trying to create values temporarily in debugging mode only.
    Thanks,
    Balaji

    Hi,
    In the debugging do the following..
    Click the Table button..
    Double click on the internal table name..
    Then in the bottom of the screen you will get the buttons like CHANGE, INSERT, APPEND, DELETE..
    Use the APPEND button to insert records to the internal table..
    Thanks,
    Naren

  • How to Update EKPO table with enhancement at header level-customer data tab

    Experts,
    I have a requirement where I had to create a new button in the 'customer data' tab(header) in the ME21N/ME22N Transaction and once it gets clicked a table control will appear and in that all the line items with item no, material and plant and an additional check box will display, and once any one checks the check box against the item/material in the table control the item data with additional z fields (already created the zfields in EKPO Table) should get updated.
    Displaying Table control and item data on the click of button was successful, but once you check the check box against the item and save the PO it is not updating the z-fields in the EKPO table.
    I have implemented all the user exits , badis but no results. 
    Once you check the box in the table control against each item in the header part (Table control is in header part (customer tab)) the line item EKPO table with z fields should get updated.
    Any Clues/ideas will be appreciated.
    Thanks in advance,
    Kalikonda.

    Hi,
    Can you please share the remedy for above issue, recently we have same issue in our system.
    or please send me any supportive doc. for the below mail
    Looking forward for your positive response.
    Thanks
    Mohan
    ([email protected])

  • How to update Nested tables with xsu

    Hello,
    I have three tables.
    1) DEPARTMENT_TAB
    2) EMPLOYEE_TYP
    3) ADDRESS_TYP
    ADDRESS_TYP is a collection and it is nested inside EMPLOYEE_TYP.
    EMPLOYEE_TYP is a collection and it is nested inside DEPARTMENT_TAB.
    created with below scropt
    CREATE TYPE ADDRESS_TYP AS OBJECT (CITY VARCHAR2(10), STATE VARCHAR2(2));
    CREATE TYPE ADDRESS_TYP_NT AS TABLE OF ADDRESS_TYP;
    CREATE TYPE EMPLOYEE_TYP AS OBJECT (EMPNO NUMBER(4), ENAME VARCHAR2(10), ADDRESS_VAR ADDRESS_TYP_NT);
    CREATE TYPE EMPLOYEE_TYP_NT AS TABLE OF EMPLOYEE_TYP;
    CREATE TABLE DEPARTMENT_TAB (DEPTNO NUMBER(4), DNAME VARCHAR2(10), EMPLOYEE_VAR EMPLOYEE_TYP_NT)
         NESTED TABLE EMPLOYEE_VAR STORE AS EMPLOYEE_TAB
         ( NESTED TABLE ADDRESS_VAR STORE AS ADDRESS_TAB);
    I inserted two rows in DEPARTMENT_TAB and their nested tables using normalsql. and i generated below xml content using XSU java API
    oracle.xml.sql.query.OracleXMLQuery
    My Question is How to UPDATE a row in ADDRESS_TAB using XSU java API
    oracle.xml.sql.dml.OracleXMLSave.
    (When i was trying to update address_tab nested table's row with xml input file. it is deleting other existing rows)
    Thanks.

    Why do you say it does not work?

  • How to update a table with strin that contains &

    Hi,
    I would like to update ename col of emp table with a string that contains &
    update emp set ename = 'tom&jerry' where empno = 7369But this gives an error.Please advice.
    Regards,

    Consult the sql*plus reference manual on how to disable the &
    Software engineers should be capable of doing research themselves, please stop abusing this forum to increase your salary by being spoon fed for free.
    Sybrand Bakker
    Senior Oracle DBA

  • How to update application table with notification id

    What is the best method for updating an application table with the notification id of a notification just generated.
    We tried creating a suspended activity with a delay but it only works randomly. Sometimes the suspended update activity runs before the notification is generated and the update fails. Thanks, Tom

    Well, you could do a select in WF_NOTIFICATIONS and check if you application table is updated.
    select NOTIFICATION_ID from WF_NOTIFICATIONS where MESSAGE_TYPE like 'item type name'
    But as you noticied, notification id is not created immediately.
    Hope could help.
    Regards,
    Luiz

  • How to update database table with key field?

    Hello Experts,
    I have a database table with following fields
    MATNR   - Key
    SSOUR  -  Key
    KUNNR   - Key
    MENG1 
    MENG2
    MENG3
    And this table contains records like...
    MSD50001     R      1000001     5.30    2.30    5.25
    MSD50002     R      1000002     5.30    2.30    5.25
    MSD50003     R      1000003     5.30    2.30    5.25
    MSD50005     R      1000004     5.30    2.30    5.25
    MSD50004     R      1000005     5.30    2.30    5.25
    I have an internal table with same fields of above database table.
    MSD50001     A      1000001     5.30    2.30    5.25
    MSD50002     A      1000002     5.30    2.30    5.25
    MSD50003     A      1000003     5.30    2.30    5.25
    MSD50005     A      1000004     5.30    2.30    5.25
    MSD50004     A      1000005     5.30    2.30    5.25
    MSD50006     A      1000006     5.30    2.30    5.25
    I want to update the DB table with following internal table records.
    If internal table records = db table records are same then Update....else insert from internal table to db table.
    But here, SSOUR is key field so i am not able to use
    MODIFY dbtab from itab.
    It results me , entries in internal table are inserted into db table.
    So i have double records.
    Is there any statement which updates the key field? and if no fields in db table then insert it?
    Regards
    RH

    hi,
    u cannot update akey field.u can update only non key fields by using key field as a selection criteria.For example if u go to sm30 if u enter any table for inserting values, the key field will always be greyed out it is not succumbed to chnges.but u can insert value into ,if ur inserting and in the insert staemnet if  u have key field which is already present in the table it will return sy-subrc = 4 otherwise it will insert the record and return 0.
    eg for update :
    UPDATE zdm_wtyprof  SET upload_status = 'S'
                             WHERE spart = wa_upd-spart.
    here spart is the key field and it will update the status field in the table as S.
    if updated succesfully it will return 0.
    SIMILARLY U CAN USE select.

  • How to update Z table with delivery number using MV50AFZ1

    Hi Friends,
    I am working with user exit MV50AFZ1/ USEREXIT_SAVE_DOCUMENT.
    My requirement is I have a Ztable with delivery number field (initially blank). If I create a delivery thru sales order VA02 , my created delivery number should get populated/updated in my Ztable.
    I would appreciate if someone could help me on this.
    Thanks.

    Hi
    First of all, read SAP Note 415716 - User exits in delivery processing, as for instance, avoid your own COMMIT WORK.
    For instance, as the sample code suggests, the better is encapsulate your ABAP coding in a function module with the option IN UPDATE TASK. Define the interface with the data that you need (XLIKP, XLIPS, XVBUK, and so on), after in your own coding (for instance)
    FUNCTION Z_SAVE_DELIVERY
         IMPORTING
           VALUE(IM_LIKP) TYPE SHP_LIKP_T.
       DATA: w_zeta LIKE z_table.
       DATA: ty_likp TYPE likp.
      LOOP AT im_likp INTO ty_likp.
         MOVE-CORRESPONDING ty_likp TO w_zeta.
         MODIFY z_table FROM w_zeta.            "or your own algorithm, searching records and modify them.
      ENDLOOP.
    In the userexit you can do this coding:
      CALL FUNCTION 'Z_SAVE_DELIVERY' IN UPDATE TASK
          EXPORTING
                im_likp = xlikp.
    I hope this helps you
    Regards
    Eduardo
    Edited by: E_Hinojosa on Jun 21, 2011 5:49 PM

  • How to update a table with if condition

    here is my table 
    Party1 party2 DELFlag
    JON     NYC     0
    JON     NYC1   0 
    SAM     NYC   0
    SAM    NYC1   0
    TOM     NYC1   0
    GIT      NYC1   0
    No I need to change all NYC1 to NYC , but I get primary key error As JON is already related to JON->NYC  in this case I need to make the flag to 1 
    To be more specific JON->NYC1 must be JON-NYC1-1 and TOM-NYC1-0 must change to TOM-NYC-0 as tom does not have any records 
    My table update must look like 
    Party1 party2 DELFlag
    JON     NYC     0
    JON     NYC1   1
    SAM     NYC   0
    SAM    NYC1   1
    TOM     NYC   0
    GIT      NYC   0

    I can't use this INSERT INTO @partyRock (Party1, Party2, DELFLag) VALUES my table has thousands of rows and other relations even 
    Dont want to create a new table as this is in all my prod servers , want to update 
    Party1 party2 DELFlag
    JON     NYC     0
    JON     NYC1   0 
    SAM     NYC   0
    SAM    NYC1   0
    TOM     NYC1   0
    GIT      NYC1   0
    SDS      ORD 0
    DED      MEX  0
    Update output table
    Party1 party2 DELFlag
    JON     NYC     0
    JON     NYC1   1
    SAM     NYC   0
    SAM    NYC1   1
    TOM     NYC   0
    GIT      NYC   0
    SDS      ORD 0
    DED      MEX  0

  • How to Update ESTMJ table with appended fields

    Attempting to do a mass load of data to table ESTMJ. Tried using an LSMW, but took a very long time...days in fact. Added a couple Z fields to this table in an append structure. Attempting to run BAPI_BUS1077_CREATE to add records, but how do I update the new Z fields using this BAPI?

    Hi,
    the af:column allows you to group columns
    <af:column>
    <af:column> </af:column>
    <af:column> </af:column>
    </af:clomn>
    Also, in HTML it is easy to assign a background color to cell, e.g. cell with Label 1 is red, Label 2 is green.
    Is there something like this in JSF?
    You can use CSS on the inlineStyl or contentStyle property to dynamically set CSS using EL. You can reference e.g. a managed bean , access the #{row} variable within the managed bean method and return the color based on the value you read for the each row
    Frank

  • How to update a table with the time of insert instead of time of commit

    dear,
    i have 10 record at source side which needs to be injected in a target table ;
    the record creation date is injected with the systimestamp -
    when commiting it takes for all the same timestamp for all records( at commit time ) however I would like to insert the timestamp at INSERT moment to have a unique timestamp - id est at INSERT time.
    Can anyone please adviseN?
    Thanks
    Erik
    Edited by: 845498 on 29-aug-2012 1:36

    845498 wrote:
    dear,
    when commiting it takes for all the same timestamp for all records( at commit time ) Not true about commit time. True about same time. Function SYSDATE is always calculated once for SQL statement no matter how many times and for how many rows it is referenced. So when you issue:
    insert
      into target(insert_date)
      select sysdate
        from  source
    /All inserted rows will have same insert_date. Now keep in mind, Oracle date datatype precision is one second. So unless your insert of 10 rows takes more than a second (which would be a problem on its own), date precision will not give you what you want. You would need timestamp. But again, same as SYSDATE, SYSTIMESTAMP is called once per statement. To call it row each row and reference you need to create user-defined function:
    create or replace
      function get_systimestamp
        return timestamp
        is
        begin
            return systimestamp;
    end;
    /Now:
    SQL> select  systimestamp,
      2          get_systimestamp
      3    from  hr.employees
      4  /
    SYSTIMESTAMP                        GET_SYSTIMESTAMP
    29-AUG-12 01.55.23.656000 PM -04:00 08/29/2012 13:55:23.671000000
    29-AUG-12 01.55.23.656000 PM -04:00 08/29/2012 13:55:23.687000000
    29-AUG-12 01.55.23.656000 PM -04:00 08/29/2012 13:55:23.687000000
    29-AUG-12 01.55.23.656000 PM -04:00 08/29/2012 13:55:23.687000000
    29-AUG-12 01.55.23.656000 PM -04:00 08/29/2012 13:55:23.687000000
    29-AUG-12 01.55.23.656000 PM -04:00 08/29/2012 13:55:23.687000000
    29-AUG-12 01.55.23.656000 PM -04:00 08/29/2012 13:55:23.687000000
    29-AUG-12 01.55.23.656000 PM -04:00 08/29/2012 13:55:23.687000000
    29-AUG-12 01.55.23.656000 PM -04:00 08/29/2012 13:55:23.687000000
    29-AUG-12 01.55.23.656000 PM -04:00 08/29/2012 13:55:23.687000000
    29-AUG-12 01.55.23.656000 PM -04:00 08/29/2012 13:55:23.687000000
    SYSTIMESTAMP                        GET_SYSTIMESTAMP
    29-AUG-12 01.55.23.656000 PM -04:00 08/29/2012 13:55:23.687000000
    29-AUG-12 01.55.23.656000 PM -04:00 08/29/2012 13:55:23.687000000
    29-AUG-12 01.55.23.656000 PM -04:00 08/29/2012 13:55:23.687000000
    29-AUG-12 01.55.23.656000 PM -04:00 08/29/2012 13:55:23.687000000
    29-AUG-12 01.55.23.656000 PM -04:00 08/29/2012 13:55:23.687000000
    29-AUG-12 01.55.23.656000 PM -04:00 08/29/2012 13:55:23.765000000
    29-AUG-12 01.55.23.656000 PM -04:00 08/29/2012 13:55:23.765000000
    29-AUG-12 01.55.23.656000 PM -04:00 08/29/2012 13:55:23.765000000
    29-AUG-12 01.55.23.656000 PM -04:00 08/29/2012 13:55:23.765000000
    29-AUG-12 01.55.23.656000 PM -04:00 08/29/2012 13:55:23.765000000
    29-AUG-12 01.55.23.656000 PM -04:00 08/29/2012 13:55:23.765000000.
    .SY.

  • How to update database table with this new internal table

    hi
    i have a internal table having 8 records and it contains one record which was modified by user
    not i want this new record to be updated to the database table which was modified by the user
    how to do it pls suggest?
    i want to use index for comarision as using index will not have any problems like promary key etc
    like i want to capture the index for this table which was modified thr recoed index and use thi record indext to modify the database table
    or any other suggestion
    regards
    nishant

    Hi Nishant,
    Have an additional field in a table to indicate a change with which you avoid in updating the record modified by user.
    Regards,
    Madhu.

  • How to update a table with ALV list reocrds

    Dear All,
    I have a requirement to display records in ALV list and these records
    should get updated in a table and I should also be able to insert new
    records in an ALV list.
    Could any  body  please let me know how to do this. This is an urgent requirement.

    You can use Table Control instead. Check the following examples in SE38
    demo_dynpro_tabcont_loop
    demo_dynpro_tabcont_loop_at
    RSDEMO_TABLE_CONTROL
    Regards
    Gopi

  • Updating a table with the data from the select list

    I have 2 select lists on a page...first select list displays vendor no and vendor name from the table vendor (vendor_no, vendor_name, address, city, state, zip, ph no)
    second list displays contact no and contact name from the table contact (contact_no, contact_name, email_addrs)
    i have a submit button...once it is clicked the vendor_no from the first list and the contact_no from the second list must be inserted into the third table vendor_contact (vendor_contact_no, contact_no, vendor_no) and also there must be a condition to check if the entry already exists or not...can any one tell me how this can be done...

    Why not design your page just on your third table (vendor_contact), and those fields (which will already be defined as part of that table) can be defined there as your select lists. Then make sure you have a Primary Key (or Unique Key) defined on the table to prevent duplicates.
    It makes for a much cleaner looking page, and far easier to implement as well.
    Hope this made sense and helps.
    Bill Ferguson

Maybe you are looking for

  • Macbook Pro screen blacks out keys stay lit

    The gist of it is in the subject Pretty much without warning, does not have a preference for type of application being ran, the screen will completely black out. If sound is being play it either stops or begins to skip. The keys stay lit. The only wa

  • Unable to compile class for JSP--- help me plz!!!!!

    hi friends; Pease suggest me where i am wrong, i think javabean is not instantiated in jsp file.may be it is related to the classpath of javabean. i have not set any variable for javabean classpath. and i put javabean class file in TOMCAT_HOME/webapp

  • Export to query ready mode

    In version 11.1.2 when exporting a report to query ready mode from workspace we are getting an HRdialogue error message. However when I turn off the POV preview in user preferences it works. Anyone else experiencing this? Thanks, Jeff

  • IDOc posting  error

    hai friends iam getting idocs form xi system (matmas) in this MBEWM segement  is repeting meny times in this segment BWTAR field some times not having any value at that time if the that segement is is first segment then it is posting proparly but if

  • How long does it take BT to install a telephone po...

    I've moved to a cottage in a rural area of Scotland. There's no telephone line but there is a telephone pole in the front of the house that provides a line to the house next door. BT were due to connect the line and provide a telephone and broadband