Copy contents of one table to another

Hi,
Can anyone will give me the code copying the contents of one table to another...
Need an urgetn help..
Thanks

Thanks for everyones reply...
But here the problem
I to copy the content based on the length of the content
Eg:
If the content key code has 3 characteristics then where ever the last 2 characters are similar i need to copy the rrest content
EG:-
234
236
278
299
288
that means i need to take the last two characteristic and copy the rest data ...
another option
23411
23412
23413
23414
in this i need to check the last 4 characters and copy...
Can any one help..
Another important point is it need to copy in different fields ...
Eg: from where i am copying is FIELD A which has all the data and it need to copy in Field1,2,3,4,5,6,7,8
Thanks

Similar Messages

  • T code to Copy Data from one table to another table

    Hi,
    I want copy all data of one table to its copy table. Anyone knows transaction code to copy data from one table to another table.
    Regards,
    Jigar Thakkar.

    Hi
    Create a small program.
    Extract data from T1 - database table and put it in one internal table - itab1.
    loop the itab1 data .............
        insert itab1 into tab2.   (tab2 - second database table)
    endloop.
    try this....
    hope it works....

  • How to copy data from one table to another (in other database)

    Hi. I would like to copy all rows from one table to another (and not use BC4J). Tables can be in various databases. I have already 2 connections and I am able to browse source table using
    ResultSet rset = stmt.executeQuery("select ...");
    But I would not like to create special insert statement for every row . There will be problems with date formats etc and it will be slow. Can I use retrieved ResultSet somehow ? Maybe with method insertRow, but how, if ResultSet is based on select statement and want to insert into target table? Please point me in the right direction. Thanks.

    No tools please, it must be common solution. We suceeded in converting our BC4J aplication to PostgreSQL, the MSSQL will be next. So we want to write simple aplication, which could transfer data from our tables between these 3 servers.

  • Trigger to copy records from one table to another;  ORA-04091:

    Hello,
    I'm trying to create a trigger that will move data from one table to another.
    I have two tables (Trial1, Trial2) Both of them contains the same attributes (code, c_index)
    I want to move each new record inserted in (code in Trial1) to (code in Trial2)
    This is my trigger:
    Create or replace trigger trg_move_to_trial2
    After insert on Trial1
    for each row
    begin
    insert into Trial2 (code)
    select :new.code from Trial1;
    end;It compiled, but when I insert new (code) record into (Trial1) it display this error:
    Error report:
    SQL Error: ORA-04091: table STU101.TRIAL1 is mutating, trigger/function may not see it
    ORA-06512: at "STU101.TRG_MOVE_TO_TRIAL2", line 3
    ORA-04088: error during execution of trigger 'STU101.TRG_MOVE_TO_TRIAL2'
    04091. 00000 - "table %s.%s is mutating, trigger/function may not see it"
    *Cause:    A trigger (or a user defined plsql function that is referenced in
    this statement) attempted to look at (or modify) a table that was
    in the middle of being modified by the statement which fired it.
    *Action:   Rewrite the trigger (or function) so it does not read that table.I know what does this error mean, but I don't how to fix the error.
    I tried to change the (After insert on Trial1) to be (Before insert on Trial1); that worked, but not in the right way. When I insert new value into (code in Trial1) and refreshed Trial2 table, as much as records I have in Trial 2 they will be duplicated. E.g.
    Trial2
    code
    111
    222
    333when I insert in Trial1
    Trial1
    code
    444
    Trial2 will be:
    code
    111
    222
    333
    444
    444
    444Can you please tell me how to solve this issue?
    Regards,
    Edited by: 1002059 on Apr 23, 2013 5:36 PM

    You should not select from Trial1 - you have the data already. Just insert that value.
    Create or replace trigger trg_move_to_trial2
    After insert on Trial1
    for each row
    begin
    insert into Trial2 (code)
    values (:new.code);
    end; regards,
    David

  • Copy data from one Table to another Table

    How can I copy data from one Oracle Table to another Oracle Table on a different server? Question 2: How can I clear all of the data in one Table with a single SQL script?
    Thanks...

    Question 1:
    I assume you have the privileges. If you don't, ask the DBA to give them to you. Then
    1. Login to database_source (It could be either the source or the target. Let's assume it's the source.)
    2. Create a database link to database_target: CREATE DATABASE LINK link_to_database_target CONNECT TO myuserid IDENTIFIED BY mypassword USING 'database_target'; Note the single quotes.
    3. Copy the table data: INSERT INTO targetowner.mytable@link_to_database_target SELECT * FROM sourceowner.mytable; COMMIT;
    Question 2:
    You have two options, but you may not have privileges for both.
    Option 1:
    DELETE FROM tableowner.tablename; COMMIT;
    Advantage: Since this is a DML (Data Manipulation Language) statement, you have to commit the transaction. Also, the data will be gone but the table size is NOT changed, so it's ready for accepting replacement data. DML statements can simply be executed not only from SQL scripts, but from PL/SQL scripts as well.
    Disadvantage: Slow, because all record deletion is logged, so you can recover from it by issuing a ROLLBACK; instead of the COMMIT; above. The table size is NOT changed, so if you are short of disk space or tablespace space, you have not resolved the issue.
    Option 2:
    TRUNCATE TABLE tableowner.tablename;
    Advantage: Since this is a DDL (Data Definition Language) command, you do NOT have to commit the transaction. (DDL commands automatically commit both before and after their execution.) The table size will be changed back to the initial extent size which is the minimum size a table can have and can only be set when the table is created. If it needs to be changed, the table has to be dropped and recreated with a different initial extent size. The statement execution of this command is not logged, therefore it's much faster then the DELETE.
    Disadvantage: No rollback. Being a DDL, this command cannot be executed straight from PL/SQL. If you need to issue this within PL/SQL, you will have to use dynamic SQL.

  • Copying contents of one account to another account

    Following advice about security, I just set up a new account for my family without administrator rights. But now I want to copy into that account all of the files and photos that the family had been using in the administrators account. How do I copy the contents of one account to a new account? I can't figure it out. Can you help?
    Thanks, Jonathan

    Hey, I have exactly the same problem.
    My msn messenger doesnt work completely right in my current using account.
    So I made a new account, and on that one my msn works!
    So I want to start using that account, but all my files and photos and everything are on my 'old' account.
    I did what you said; So I've made my new account admin. and my old account non-admin.
    But it doesnt work, my files aren't in my new account.
    but my parents do also have an account on this computer, also an admin account.
    I hope you understand me, and are able to help me!
    And Im sorry for my english.
    Thanks, Jessie
    Message was edited by: Shakilicious

  • 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

  • How to Copy Contents of  One HD to Another HD?

    I use a G4 QuickSilver 2002; run Mac OS X 10.5.8 Leopard.  I would like to copy the contents of one old hard drive to the main hard drive.  How do I do it?  I tried using Disk Utility, but didn't know what to next once the Disk Utility folder appeared.  Enclosed please find picture of DU.  I'm trying to copy disk named Hard Disk to WD1200 Boot Drive.

    Alll the Disk Utility can do is clone an entire drive. In the process the Destination drive is erased. Is that the result you want? If so do this:
    Clone using Restore Option of Disk Utility
      1. Open Disk Utility in 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. Select the destination volume from the left side list and drag
           it to the Destination entry field.
      5. Select the source volume from the left side list and drag it to
          the Source entry field.
      6. Double-check you got it right, then click on the Restore button.
    Destination means the external backup drive. Source means the internal startup drive.
    If you want to copy files to the Destination without erasing the Destination, then you can do that using Drag and Drop. Select the files you wish to copy and drag them to the Destination drive. Note, that if the Destination is a boot drive, then be sure you only drag your files and data - no system files.

  • Copy records of one table into another using Update statement

    Supposing I have 2 tables test and test1.
    Test has columns col1 and col2. and test1 has only one table col1.
    select * from test returns:
    COL1 COL2
    a
    b
    c
    d
    e
    select * from test1 returns
    COL1
    p
    q
    r
    s
    t
    Suppose i want to copy values of test1.col1 to test.col2 so tht final result of
    select * from test should be
    COL1 COL2
    a p
    b q
    c r
    d s
    e t
    I found a query in the OCP introduction book:
    update test set col2=(select col1 from test11)
    this works fine only when we have a single record in test1 table but fails otherwise.
    how can this be achieved using the update statement ?

    SQL> desc test
    Name Null? Type
    COL1 VARCHAR2(10)
    COL2 VARCHAR2(30)
    SQL> desc test1
    Name Null? Type
    COL1 VARCHAR2(10)
    SQL> insert into test values ('a','');
    1 row created.
    SQL> insert into test values ('b','');
    1 row created.
    SQL> insert into test values ('c','');
    1 row created.
    SQL> insert into test values ('d','');
    1 row created.
    SQL> insert into test1 values ('e');
    1 row created.
    SQL> insert into test1 values ('f');
    1 row created.
    SQL> insert into test1 values ('g');
    1 row created.
    SQL> insert into test1 values ('h');
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> ed
    Wrote file afiedt.buf
    1 select a.col1, b.col1, a.rn from
    2 (select row_number() over (order by col1) rn, col1 from test) a,
    3 (select row_number() over (order by col1) rn, col1 from test1) b
    4* where a.rn = b.rn
    SQL> /
    COL1 COL1 RN
    a e 1
    b f 2
    c g 3
    d h 4
    SQL> ed
    Wrote file afiedt.buf
    1 update test set col1 =
    2 (
    3 select forupd from (
    4 select a.col1, b.col1 test1col, a.col1||' '||b.col1 forupd, a.rn from
    5 (select row_number() over (order by col1) rn, col1 from test) a,
    6 (select row_number() over (order by col1) rn, col1 from test1) b
    7 where a.rn = b.rn
    8* ) z where z.col1 = test.col1)
    SQL> /
    4 rows updated.
    SQL> commit;
    Commit complete.
    SQL> select * from test;
    COL1 COL2
    a e
    b f
    c g
    d h
    SQL>
    This will work only if you have the same number of lines in COL1 in both tables. If you have different number of lines, then you need to code more at join (outer, inner).
    But for complicated cases, please post sample data.
    Michael
    PS: And supossing that the values are distinct in TEST table. Else update will fail, because more rows will be retrived.
    If more values in TEST table in COL1, then you need to assign a row number on TEST also, and in WHERE of query you need to place one more join condition:
    something like:
    8* ) z where z.col1 = test.col1
    and z.rn = test.rn)
    SQL> /
    But as i said, get more specifications.
    Message was edited by:
    kjt
    Added the PS.

  • How to copy file from one table to another table at another database

    I need to transfer my tables from one workspace and schema to another workspace and schema. Basically I need to create again all the tables at this new schema. How could I transfer data from tha table at old schema to the table at new schema when this table has files stored in it? (data type is blob)
    thank you so much,
    Silver

    Hello Silver,
    Depending which database you're using (if it's available) I would recommend to use datapump.
    Datapump allows you to copy an entire schema to another database, it's the "new" export/import you might now.
    Regards,
    Dimitri
    http://dgielis.blogspot.com/
    http://www.apex-evangelists.com/
    http://www.apexblogs.info/
    REWARDS: Please remember to mark helpful or correct posts on the forum

  • Copy data from one table to another

    Hello everyone,
    I have a student table with fields sno, sname. I created another table student1 with same fields sno, sname and with one new field class.
    Now i want to copy data from sno, sname of student table to sno, sname of student1 table when the class field in styudent1 has no data i.e., its null.
    Could any one let me know how to do this?
    Thanks,
    Prathima

    i want to copy data from sno, sname of student table to sno, sname
    of student1 table when the class field in styudent1 has no dataSo what is the join condition? What column in STUDENT1 tells us what row in STUDENT to copy?
    Cheers, APC
    Blog : http://radiofreetooting.blogspot.com/

  • Copying data from one table to another, but not duplicate

    Good afternoon!
    I am new to Oracle SQL, I have a difficulty.
    I have a script that copies or add another table with data from another table.
    If the table already has 01 "Registry 01" when you make a copy of the data in table 02, can not duplicate the "Registry 01" again.
    As the table already exists since the beginning of the year before last and duplicate information, I can not apply the UNIQUE constraint because of the error. I have to make this change from now.
    How to perform this validation so that no duplicate data?
    DECLARE
    w_cont NUMBER;
    CURSOR c_simpro IS
    SELECT sc.cd_simpro,
    sc.ds_produto,
    sp.qt_embalagem,
    MAX(sp.dt_vigencia)
    FROM simpro_cadastro sc,
    simpro_preco sp
    WHERE sc.cd_simpro = sp.cd_simpro
    GROUP BY sc.cd_simpro,
    sc.ds_produto,
    sp.qt_embalagem;
    BEGIN
    FOR r_simpro IN c_simpro LOOP
    w_cont := 0;
    SELECT COUNT(1)
    INTO w_cont
    FROM pls_material pm
    WHERE pm.cd_material_ops = r_simpro.cd_simpro;
    IF w_cont = 0 THEN
    INSERT INTO pls_material(nr_sequencia,
    dt_atualizacao,
    nm_usuario,
    dt_atualizacao_nrec,
    nm_usuario_nrec,
    ie_tipo_despesa,
    cd_estabelecimento,
    nr_seq_estrut_mat,
    cd_simpro,
    ds_material,
    ie_situacao,
    ds_material_sem_acento,
    dt_inclusao,
    cd_material_ops_orig,
    cd_unidade_medida,
    cd_material_ops,
    qt_conversao_simpro)
    VALUES(pls_material_seq.nextval,
    SYSDATE,
    'ES-SIMPRO',
    SYSDATE,
    'ES-SIMPRO',
    3,
    1,
    3,
    r_simpro.cd_simpro,
    r_simpro.ds_PRODUTO,
    'A',
    r_simpro.ds_PRODUTO,
    SYSDATE,
    r_simpro.cd_simpro,
    'un',
    TRIM(to_char(r_simpro.cd_simpro,'0000099999')),
    r_simpro.qt_embalagem);
    COMMIT;
    END IF;
    IF w_cont > 0 THEN
    UPDATE pls_material p
    SET p.qt_conversao_simpro = r_simpro.qt_embalagem,
    p.dt_atualizacao = SYSDATE
    WHERE p.cd_simpro = r_simpro.cd_simpro;
    COMMIT;
    END IF;
    END LOOP;
    END;
    Edited by: 983464 on 22/01/2013 10:30

    Hi,
    in addition to what Marwin has already said, I suggest you to post CREATE TABLE and INSERT statements (as mentioned in the FAQ).
    The error you are getting from MERGE command is because you need a way to uniquely identify within the table. So it's is important to know also if your table has a primary key/unique index so the keys could to be used in the MERGE command.
    Additionally when you put some code or output please enclose it between two lines starting with {noformat}{noformat}
    i.e.:
    {noformat}{noformat}
    SELECT ...
    {noformat}{noformat}
    Regards.
    Al                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Copying data from one table to another

    Hello!
    I have a table (TABLE1) and I want to copy part of TABLE1's data to an another table (TABLE2).This proccess is made by an application in PROC Language with ORACLE 8.1 in UNIX environment.
    1) I've tried to make the copy with a cursor:
    void search() {
    char alias[ALIASTAM];
    struct tpNoticia noticia;
    printf("Introduzca el nombre del autor: ");
    scanf("%s",alias);
    EXEC SQL DECLARE AUX CURSOR FOR
    SELECT idNoticia,titulo,texto,TO_CHAR(publicacion,'HH24:MI:SS DD-MM-YYYY'),
                        URLimagen,numVisitas,sumaVal,totalVal,esBorrador,alias,nombreT
    FROM TABLE1
         WHERE alias=:alias;
    EXEC SQL OPEN AUX;
    EXEC SQL WHENEVER NOT FOUND DO break;
    for (;;) {
    EXEC SQL FETCH AUX INTO :noticia;
    printf("%d %s \n", noticia.idNoticia,noticia.titulo);
    EXEC SQL INSERT INTO TABLE2 (idNoticia,titulo,texto,publicacion,URLimagen,numVisitas,sumaVal,totalVal,esBorrador,alias,nombreT)
    VALUES (:(noticia.idNoticia),:(noticia.titulo),:(noticia.texto), TO_DATE('00:00:00 01-01-1900','HH24:MI:SS DD-MM-YYYY'),:(noticia.URLimagen),:(noticia.numVisitas),
         :(noticia.sumaVal),:(noticia.totalVal),:(noticia.esBorrador),:(noticia.alias),:(noticia.nombreT));
    EXEC SQL CLOSE AUX;     
    IN THIS CURSOR printf SHOWS CORRECTLY THE DATA BUT IT ISN'T INSERTED INTO TABLE 2;
    2) I've tried to define TABLE2 from TABLE1:
    EXEC SQL CREATE TABLE TABLE2 AS
    SELECT * FROM TABLE1 WHERE alias=:alias
    BUT MY COMPILER SAYS: PCC-S-02206, Host variables are not permitted within a DDL statement
    ANY IDEA???
    Thanks

    If you want to create the table dynamically, then you have to use dynamic Sql. Didn't you like my above suggestion ? If you want I can post a small example of a similar stored procedure.
    See also http://www.mcs.csuhayward.edu/support/oracle/doc/8.1.7/appdev.817/a76942/pc_07pls.htm#2778

  • Error when copying items from one table to another

    I am trying to copy data from 2 archive tables within an
    Access database to their twin production tables. The first table
    copies perfectly with the code:
    <CFQUERY NAME="moveArchAttach" datasource="faaco2">
    INSERT INTO tbl_Attachment ( PostID, Attachment, AttachNote,
    AttachName )
    SELECT tbl_Attachment_Archived.PostID,
    tbl_Attachment_Archived.Attachment,
    tbl_Attachment_Archived.AttachNote,
    tbl_Attachment_Archived.AttachName
    FROM tbl_Attachment_Archived
    </CFQUERY>
    However, when trying to use similar code on the other table:
    <CFQUERY NAME="moveArchPost" datasource="faaco2">
    INSERT INTO tbl_Posting ( Title, FirstName, LastName,
    PhoneNumber, RoutingSymbol, Email, IniDate, ComDate, SOLNBR,
    PhaseCode, ProcCode, Posting, Password, RegionCode )
    SELECT tbl_Posting_Archived.Title,
    tbl_Posting_Archived.FirstName, tbl_Posting_Archived.LastName,
    tbl_Posting_Archived.PhoneNumber,
    tbl_Posting_Archived.RoutingSymbol, tbl_Posting.Email,
    tbl_Posting.IniDate, tbl_Posting.ComDate, tbl_Posting.SOLNBR,
    tbl_Posting.PhaseCode, tbl_Posting.ProcCode, tbl_Posting.Posting,
    tbl_Posting.Password, tbl_Posting.RegionCode
    FROM tbl_Posting_Archived
    </CFQUERY>
    I receive the error:
    [Microsoft][ODBC Microsoft Access Driver] Too few parameters.
    Expected 9.
    Any help would be greatly appreciated, I am at a loss and
    I've tried everything. Thank you.

    I realized my error immediately after posting this topic and
    subsequently have resolved this error. On 9 of the values, I have
    listed the wrong table in the SELECT statement. This is why one
    needs to take breaks instead of staring at a screen forever :).
    Thank you anyway!

  • Automatic copying row from one table into another one

    Hi,
    I am looking for some help on how to do the following:
    I use Number to track my finances. I have two tables - one for my checking account and the other one for my cash account. When I withdraw cash from my checking account I record a transfer or debit transaction in my checking account table (in the type column of this table I enter "transfer" and in the category column of this table I enter "cash account"); Obviously I have to record a matching transaction in my cash account where the category column shall read "checking account". Both records represent one and the same transaction. In order not to enter this transaction twice I would like to "automate" this process so that once I enter the transaction in either of the two table (checking or cash) the matching entry automatically appears in the other table. Is there any way to do this.
    Thank you,
    Evgeny

    You can use Connection#getMetaData() to retrieve information about the tables and the columns of the table.
    After all, it is better to gain information about the table first and then issue a query in the form of "INSERT INTO table1 SELECT * FROM table2", including the eventual column selections and/or data conversions at SQL level.

Maybe you are looking for