I need to copy data from a table in one database (db1) to another table in

Hi
I need to copy data from a table in one database (db1) to another table in another database (db2).
I am not sure if the table exists in db2,,,if it doesnot it needs to be created as well data also needs to be inserted...
How am I supposed to this using sql statements..?
I shall be happy if it is explained SQL also...
Thanking in advance

How many rows does the table contains? There are manyway you can achieve this.
1. export and import.
2. create a dblink between two databases and use create table as select, if structure doesnot exists in other database, if structure exists, use, insert into table select command.
example:
create a dblink in db2 database for db1 database.
create table table1 as select * from table1@db1 -- when there is no structure present
-- you need to add constraints manually, if any exists.
insert into table1 select * from table1@db1 -- when there is structure present.
If the table contains large volume of data, I would suggest you to use export and import.
Jaffar

Similar Messages

  • Copying data from excel(more than one row) and pasting into table control

    I have a requirement to copy data from excel and have it pasted it into the corresponding fields table control when the user clicks on an icon.For the first part I used a class to copy it from the clip board.By the previous process,I get the data inside an internal table, but even after  trying to split the data using 'split at cl_abap_char_utilities=>horizontal_tab into table itab.' it's not working.The table and the excel file are of the same structure.
    Does anyone know any cause as to why it might not work?Is there any other way to achieve my objective?
    Bon

    Hi,
    try to get data into internal table as below
    TYPES :     BEGIN     OF             ty_data          ,
                zbukr     TYPE           payr-zbukr       ,
                hbkid     TYPE           payr-hbkid       ,
                hktid     TYPE           payr-hktid       ,
                rzawe     TYPE           payr-rzawe       ,
                chect     TYPE           payr-chect       ,
                laufd     TYPE           reguh-laufd      ,
                laufi     TYPE           reguh-laufi      ,
                lifnr     TYPE           reguh-lifnr      ,
                vblnr     TYPE           reguh-vblnr      ,
                rwbtr     TYPE           reguh-rwbtr      ,    "uncommented
                unique_no TYPE           char13           ,   " Added SAP Doc. No. and current year concate in NEFT,RTGS and Fund Transfer cases
                END       OF             ty_data          .
    DATA :      wa_file   LIKE LINE OF   it_file          ,
                wa_data   TYPE           ty_data          .
    DATA:      it_data1 TYPE              kcde_intern WITH HEADER LINE,
               wa_data1 LIKE LINE OF      it_data1.
    start-of-selection.
    CALL FUNCTION 'KCD_EXCEL_OLE_TO_INT_CONVERT'
          EXPORTING
            filename                = lv_file1
            i_begin_col             = '1'
            i_begin_row             = '4'
            i_end_col               = '11'
            i_end_row               = '60000'
          TABLES
            intern                  = it_data1
          EXCEPTIONS
            inconsistent_parameters = 1
            upload_ole              = 2
            OTHERS                  = 3.
        IF sy-subrc = 0.
          PERFORM format_data.
        ENDIF.
    FORM format_data.
      DATA : ld_index TYPE i.
      FIELD-SYMBOLS : <fs>.
      DATA it_tab LIKE wa_data OCCURS 0 WITH HEADER LINE.
          LOOP AT it_data1.
            MOVE it_data1-col TO ld_index.
            ASSIGN COMPONENT ld_index OF STRUCTURE
            it_tab TO <fs>.
            MOVE : it_data1-value TO <fs>.
        MOVE it_data1-value TO p_table.
            AT END OF row.
              APPEND it_tab.
              CLEAR it_tab.
            ENDAT.
          ENDLOOP.
           it_data[] = it_tab[] .
        ENDIF.
    endform.                    "format_data

  • I need to copy data from sysbase database to oracle database

    I have to database one on sybase and the other on oracle ,them have the same tables i need to copy the data in the table of sybase to the tables in oracle

    I setup the getway already but after this the oracle client didnt connect to any thing even the oracle server which was conneted succesfully before setup the getway
    I sorry for long and thanks for your advice

  • Need to copy Data from a specific Html Tag

    Hello,
    I am trying to use CF to access website and capture data from a specific tag to the end of that tag and store same in a csv file or database.
    The tag based search of an open file is where I am not able to get any head way. Any one has done this?

    You'll need to use a regular expression for that. CF supports regular expressions with the REFind, REFindNoCase and REReplace functions. Here's an example of using regular expressions to capture the value within an HTML tag:
    http://www.javamex.com/tutorials/regular_expressions/example_scraping_html.shtml
    It's in Java, but the syntax for regular expressions is the same in CF.
    Dave Watts, CTO, Fig Leaf Software
    http://www.figleaf.com/
    http://training.figleaf.com/
    Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on
    GSA Schedule, and provides the highest caliber vendor-authorized
    instruction at our training centers, online, or onsite.
    Read this before you post:
    http://forums.adobe.com/thread/607238

  • Need to read data from a text file

    I need to read data from a text file and create my own hash table out of it. I'm not allowed to use the built in Java class, so how would I go implementing my own reading method and hash table class?

    It's not possible to read from a file without using classes from the core API*. You'll have to get clarification from your instructor as to which classes are and are not allowed.
    [http://java.sun.com/docs/books/tutorial/essential/io/]
    *Unless you write a bunch of JNI code to replicate what the java.io classes are doing.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How to copy data from one planning area to other planning area

    Hi ,
    I need to copy data from one planning area to other planning area, the MPOS for two planning areas are differant and  here my scenario is one planning area having extra key figures.
    First i need to release forecast data to CIP planning area and then,  i load the data from infocube  to MPS planning area and copy the data from CIP planning area. here both MPS and CIP planning areas having different MPOS .
    Please help me in this. Please give me the stepls i need to follow.
    Thanks in advance.
    Regards,
    Chandu

    Hi,
    You can use the transaction /sapapo/tscopy.
    In this you can configure your source plng area and destination plng area. You also have an option to map your KF. There is no problem if the MPOS are different as long as you are able to map the characteristics between the 2 MPOS.
    Alternatively, you can create an Infocube which shares common ground between the 2 planning areas and extract data from CIP plng area into the infocube and then copy teh data from infocube to MPS plng area using the the transaction /sapapo/tscube.
    Hope this helps.
    Thanks
    Mani Suresh

  • 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 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

  • Copy data from Berkeley DB to Oracle tables

    Hello
    I need to get data from Berkeley DB to Oracle tables.
    Any help/tools to this?
    Thanks for your help in advance.
    So far
    1. I asked developers to dump BDB in flat file.
    2. Created external tables & loaded into permanent table using CTAS.
    Cheers

    Hi Shekhar,
    External tables managed by the Oracle DB Server are a way to go.
    However, I would suggest using any of the Berkeley DB Core APIs (C, C++, Java) along with its appropriate correspondent on the Oracle DB side, that is, OCI (Oracle Call Interface, C API), OCCI (Oracle C++ Call Interface) and, respectively, JDBC or SQLJ. You may also use the Oracle DB Precompilers, Pro*C/C++ along with the correspondent Berkeley DB API, C/C++.
    If you have Metalink access, you may consult the KM Note 756126.1, where I've discussed how to import Oracle DB data into Berkeley DB databases (the opposite of what you're trying to do), using OCI on the Oracle DB side and the C API on the Berkeley DB side; there is a code example in the note to explain how to perform this task.
    Doing the data copying the other way around is not difficult; you'll need to iterate through the Berkeley DB database with a cursor and use appropriate OCI DML statements (INSERT INTO) to write the data to the Oracle DB table. Note that you may also use OCI to execute the DDL statements (CREATE TABLE) to create the Oracle DB table into which data will be copied, or do that separately using SQL*Plus, PL/SQL dynamic native SQL etc before copying the data.
    Bellow are the links for the Berkeley DB documentation page where you'll find each of the BDB APIs and the Oracle DB Application Development documentation section where you'll find the development guides for Oracle Call Interface, JDBC and SQLJ:
    [Oracle Berkeley DB|http://www.oracle.com/technology/documentation/berkeley-db/db/index.html]
    [Oracle DB Application Development|http://www.oracle.com/pls/db102/portal.portal_db?selected=5]
    Best regards,
    Andrei

  • How to Copy data from field symbol to Dynamic Internal Table

    Hi,
    I want to copy the data between two dynamic Internal tables . Following is the code were I have data in the field symbol wanted to transfer it to the other Internal table :
    REPORT  ztest.
    DATA:
           gd_dref          TYPE REF TO data,
           gd_dref1          TYPE REF TO data.
    FIELD-SYMBOLS:  <fs1>   TYPE any,
                               <fs_wa> TYPE any,
                                <field>    TYPE any,                  
                                <fs_wa1> TYPE ANY TABLE.  * Contains data from p_src
    *Copy data from p_src to p_dest*
    PARAMETERS: p_src LIKE dd02l-tabname .    * Name of Dynamic Internal table *
                             p_dest LIKE dd02l-tabname .  * Name of Dynamic Internal table*
    *DATA : lt_csks LIKE p_dest WITH HEADER LINE.
    START-OF-SELECTION.
      CREATE DATA gd_dref TYPE (p_src).
      CREATE DATA gd_dref1 TYPE TABLE OF (p_src).
       ASSIGN gd_dref->* TO <fs_wa>.
       ASSIGN gd_dref1->* TO <fs_wa1>.
       SELECT * FROM (p_src) INTO TABLE <fs_wa1>.
    *Write out data from FIELD SYMBOLS TO Table.
       loop at <fs_wa1> into <fs_wa>.
         do.
           assign component  sy-index
              of structure <fs_wa> to <field>.
           if sy-subrc <> 0.
           exit.
           endif.
           if sy-index = 1.
             write:/ <field>.
           else.
           write: / <field>.
           endif.
         enddo.
       endloop.
    *Need Logic To Copy the Data to p_dest table from <fs_wa1>.
    *p_dest is a table having a similar structure to table p_src .
    *Need Logic To Copy the Data to p_dest table from <fs_wa1>.
    EXIT.
    Thanks in Advance.

    try this...
    I have extended your source code and just used vbak/vbap as an example as they have some common fields like vbeln/erdat etc which corresponds with your requirement of 'similar structure' i.e. shared/common fields in both.
    Cheers...
    report  ztest.
    data:
      gd_dref type ref to data,
      gd_dref1 type ref to data,
      gd_dref_str type ref to data,
      gd_dref_tab type ref to data.
    field-symbols:
      <fs1> type any,
      <fs_wa> type any,
      <fs1_dest_str> type any,
      <fs_dest_tab> type any table,
      <field> type any,
      <fs_wa1> type any table.
    * contains data from p_src
    *Copy data from p_src to p_dest*
    parameters: p_src like dd02l-tabname default 'vbak',
    * name of dynamic internal table *
                p_dest like dd02l-tabname default 'vbap'.
    * name of dynamic internal table*
    *data : lt_csks like p_dest with header line.
    start-of-selection.
      create data gd_dref type (p_src).
      create data gd_dref1 type table of (p_src).
      assign gd_dref->* to <fs_wa>.
      assign gd_dref1->* to <fs_wa1>.
      select * from (p_src) into corresponding fields of table <fs_wa1>
      up to 3 rows
      where vbeln ne space.
      create data gd_dref_str type (p_dest).
      create data gd_dref_tab type standard table of (p_dest).
      assign gd_dref_str->* to <fs1_dest_str>.
      assign gd_dref_tab->* to <fs_dest_tab>.
    *write out data from field symbols to table.
      loop at <fs_wa1> into <fs_wa>.
        " break-point here - can see vbeln/waers/create date/ etc move over to new structure
        " the 'common' fields of your structures - the same will happen. if they not the same name you will have to do an
        " explicit move i.e. if fieldname = xyz ....move fieldxyz to new field123....after the move-corre
        break-point.
        move-corresponding <fs_wa> to <fs1_dest_str>.
        insert <fs1_dest_str> into table <fs_dest_tab>.
    **    do.
    **      assign component  sy-index
    **         of structure <fs_wa> to <field>.
    **      if sy-subrc <> 0.
    **        exit.
    **      endif.
    **      if sy-index = 1.
    **        write:/ <field>.
    **      else.
    **        write: / <field>.
    **      endif.
    **    enddo.
      endloop.
      " write out some dest data from the dest table build from previous loop
      loop at <fs_dest_tab> assigning <fs1_dest_str>.
        do.
          assign component sy-index of structure <fs_wa> to <field>.
          if sy-subrc <> 0.
            exit.
          endif.
          if sy-index = 1.
            write:/ <field>.
          else.
            write: / <field>.
          endif.
        enddo.
      endloop.

  • ADF 11g can not select and copy data from cell of readonly table in IE

    hi,
    In ADF 11g, when render view object as readonly table with Single RowsSelection, using IE browser can not select and copy data from the cell, but it work in firefox.
    is it a bug?
    Edited by: kent2066 on 2009-5-18 上午8:46

    Hi Timo,
    Sorry forgot to mention versions.
    We are using 11.1.1.7 and IE 9.
    I tried in Google but could not get the solution.
    Kindly let me know solution for this.
    PavanKumar

  • 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/

  • I need to import data from a CSV file to an Oracle table

    I need to import data from a CSV file to an Oracle table. I'd prefer to use either SQL Developer or SQL Plus code.
    As an example, my target database is HH910TS2, server is ADDb0001, my dB login is em/em, the Oracle table is AE1 and the CSV file is AECSV.
    Any ideas / help ?

    And just for clarity, it's good to get your head around some basic concepts...
    user635625 wrote:
    I need to import data from a CSV file to an Oracle table. I'd prefer to use either SQL Developer or SQL Plus code.SQL Developer is a GUI front end that submits code to the database and displays the results. It does not have any code of it's own (although it may have some "commands" that are SQL Developer specific)
    SQL*Plus is another front end (character based rather than GUI) that submits code to the database and displays the results. It also does not have code of it's own although there are SQL*Plus commands for use only in the SQL*Plus environment.
    The "code" that you are referring to is either SQL or PL/SQL, so you shouldn't limit yourself to thinking it has to be for SQL Developer or SQL*Plus. There are many front end tools that can all deal with the same SQL and/or PL/SQL code. Focus on the SQL and/or PL/SQL side of your coding and don't concern yourself with limitations of what tool you are using. We often see people on here who don't recognise these differences and then ask why their code isn't working when they've put SQL*Plus commands inside their PL/SQL code. ;)

  • 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 transparent table to our own ceated z table?

    How to copy data from transparent table to our own ceated z table?
    Plz tell me different methods and which one is best?
    Is get data from sflight into table z* is correct?

    Hi Ajay,
    let us consider you have to copy EKKO table to ZEKKO table
    1. In ABAP program define internal table based on EKKO
    <b>     eg: i_ekko</b>
    2. Select the data from EKKO to i_ekko
    <b>     eg: select * from ekko into table i_ekko.</b>
    3. insert into Z-TABLE from the internal table
    <b>     eg: INSERT EKKO FROM TABLE I_EKKO.
               COMMIT WORK.</b>
    <u>To insert in internal table you can use the following:</u>
    1. INSERT [wa INTO|INITIAL LINE INTO] itab [INDEX idx].
    2. INSERT [wa INTO|INITIAL LINE INTO] TABLE itab.
    3. INSERT LINES OF itab1 [FROM idx1] [TO idx2] INTO itab2 [INDEX idx3].
    4. INSERT LINES OF itab1 [FROM idx1] [TO idx2] INTO TABLE itab2.
    <u>To inert in database table, use the following:</u>
    1. INSERT INTO <dbtabname> [CLIENT SPECIFIED] VALUES wa.
    2. INSERT <dbtabname> [CLIENT SPECIFIED] FROM TABLE itab.
    3. INSERT <dbtab> [CLIENT SPECIFIED]. oder
    4. INSERT <dbtabname> [CLIENT SPECIFIED] ... .
    <b>Reward points.. if helpful.
    Cheers !
    Moqeeth.</b>

Maybe you are looking for

  • Upgraded to Skype 7 But crashes after login

    Hi, I updated my skype the other night and it crashes every time it logs me in. I'm using my hotmail/msn login. on windows 7 home premium. Had no problem until I upgraded. I tried uninstalling skype, then clearing anythig in %appdata% roaming and loc

  • Problem in creating Depot Invoice

    When I am trying to create a depot excise invoice using j1ij, System is throwing the following message at the time of saving : Error in allocating Depot Invoice number Interval not found Number object J_1IDEPINV. I have maintained the number range in

  • Can I install Adobe acrobat professional on vista?

    Hello Everyone, I have a old system with adobe acrobat professional, and I need to buy a new computer which has windows vista on it, will adobe acrobat professional work on it? Its very important, because that program, I need to do my job at this com

  • RealmAdapterAuthenticator in WLS 9.2

    Hello, I'm trying to add a RealmAdapterAuthenticator to an existing security realm. It appears that the Realm implementation is specifically filtering out weblogic.security.providers.realmadapter provider types. The console does not list RealmAdapter

  • Authorization check For T code

    Hi everyone, Can anybody guide to set a  authorization check  for a particular Tcode. I have ztable where users are assigned particular numbers. I want the users who are assigned some numbers should be able to use this particular t code Thanks in adv