Transferring data from one table to few new tables

Hi,
I have a table that contains millions of records. I need to transfer the records from that table to few new tables. For a future convenient purpose, the data is being splitted into multiple new tables. I am planning to use a cursor to fetch the records from the old table and call a new procedure in a loop. The new procedure is the one doing the split and inserts into different tables. Also I am planning to commit each 10,000 records. This is because I am planning to store the primary key in a temp table each time and to store the error message in another temp log table. So that I can rerun the same query multiple times to complete this transfer. I know doing in a loop and frequent commit will affect the performance. But I feel those 2 is required in my scenario. Can anyone suggest a better way if any?
Thanks

check if "create onesmaletable as select col1, col4, colwhatever from hugetable" (CTAS) works for you.
hth

Similar Messages

  • Transferring data from one table to another table using a Keycolumn using SSIS row by row dynamically

    Hi All,
    I have a Store Procedure(SP) which has a output variable name "AcivityID" which is the key column. In this SP, transformation  of data is done from one table to insert data into other table. I have to execute the SP and insert row by row data
    using the output variable "ActivityID"  whose value will keep on changing. How can I do it?
    Thanks,
    Kallu

    Value changing on a row by row basis? Not quite sure what you mean, but it seems that you want to use the results of an insert into one table as input for another. If so then SSIS is not needed, inside the stored proc use the SQL that will do that and for
    all records as
    INSERT A INTO dbo.table1
    OUTPUT INSERTED.A INTO MyTable;
    Arthur My Blog

  • Transfering Data from One table to another

    Hi all,
    Can we transfer data from Cluster Table to ZTABLE (Transparent Table)?
    if Yes, How can we do that?
    Thanks
    Devinder

    Hi,
    Generating a (surrogate) primary key value is usually done using:
    A) an Oracle sequence to generate a number
    B1) refer to the NEXVAL of the sequence in your insert statements
    or
    B2) a trigger on your agents table that populates agent_id by referring to the NEXTVAL of the sequence.
    Both approaches have pro's and con's, see what best fits your requirement.
    See this explanation (including examples):
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:6575961912937#tom6583848685931
    Also, since you're new to SQL, check the [Oracle docs|http://www.oracle.com/pls/db102/homepage].
    (Or http://www.oracle.com/pls/db112/homepage if you're on 11G)
    Especially the Concepts and Fundamentals.

  • Transferring data from one HDD to a new HDD using disk utility?

    I do not have a time machine backup of my HDD.  I was wondering if it is posssible to use disk utility to restore data from the old HDD to the new HDD.  Will I need the system disks to partition the new HDD first or is this even possible.  If it is possible, will everything transfer using the Restore in disk utility?

    How to replace or upgrade a drive in a laptop
    Step One: Repair the Hard Drive and Permissions
    Boot from your OS X Installer disc. After the installer loads select your language and click on the Continue button. When the menu bar appears select Disk Utility from the Installer menu (Utilities menu for Tiger, Leopard or Snow Leopard.) After DU loads select your hard drive entry (mfgr.'s ID and drive size) from the the left side list.  In the DU status area you will see an entry for the S.M.A.R.T. status of the hard drive.  If it does not say "Verified" then the hard drive is failing or failed. (SMART status is not reported on external Firewire or USB drives.) If the drive is "Verified" then select your OS X volume from the list on the left (sub-entry below the drive entry,) click on the First Aid tab, then click on the Repair Disk button. If DU reports any errors that have been fixed, then re-run Repair Disk until no errors are reported. If no errors are reported click on the Repair Permissions button. Wait until the operation completes, then quit DU and return to the installer.
    If DU reports errors it cannot fix, then you will need Disk Warrior and/or Tech Tool Pro to repair the drive. If you don't have either of them or if neither of them can fix the drive, then you will need to reformat the drive and reinstall OS X.
    Step Two: Remove the old drive and install the new drive.  Place the old drive in an external USB enclosure.  You can buy one at OWC who is also a good vendor for drives.
    Step Three: Boot from the external drive.  Restart the computer and after the chime press and hold down the OPTION key until the boot manager appears.  Select the icon for the external drive then click on the downward pointing arrow button.
    Step Four: New Hard Drive Preparation
      1. Open Disk Utility in your Utilities folder.
      2. After DU loads select your new hard drive (this is the entry with the
          mfgr.'s ID and size) from the left side list. Note the SMART status of
          the drive in DU's status area.  If it does not say "Verified" then the drive
          is failing or has failed and will need replacing.  Otherwise, click on the
          Partition tab in the DU main window.
      3. Under the Volume Scheme heading set the number of partitions from
          the drop down menu to one. Set the format type to Mac OS Extended
          (Journaled.) Click on the Options button, set the partition scheme to
          GUID  then click on the OK button. Click on the Partition button and
          wait until the process has completed.
      4. Select the volume you just created (this is the sub-entry under the
          drive entry) from the left side list. Click on the Erase tab in the DU main
          window.
      5. Set the format type to Mac OS Extended (Journaled.) Click on the
          Options button, check the button for Zero Data and click on OK to
          return to the Erase window.
      6. Click on the Erase button. The format process can take up to several
          hours depending upon the drive size.
    Step Five: Clone the old drive to the new drive
      1. Open Disk Utility from the Utilities folder.
      2. Select the destination volume from the left side list.
      3. Click on the Restore tab in the DU main window.
      4. Check the box labeled Erase destination.
      5. Select the destination volume from the left side list and drag it to the
          Destination entry field.
      6. Select the source volume from the left side list and drag it to the
          Source entry field.
      7. Double-check you got it right, then click on the Restore button.
    Destination means the new internal drive. Source means the old external drive.
    Step Six: Open the Startup Disk preferences and select the new internal volume.  Click on the Restart button.  You should boot from the new drive.  Eject the external drive and disconnect it from the computer.

  • Transferring data from one table to another

    I have two tables.i have some information existing in one of the tables.this information is defined at the broadest possible level e.g. Level A has one row.
    I have to transfer this information to the other table when asked to by the user, but the problem is that the other table needs to have 64 rows created corresponding to the single row in the first table,i.e the other table will have 64 rows corresponding to a single row in the first table.
    This needs to be done as quickly as possible so that the system does not hang and the other processing logic continues.
    Moreover the first table can have more rows and each row may have 64 instances created in the other table when asked to by the user.
    Please help if anyone has answer to this query.Any kind of algorithm will help.

    Walk through the fist table, and for each row make 64 inserts.
    Do it in one transaction (i.e. without autocommit) to speed it up a bit and improve data consistency. Don't forget to commit at the end. If that seems to be too slow, you can always make a stored procedure to do the same to avoid round trip time for each insert statement if the database is on another machine...

  • Transferring data from one to another table

    I am getting delayed in transffering data from one table to another for the purpose of
    making archieve of a transaction table.
    The number of records in question are about five million and the time taking is
    about 3 to 5 hours in Oracle 10g database in Sun SOLARIS config.
    can any one help me in reducing this time

    >> I am getting delayed in transffering data from one table to another for the purpose of making archieve of a transaction table.
    How you are trying to transferring the data? i.e. What commands you are using for this?
    Regards,
    Sabdar Syed.

  • Copying large amount of data from one table to another getting slower

    I have a process that copies data from one table (big_tbl) into a very big archive table (vb_archive_tbl - 30 mil recs - partitioned table). If there are less than 1 million records in the big_tbl the copy to the vb_archive_table is fast (-10 min), but more importantly - it's consistant. However, if the number of records is greater than 1 million records in the big_tbl copying the data into the vb_archive_tbl is very slow (+30 min - 4 hours), and very inconsistant. Every few days the time it takes to copy the same amount of data grows signicantly.
    Here's an example of the code I'm using, which uses BULK COLLECT and FORALL INSERST to copy the data.
    I occasionally change 'LIMIT 5000' to see performance differences.
    DECLARE
    TYPE t_rec_type IS RECORD (fact_id NUMBER(12,0),
    store_id VARCHAR2(10),
    product_id VARCHAR2(20));
    TYPE CFF_TYPE IS TABLE OF t_rec_type
    INDEX BY BINARY_INTEGER;
    T_CFF CFF_TYPE;
    CURSOR c_cff IS SELECT *
    FROM big_tbl;
    BEGIN
    OPEN c_cff;
    LOOP
    FETCH c_cff BULK COLLECT INTO T_CFF LIMIT 5000;
    FORALL i IN T_CFF.first..T_CFF.last
    INSERT INTO vb_archive_tbl
    VALUES T_CFF(i);
    COMMIT;
    EXIT WHEN c_cff%NOTFOUND;
    END LOOP;
    CLOSE c_cff;
    END;
    Thanks you very much for any advice
    Edited by: reid on Sep 11, 2008 5:23 PM

    Assuming that there is nothing else in the code that forces you to use PL/SQL for processing, I'll second Tubby's comment that this would be better done in SQL. Depending on the logic and partitioning approach for the archive table, you may be better off doing a direct-path load into a staging table and then doing a partition exchange to load the staging table into the partitioned table. Ideally, you could just move big_tbl into the vb_archive_tbl with a single partition exchange operation.
    That said, if there is a need for PL/SQL, have you traced the session to see what is causing the slowness? Is the query plan different? If the number of rows in the table is really a trigger, I would tend to suspect that the number of rows is causing the optimizer to choose a different plan (with your sample code, the plan is obvious, but perhaps you omitted some where clauses to simplify things down) which may be rather poor.
    Justin

  • Insert old missing data from one table to another(databaase trigger)

    Hello,
    i want to do two things
    1)I want to insert old missing data from one table to another through a database trigger but it can't be executed that way i don't know what should i do in case of replacing old data in table_1 into table_2
    2)what should i use :NEW. OR :OLD. instead.
    3) what should i do if i have records exising between the two dates
    i want to surpress the existing records.
    the following code is what i have but no effect occured.
    CREATE OR REPLACE TRIGGER ATTENDANCEE_FOLLOWS
    AFTER INSERT ON ACCESSLOG
    REFERENCING NEW AS NEW OLD AS OLD
    FOR EACH ROW
    DECLARE
    V_COUNT       NUMBER(2);
    V_TIME_OUT    DATE;
    V_DATE_IN     DATE;
    V_DATE_OUT    DATE;
    V_TIME_IN     DATE;
    V_ATT_FLAG    VARCHAR2(3);
    V_EMP_ID      NUMBER(11);
    CURSOR EMP_FOLLOWS IS
    SELECT   EMPLOYEEID , LOGDATE , LOGTIME , INOUT
    FROM     ACCESSLOG
    WHERE    LOGDATE
    BETWEEN  TO_DATE('18/12/2008','dd/mm/rrrr') 
    AND      TO_DATE('19/12/2008','dd/mm/rrrr');
    BEGIN
    FOR EMP IN EMP_FOLLOWS LOOP
    SELECT COUNT(*)
    INTO  V_COUNT
    FROM  EMP_ATTENDANCEE
    WHERE EMP_ID    =  EMP.EMPLOYEEID
    AND    DATE_IN   =  EMP.LOGDATE
    AND    ATT_FLAG = 'I';
    IF V_COUNT = 0  THEN
    INSERT INTO EMP_ATTENDANCEE (EMP_ID, DATE_IN ,DATE_OUT
                                ,TIME_IN ,TIME_OUT,ATT_FLAG)
         VALUES (TO_NUMBER(TO_CHAR(:NEW.employeeid,99999)),
                 TO_DATE(:NEW.LOGDATE,'dd/mm/rrrr'),       -- DATE_IN
                 NULL,
                 TO_DATE(:NEW.LOGTIME,'HH24:MI:SS'),      -- TIME_IN
                 NULL ,'I');
    ELSIF   V_COUNT > 0 THEN
    UPDATE  EMP_ATTENDANCEE
        SET DATE_OUT       =  TO_DATE(:NEW.LOGDATE,'dd/mm/rrrr'), -- DATE_OUT,
            TIME_OUT       =   TO_DATE(:NEW.LOGTIME,'HH24:MI:SS'), -- TIME_OUT
            ATT_FLAG       =   'O'
            WHERE EMP_ID   =   TO_NUMBER(TO_CHAR(:NEW.employeeid,99999))
            AND   DATE_IN <=  (SELECT MAX (DATE_IN )
                               FROM EMP_ATTENDANCEE
                               WHERE EMP_ID = TO_NUMBER(TO_CHAR(:NEW.employeeid,99999))
                               AND   DATE_OUT IS NULL
                               AND   TIME_OUT IS NULL )
    AND   DATE_OUT  IS NULL
    AND   TIME_OUT IS NULL  ;
    END IF;
    END LOOP;
    EXCEPTION
    WHEN OTHERS THEN RAISE;
    END ATTENDANCEE_FOLLOWS ;
                            Regards,
    Abdetu..

    INSERT INTO SALES_MASTER
       ( NO
       , Name
       , PINCODE )
       SELECT SALESMANNO
            , SALESMANNAME
            , PINCODE
         FROM SALESMAN_MASTER;Regards,
    Christian Balz

  • Moving Data from one table to another table

    Hi,
    I've a requirement to move large volumes (few billions) of data from one table to another empty target table. The target has more number of attributes and may not have same attribute name as the source. Please let me know what's the best method using oracle to move data in this case?
    Thanks in Advance,
    Tom

    You should use nologging and parallelism options
    Please refer to Tom's answers:
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:164612348068
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:6407993912330
    Kamran Agayev A. (10g OCP)
    http://kamranagayev.wordpress.com
    [Step by Step install Oracle on Linux and Automate the installation using Shell Script |http://kamranagayev.wordpress.com/2009/05/01/step-by-step-installing-oracle-database-10g-release-2-on-linux-centos-and-automate-the-installation-using-linux-shell-script/]

  • Simple way to insert data from one table

    Hi,
    I need to know a simple way on how to transfer the data from one table to another....
    First table xx_inv_tab1 has three columns col1, col2, col3 and where as second table xx_inv_tab2 has five columns col1, col2, col3, col4, col5.
    Here col2, col3, col4 are the same columns as in table1 xx_inv_tab1...
    Now I want to transfer first table data in to second table .... first column of second table holds a sequence, followed by the first table three columns data and followed with col4 and col5 which will hold NULL values....
    In my scenario, I have 70 - 75 columns in my first table which I want to move to second table which three new columns (one is sequence and other two has null values)...
    Any ideas if we make it in a simplest way rather saying insert into xx_inv_tab2 (col1, col2, col3 ............................................. col75) values (seq, col1, col2..........................col75, null, null)
    Help Appreciated..
    Thanks

    Easy
    untested
    insert into xx_inv_tab2 t2 (col1,col2,col3,col4)
    select yourSequence.nextval, t1.col1, t1.col2, t1.col3
    from xx_inv_tab1 t1
    ;Note that col5 does not need to be used, since you want to fill it with NULL.
    USe excel or sql developer to write you a list of column names, if you are to lazy to write all 75 columns by yourself.
    What might also work:
    untested
    insert into xx_inv_tab2 t2
    select yourSequence.nextval, t1.*, null
    from xx_inv_tab1 t1
    ;Edited by: Sven W. on Aug 31, 2012 4:41 PM

  • MySQL move date from one table to another

    I was wondering if there is a MySQL command that will let me move a selected row of data from one table to another. both tables have the same columns and declaration type (one table is actually an archived table on old data)
    example
    I wasnt to move all data in Table1 where the date is greater than 30 days old to Table 2
    -- so the result should be...import all rows to Table 2 where the date is greater than 30 days old..and delete all date from Table 1 that is greater than 30 days.
    currently..I'm doing three process
    1) get all row that is greater than 30 days  
        "SELECT * FROM Table1 WHERE TO_DAYS(NOW()) - TO_DAYS(dateField) > 30"
    2) insert data into Table2
        while (res.hasNext())
              TableData data = ..... // .get row
              dataList.add(data);
              for (int i = 0; i < dataList.size(); i++){
                    pstm.setString.....
                    pstm.addBatch()
              pstm.executeBatch();
    3) delete data from Table1
        "DELETE FROM Table 1 WHERE  TO_DAYS(NOW()) - TO_DAYS(dateField) > 30"

    for this app..losing a few rows does not
    impact on how we analyze the data.That's what everyone always tells me too. But 99% of the time they come back and want to know why the cannot balance and/or validate the data between two runs taken only minutes from each other.
    I've seen people puzzle over data for days that they swear they ran the exact same utility for their tests, but they were in fact using live data, and additional data had accrued but since all they had to do was execute the a script without parameters (they didn't put in a stop time), they got two different answers and it always, and I mean always confuses people. Be safe, and put the option in for and end date/time, then when they waste days trying to figure out why the two different observations gave them different numbers, they cannot blame you (because you gave them the option)!
    My 2 cents for the day...

  • Adding Data From One Table to Another

    Now, this doesn't strike me as a particularly complex problem, but I've either strayed outside the domain of Numbers or I'm just not looking at the problem from the right angle. In any case, I'm sure you guys can offer some insight.
    What I'm trying to do is, essentially, move data from one table to another. One table is a calendar, a simple two column 'date/task to be completed' affair, the other is a schedule of jogging workouts, i.e, times, distances. Basically, I'm trying to create a formula that copies data from the second table onto the first but only for odd days of the week, excepting Sundays (and assuming Monday as the start of the week). Now, this isn't the hard part, I can do that. The problem comes when I replicate the formula down the calendar. Even on the days when the 'if' statement identifies it as an 'even day', the cell reference to the appropriate workout on the second table is incremented, so when it comes to the next 'odd day', it has skipped a workout.
    I can't seem to see any way of getting it to specifically copy the NEXT line in the second table, and not the corresponding line.
    This began as a distraction to try and organise my running so I could see at a glance what I had to do that day and track my progress, but now it's turned into an obsession. SURELY there's a solution?
    Cheers.

    Hi Sealatron,
    Welcome to Apple Discussions and the Numbers '09 forum.
    Several possible ways to move the data occur to me, but the devil's in the details of how the data is currently arranged.
    Is it
    • a list of three workouts, one for each of Monday, Wednesday and Friday, then the same three repeated the following week?
    • an open-ended list that does not repeat?
    • something else?
    Regards,
    Barry

  • Moving time-dependant data from one table to another (archiving)

    Hello all
    I would like to know if there's an easier solution or a "best practice" to move data from one table to another. The context of this issue can be found within "archiving".
    More concretely: we have an application that uses several tables to log information to.
    These tables are growing like crazy, and we would like to keep only "relevant" data in those tables, so I was thinking about moving data from these tables that have been in there for, say 2 months, to "archiving" tables.
    I figured there must be some kind of "best practice" to get this done.
    I have already written a procedure that loops the table that has the time indicator and inserts the records from the normal tables into the archive tables (and afterwards delete this data), but it seems to be taking ages to get it done.
    Thanks in advance!
    Message was edited by:
    timschraepen

    There is nothing to do with PL/SQL.
    You can refer below links:
    http://www.lc.leidenuniv.nl/awcourse/oracle/server.920/a96524/c12parti.htm
    http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10739/partiti.htm#i1006727

  • How do I transfer data from one time capsule to new time capsule when TC backs up an iMac and Power Book

    How do I transfer data from one time capsule to new time capsule when TC backs up an iMac and MacBookPro

    It is generally better to leave the old backups and start again.. unless there is something you particularly need.
    But if you desperately want all the old backups you have to copy the sparse bundles.. this will take very long time as it must copy via the computer..
    http://pondini.org/TM/18.html
    Take particular note of the initial comments.. ie before you read how to do it.. don't do it.

  • Copying data from one table to another table thru java

    Hi
    I have to copy data from table emp in Database A to table emp in Database B. My input would be table name and number of rows to be fetched. these rows i need to insert in table B.
    The problem over here is I won't be having any info. of table emp i.e the number of columns it has and their type.
    So is their any way i can copy the data from one table to other without having the info abt the number of cols and their type.
    TIA

    Cross post - http://forum.java.sun.com/thread.jspa?threadID=5169293&messageID=9649839#9649839

Maybe you are looking for

  • Create a reservation without a purchase order

    Hi all, I try to create a reservation without a purchase order for material T-RN133, and then i got a message, " Order 800040 is flagged for deletion". Then i tried to create another reservation, but still got the same error message. THe movement typ

  • Color mismatch between Lightroom when edits done in Photoshop

    I am having a lot of problems since I upgraded to Photoshop 5 and Lightroom 3.  When I go to edit a particular photo in Photoshop from LIghtroom the photo changes once I have saved it back into Lightroom (despite making no alterations whatsoever in P

  • Wageytypes which are newly created  are not showing up in the prod.server

    Hi Experts, I have newly created 2 new wagetypes. 1.Arrears on housing loan subsidy  2,arrears on Vehicle loan subsidy They are properly showing up in Dev server and properly transported to Quality Server.IN Quality server also it is popping the new

  • COPA document in ETO (Engineer to Order) Scenario with milestone billing

    Hi All I have some issue in COPA document generation in ETO Scenario. In ETO scenario, we have following important points --- Milestone billing (30 % downpayment, 60% on shipping and remaining 10% with closing invoice) in the Billing plan. --- We hav

  • Need few lines script (Mail)

    Hi!.. Because of some troubles with my provider, I find thousands of duplicate messages in my MBOX folder. Well, I'm looking for a script that says to Mail: "Check the MBOX folder: If you find messages with the same sender, the same title, the same d