How to update a table that has around 1 Million Records

Hi,
Lets take the basic emp table for our Referenece and lets assume that it contains around 60000 Records and all the deptno in that table are Initially 10. Please provide an update statement which would update deptno column of EMP table((based on) order by EMPNO) in for every 120 records incrementing by 1.(DeptNo to be incremented by 1,like 10 ,11 , 12 etc).
First 120 Records deptno should be 10,
Next 120 Records deptno should be 11, and so on.
For Last 120 records deptno should be updated with 500.
Please advise.
Regards,

Ok, I've done it on a smaller set, incrementing every 5 records...
SQL> ed
Wrote file afiedt.buf
  1  update emp2 set deptno = (select newdeptno
  2                            from (select empno, 10+floor((row_number() over (order by empno)-1)/5) as newdeptno
  3                                  from emp2
  4                                 ) e2
  5                            where e2.empno = emp2.empno
  6*                          )
SQL> /
14 rows updated.
SQL> select * from emp2;
     EMPNO ENAME      JOB              MGR HIREDATE                    SAL       COMM     DEPTNO
      7369 SMITH      CLERK           7902 17-DEC-1980 00:00:00        800                    10
      7499 ALLEN      SALESMAN        7698 20-FEB-1981 00:00:00       1600        300         10
      7521 WARD       SALESMAN        7698 22-FEB-1981 00:00:00       1250        500         10
      7566 JONES      MANAGER         7839 02-APR-1981 00:00:00       2975                    10
      7654 MARTIN     SALESMAN        7698 28-SEP-1981 00:00:00       1250       1400         10
      7698 BLAKE      MANAGER         7839 01-MAY-1981 00:00:00       2850                    11
      7782 CLARK      MANAGER         7839 09-JUN-1981 00:00:00       2450                    11
      7788 SCOTT      ANALYST         7566 19-APR-1987 00:00:00       3000                    11
      7839 KING       PRESIDENT            17-NOV-1981 00:00:00       5000                    11
      7844 TURNER     SALESMAN        7698 08-SEP-1981 00:00:00       1500          0         11
      7876 ADAMS      CLERK           7788 23-MAY-1987 00:00:00       1100                    12
      7900 JAMES      CLERK           7698 03-DEC-1981 00:00:00        950                    12
      7902 FORD       ANALYST         7566 03-DEC-1981 00:00:00       3000                    12
      7934 MILLER     CLERK           7782 23-JAN-1982 00:00:00       1300                    12
14 rows selected.but the principle would be the same.

Similar Messages

  • How to update a table that has  Million Records

    Hi,
    Lets consider the basic EMP table and lets assume that it has around 20 Million Records . we need to have an update statement.Normal UPdate statement may hang the system or it may take a lot of time.
    The basic or Normal update statement goes like this and hope it may not work.
    update emp set hiredate = sysdate where comm is null and hiredate is null;Basic statement may not work. sugestions Needed.
    Regards,
    Vinesh

    sri wrote:
    I heard Bulk collect will resolve these type of issues and i am really poor at Bulk Collect concepts.Exactly what type of issue are you concerned with? The business requirements here are pretty important-- what problem is the UPDATE causing, specifically, that you are trying to work around.
    so looking for a solution to the problem using Bulk Collect .Without knowing the problem, it's very tough to suggest a solution. If you process data in batches using BULK COLLECT, your UPDATE statement will take longer to run and will consume more resources on the database. If the problem you are trying to solve is that your UPDATE is not fast enough, this is a poor approach.
    On the other hand, if you process data in batches, and do interim commits, you can probably hold locks on individual rows for a shorter amount of time. That would only be a concern, though, if you have some other process that is trying to update the same rows that you are updating at the same time that you're updating them, which is pretty rare. And breaking your update into multiple transactions introduces a whole bunch of complexity. You now have to write a bunch of code to ensure that your process is restartable should the update fail mid-way through leaving some number of updates committed and some number rolled back. You have to have a very detailed understanding of the data and data consistency to ensure that breaking up the transaction isn't going to negatively impact any process, report, etc. To do it correctly is a pile of work and then it's something that is constantly at risk of creating problems in the future when requirements change.
    In the vast majority of cases, you're better off issuing a simple SQL statement during a time when the system isn't particularly busy.
    Justin

  • How to update a table that has hundred thousand rows?

    Hi all !
    I detect that I did wrong with column SHAPE (in GRAG table ) ,namely at Gtype : 3003
    (MDSYS.SDO_GEOMETRY(3003,50632625,'null',MDSYS.SDO_ELEM_INFO_ARRAY(1,5,1,1,2,1),MDSYS.SDO_ORDINATE_ARRAY(276.2339,-179.7433,0,276.2498,-179.7361, 0 ))
    And I need to update value Gtype :3003 to 3002 .
    My problem is I don't know how to implement it because GRAG table has 30000 rows . I cannot update every row manually .
    Do you have any advice ?

    AFAIK oracle11g cannot simply update SDO_GEOMETRY.
    so you have to create new SDO_GEOMETRY with all but one old values.
    try to modify this (I wrote it once to circumvent the cannot modify SDO_GEOMETRY problem):
    -- clones a geometry but with different values
    -- we can "alter" the SRID
    -- note: oracle 11g cannot modify geometries
    function alter_geometry(p_geo sdo_geometry, p_srid number default null)
    return sdo_geometry is
    v_result sdo_geometry;
    v_srid number;
    begin
    if p_srid is null then
    v_srid := p_geo.SDO_SRID;
    else
    v_srid := p_srid;
    end if;
    v_result := sdo_geometry(p_geo.SDO_GTYPE,
    v_srid,
    p_geo.SDO_POINT,
    p_geo.SDO_ELEM_INFO,
    p_geo.SDO_ORDINATES);
    return v_result;
    end alter_geometry;
    --then do an update like
    --test before with an create table as select
    update crack c set c.shape = alter_geometry(shape, ...)

  • How to update a column which has 35 millions of rows?

    Hi everyone
    need help
    I am updating a column which has 35 millions of records. When i start update, it is taking like > 60 mins and its not stoping (finishing).
    I need to null that column A, and update that column A  with the other column B values.
    Thanks
    kumar

    Three common causes for big updates that are slow:
    blocking. You can check whether the UPDATE is waiting on another connection to release locks using sp_who2
    improperly sized log file. A big update may use of a lot of log space. If you log file is too small, and you have auto-grow enabled (which is the default setting), it will grow whenever needed. But this takes a lot of extra time. You can easily see this
    when you view the file size of the log file
    if the column you are updating is indexed, the engine may also you tempdb a lot, so tempdb may also grow a lot, which would take a lot of additional time. This is also easy to check by inspecting tempdb's file size
    Gert-Jan

  • How to update one table from another

    I am creating scripts in Oracle 10g. I have a table that has data corruption on three date fields.
    I created a table with the following sql of all the affected rows:
    CREATE TABLE LSU_INTER_FIX_DATE AS
    select request_id,received_date,planned_start_date, actual_start_date
    from lsu_inter2_requests_t
    where received_date < to_date('01-JAN-1900')
    OR planned_start_date < to_date('01-JAN-1900')
    OR actual_start_date < to_date('01-JAN-1900')
    I then repaired all of the rows with three data fixes
    UPDATE LSU_INTER_FIX_DATE
    SET received_date = TO_CHAR(received_date,'YY-MON') ||'-'||(TO_CHAR(received_date,'RRRR') + 2000)
    where received_date < to_date('01-JAN-1900')
    UPDATE LSU_INTER_FIX_DATE
    SET planned_start_date = TO_CHAR(planned_start_date,'YY-MON') ||'-'||(TO_CHAR(planned_start_date,'RRRR') + 2000)
    where planned_start_date < to_date('01-JAN-1900')
    UPDATE LSU_INTER_FIX_DATE
    SET actual_start_date = TO_CHAR(actual_start_date,'YY-MON') ||'-'||(TO_CHAR(actual_start_date,'RRRR') + 2000)
    where actual_start_date < to_date('01-JAN-1900')
    I now want to update the original base table with the corrected data so I wrote the following SQL UPDATE command:
    UPDATE lsu_inter2_requests_t aaa
    SET aaa.received_date = bbb.received_date
    FROM LSU_INTER_FIX_DATE bbb WHERE aaa.request_id = bbb.request_id
    When I run this sql Oracle returns the error “ORA-00933 SQL command not properly ended.” How do I update multiple rows in one table from another table that share the same primary key?

    Comet wrote:
    I am creating scripts in Oracle 10g. I have a table that has data corruption on three date fields.
    I created a table with the following sql of all the affected rows:
    CREATE TABLE LSU_INTER_FIX_DATE AS
    select request_id,received_date,planned_start_date, actual_start_date
    from lsu_inter2_requests_t
    where received_date < to_date('01-JAN-1900')
    OR planned_start_date < to_date('01-JAN-1900')
    OR actual_start_date < to_date('01-JAN-1900')
    I then repaired all of the rows with three data fixes
    UPDATE LSU_INTER_FIX_DATE
    SET received_date = TO_CHAR(received_date,'YY-MON') ||'-'||(TO_CHAR(received_date,'RRRR') + 2000)
    where received_date < to_date('01-JAN-1900')
    UPDATE LSU_INTER_FIX_DATE
    SET planned_start_date = TO_CHAR(planned_start_date,'YY-MON') ||'-'||(TO_CHAR(planned_start_date,'RRRR') + 2000)
    where planned_start_date < to_date('01-JAN-1900')
    UPDATE LSU_INTER_FIX_DATE
    SET actual_start_date = TO_CHAR(actual_start_date,'YY-MON') ||'-'||(TO_CHAR(actual_start_date,'RRRR') + 2000)
    where actual_start_date < to_date('01-JAN-1900')
    I now want to update the original base table with the corrected data so I wrote the following SQL UPDATE command:
    UPDATE lsu_inter2_requests_t aaa
    SET aaa.received_date = bbb.received_date
    FROM LSU_INTER_FIX_DATE bbb WHERE aaa.request_id = bbb.request_id
    When I run this sql Oracle returns the error “ORA-00933 SQL command not properly ended.” How do I update multiple rows in one table from another table that share the same primary key?I am not convinced you have what you think you have
    >
    UPDATE LSU_INTER_FIX_DATE
    SET received_date = TO_CHAR(received_date,'YY-MON') ||'-'||(TO_CHAR(received_date,'RRRR') + 2000)
    where received_date < to_date('01-JAN-1900')
    When you want to produce a DATE datatype when starting with a string,
    you must use TO_DATE() on the SET line!
    (TO_CHAR(received_date,'RRRR') + 2000)since when do you do add characters (from TO_CHAR) with a constant number (2000)?
    You should NEVER EVER rely on implicit datatype conversion
    Edited by: sb92075 on Jul 27, 2011 7:09 PM

  • How to update database table !!!

    hi all,
    Please advice how to update database table with certain cndition needs to be checked.
    Please consider below scenario.
    have used enqueu and dequeue function to lock entries  and also i have used BAPI so considering that return parameter . i want to update table
    /tdk/st0027.
    1. I want to update database table
    2. there are certain condition needs to be checked like ,
       loop at it_final into wa_final.
    th_return-type = 'S'.
               if th_final-vbeln = /tdk/st0027-vbeln and
                  th_final-posnr = /tdk/st0027-posnr and
                  th_final-etenr = /tdk/st0027-sdslno.
    above condition which i need to check .and need to append below system fields need to be appended in table.
              th_final-prstsind = '20'.
              th_final-chgdate  = g_date.
              th_final-chgtime  = g_uzeit.
              th_final-chgprog  = g_cprog.
              th_final-chguser  = g_uname.
              append th_final to td_final.
              update /tdk/st0027 FROM th_final.
              endif.
    endloop.
    but i am getting error saying that  "The type od database table and work area (TH_FINAL)  are not unicode convertible"?
    I am not able to understandwhat would be the solution for this ?
    Thanks and regards,
    Prasad K. NAralkar

    The error occurs in the UPDATE statement included in the code. In this statement it is seen that there is a mismatch of structure defined for the DDIC table /tdk/st0027 and that of your work area th_final.
    try to create a structure w.r.t the DDIC table.
    Eg: DATA: wa_temp TYPE /tdk/st0027.
    MOVE-CORRESPONDING th_final TO wa_temp.
    Then try to UPDATE using the temporary work area i.e wa_temp which has structure similar to that of the database table.

  • How to update the table available in BADI method

    Hi Friends,
    I have to implement one badi ME_REQ_POSTED for purchase requistion, in this badi  I have to read first line item and do
    some check...if that check is true i need to update subsequent line item (line 20, 30, 40 or so) with purchase group and MRP controller.
    In this BADI i have method POSTED, in this method parameter IM_EBAN is a table which i need to modify with my different
    values for purchase group and MRP controller.
    Kindly let me know how to update this table, so the changes can be reflected in purchase requistion.
    Since when I tried to directly modify the table in a loop, system throw one error stating IM_EBAN can not be modified.
    kindly help.
    pradeep

    hi
    I have implemented this exit but it does not stop at it while saving Purchase requistion. But my previous BADI stops at it when saving.
    Kindly guide.

  • How to update a table (CUSTOMER) on a Report Server with the data from the same table (CUSTOMER) from another server Transaction server?

    I had an interview question that is:
    How to update a table (Customer) on a server ex: Report Server with the data from the same table (Customer) From another server ex: Transaction server?
    Set up steps so inset, update or delete operation takes place across the servers.
    It would be great if someone please enlighten me in details about this process in MS SQL Server 2008 R2.
    Also please describe would it be different for SQL Server 2012?
    If so, then what are the steps?

    I had an interview question that is:
    How to update a table (Customer) on a server ex: Report Server with the data from the same table (Customer) from another server ex: Transaction server?
    Set up steps so that inset, update or delete operation gets done correctly across servers.
    I was not sure about the answer, it would be great if someone please put some light on this and explain in details about this process in MS SQL Server 2008 R2.
    Also it would be very helpful if you please describe would it be different for SQL Server 2012? If so, then what are the steps?

  • How to update Spry-table and present the updated table in a div element?

    Hello!
    I am using a very interesting AJAX-framework called Spry when designing a web page. Here the web page is: Link.
    I need some help.
    Every time a new project or shift is added, the changes are written to an xml-file. When the page is reloaded, Spry reads data from xml-files.
    This is caused by this code:
    dsProjects = new Spry.Data.XMLDataSet("timetable/projects.xml", "projects/project");
    dsShifts = new Spry.Data.XMLDataSet("timetable/{dsProjects::url}", "project/shift"); //look inside projects.xml and //extrac xml-file. url
    dsName = new Spry.Data.XMLDataSet("timetable/{dsProjects::url}", "project");
    I call this function that I have written: loadProjectsIntoDivElement ().
    This function does the following: [See attached code.]
    It iterates through the Spry-datastructure and puts the data in a table inside of the div-element called 'projectsList'.
    Now, when I add a new project, I want it to be inserted into the Spry-datastructure and then cause the new data to be written into the div element called 'Specials_DIV'.
    I have found out how to update a Spry-datastructure (e.g. dsProjects above), but I don't know how to update the table containing the data without refreshing the page. This should be done using Spry.
    Some code:
    1:
    2:
    3:
    function loadProjectsIntoDivElement () {
    $('#projectsList').html('');
    $('#projectsList').append('<table id="Specials_Table"><tr><th spry:sort="id">ID</th><th spry:sort="NAME">Name </th><th spry:sort="hoursestimated">Nr. of hours estimated</th><th spry:sort="hoursworked">Nr. of hours worked</th><th spry:sort="costperhour">Cost per hour.</th></tr>{function::init_hours}<tr spry:repeat="dsProjects" onclick="chooseProject({ds_RowID})"><td>{id}</td><td>{NAME}</td><td>{hoursestimated}</td><td>{hoursworked}</td><td>{costperhour}</td></tr></table><br/>{function::get_hours}<br/>');
    I have tried to accomplish this in various ways but I don't succeed.
    I want to do it without refreshing the page.
    Update: I found some code here that I will try: Link
    Thanks in advance!
    Anders Branderud
    My blog

    Hello!
    Thanks!
    I don't succeed with the implementation in any browser.
    I have found a way to it, but I would like a way that updates the data quicker and without reloading all of the page. After all, I am only adding one row on the end of the data structure, so there should be no need to read in all data again.
    Now I do it like this:
    When a project is added, do this:
    1. Store a new row in the project file through a php script.
    2. When the post-call to the php-file returns, do refresh of the whole page.
    Then the newest version of the xml file will be read in.
    However, I don't want to read the data from a xml file each time that a new project is created.
    I know how to add the new data to a Spry-datastructure [in my code 'dsProjects'], but I don't know how to display the updated data without reloading the whole page.
    I have tried some various ways to do it, but haven't succeded.
    Thanks!
    Anders Branderud

  • How to update a table containing BLOB?

    Hi,
    I'm trying to update two columns in a table.
    one is NUMBER and the other is BLOB
    Is there a way to do so in OCCI in a single operation ?
    the table looks like this:
    CREATE TABLE ACCUMULATORS
    (TARGET_SUBS NUMBER(9),
    ITERATOR NUMBER(9),
    NUMERATOR NUMBER(9),
    LARGE_DATA BLOB,
    PRIMARY KEY(TARGET_SUBS,ITERATOR));
    and the query is something like:
    UPDATE ACCUMULATORS SET NUMERATOR = :x1 , LARGE_DATA = :x2 WHERE (TARGET_SUBS = :x3) AND (ITERATOR = :x4);
    Thanks,
    Menachem

    I had an interview question that is:
    How to update a table (Customer) on a server ex: Report Server with the data from the same table (Customer) from another server ex: Transaction server?
    Set up steps so that inset, update or delete operation gets done correctly across servers.
    I was not sure about the answer, it would be great if someone please put some light on this and explain in details about this process in MS SQL Server 2008 R2.
    Also it would be very helpful if you please describe would it be different for SQL Server 2012? If so, then what are the steps?

  • How to export a form that has Asian language in it to CSV file? Currently the CSV file shows [...] for Asian language characters

    How to export a form that has Asian language in it to CSV file? Currently the CSV file shows [...] for Asian language characters

    Hi George,
    Thanks! It does work in XML format. But since I would need to present the data in a spreadsheet, is there any other way I could go around it?
    Cheers,
    Su Ann

  • How to update the table value in the valuechange event?

    I have an input field in the datatable with the valueChangeListener
    <rich:dataTable id="cart" value="#{cart.cartList}" var="item">
    <h:inputText value="#{item.cost}" id="qty" valueChangeListener="#{items.updateCost}" onchange="submit()">
    <h:outputText value="#{item.errorMsg}"> </h:outputText>
    in the backing bean
         Item item = (Item) model.getRowData();
    // do some update, if the cost too larger, change to max_cost
         item.setCost(max_cost);
         item.setErrorMsg("Error Msg");
    After calling the valuechange method, the screen output doesn't update the cost.
    How to update the table value in the valuechange event?

    As you're misusing the valueChangeListener to set another input field, you need to skip the update model values phase. Otherwise the value set in the valueChangeListener will be overridden by the submitted value. You can do this by calling the FacesContext#renderResponse() inside the valueChangeListener method. This will shift the current phase immediately to the render response phase, hereby skipping the update model values and invoke application phases.

  • How do I find music that has been uploaded to iTunes from a purchased CD and iTunes is "unable to find the original file?" I no longer have the CD. I have tried all the usual methods of looking in my iTunes library and through Find. No Luck.

    How do I find music that has been uploaded to iTunes from a purchased CD and iTunes is “unable to find the original file?” I no longer have the CD. I have tried all the usual methods of looking in my iTunes library and through Find. No Luck.

    Backup drive?
    Subscribe to iTunes Match?
    If neither of the above and you don't have the CD and can't find your tracks on the computer then they you're stuck.  A file recovery utility will cost $100, plus another $100 for an external drive to which to resue the files, and may not even work.  You can buy a lot of CDs for $200.

  • How to get PDF file that has been transformed into docx into my filing system so I can work on it???

    How can I get the PDF file that was transformed into a docx file into my filing system to be able to work on it and translate it as the customer requested?

    THanks for your reply.
    Well what happens is I bought the program. It gives you a button to click,
    you log in and then a box opens up asking you to select the file, I go into
    my filing system (in Windows explorer) select the file, and the program
    converts it into docx, my choice.  I can read it there and when I try to
    copy and paste it into my file where the PDF version is saved, it behaves
    like an "image", and I can't save it.... or it saves likes something you
    save on the internet, so you have to go into internet every time you want
    to see it.    I have also pressed any amount of buttons to see if it will
    give me the option to save it any other way, and have found nothing.  What
    I would need is a file in docx.format that I can edit.  People send me
    things in PDF and sometimes I can just copy it off the PDF file and save it
    in WOrd, then I can translate it for them. But sometimes the PDF file
    doesnt allow me to copy the text.  If it is in image form, I cannot work on
    it.  It means printing it, so I can copy type it into Word... and for that
    I certainly wouldnt need to buy a program.  Its just double the work and
    ends up that the job takes twice as long.!
    Sorry  if I am a bit dumb with informatics.  But I simply could not find
    any way whatever to  copy the PDF file that was transformed into Word, in a
    format that would enable me to edit it.
    Kindest regards,
    Margery
    2013/12/2 Test Screen Name <[email protected]>
        Re: How to get PDF file that has been transformed into docx into my
    filing system so I can work on it???
    created by Test Screen Name<http://forums.adobe.com/people/TestScreenName>in *Adobe
    ExportPDF* - View the full discussion<http://forums.adobe.com/message/5890871#5890871

  • HT4623 can i update my IPOD that has ios 4.2.1 to a least 6.0

    can i update my IPOD that has IOS 4.2.1 to a operation system that is at least 6.0 or higher

    If it's a second or third generation model, no.
    If it's a fourth, yes.
    If you don't know, append the last three characters of its serial number to http://www.everymac.com/ultimate-mac-lookup/?search_keywords= and load the page.
    (118814)

Maybe you are looking for

  • Store XML node value into an array with node element name

    Hi, I have the following code that displays the node element with the corresponding node value. I want to store the values in an array in reference to the node name. i.e. XML (my xml is much bigger than this, 300 elements): <stock> <symbol>SUNW</symb

  • Crashing on certain games

    When playing certain games with no other apps open, I'm still getting abrupt closing. "Sea Stars" after I finish, certain songs on "Groove Coaster", and "Early Bird" as soon as I attempt to start a game. Does this sound like something I need to send

  • Time Machine backup to Time Capsule clobbers wireless network

    Dear All, When TimeMachine starts a backup to my new Time Capsule, the wireless network gets clobbered. Other computers on the network's throughput to external sites goes to basically zero (slow ping times, dropped packets- basically unusable.) Is th

  • Clips stretching from QTP Pro to iMovie

    Have gone through similar questions and followed the suggested instructions, but can't seem to stop clips that have been rotated from landscape to portrait and resized in QuickTime Player Pro to stretching when imported to iMovie. Looks right in QTP,

  • Java Plug-in version mismatch crash IE8 with DEP error

    We are running Windows XP SP3 with IE8 and some of our internal sites that require JRE will crash the browser with a DEP error. The machines that exhibit this behaviour have multiple versions of JRE installed. However, we haven't been able to nail it