to add records to one table from another

Hello gurus

I have a table in which I have a few files... now, I want to add in the documents of table A of another table B has the same structure and columns.

Y at - it a command for it
insert into A
select * from B;

Tags: Database

Similar Questions

  • Populating one table from another table

    Hi Forum...

    I'm trying to populate a table from another table using CFQUERY... I have no problem with the selection of data from the original table, but need help to get the data into the new table. I use MX 6.1 and access as the database server.
    The two arrays have domain names identical to the same place, and I don't want to have to code all the column names in the selection and insert command. for example

    < cfquery name = "GetData" datasource = 'somename' >
    SELECT * FROM AssetTable1 WHERE BarCode = "123456".
    < / cfquery >

    < cfloop query = "GetData" >
    < cfquery name = "InsData" datasource = 'somename' >
    INSERT INTO AssetTable2 (xxxx...)
    VALUES ("#xxxx... #'")
    < / cfquery >
    < / cfloop >

    I hope this makes sense

    Thanks in advance

    Dave

    If your tables are identical structures and their columns are of the same type and position, and both tables are in the same database, then put everything in a single query.


    INSERT INTO AssetTable2
    SELECT *.
    OF AssetTable1
    WHERE bar code = "123456".

    If the columns were in different positions, then you should be listed explicitly in the INSERT and SELECT the parts, but you get the idea.

    INSERT INTO table1 (col1, col2)
    SELECT col1, col2
    FROM table2
    WHERE all that...

    Phil

  • Insert the record of one table to another with the help of the cursor

    Help, please!

    the tables are - 1. countries (country_id pk, country_name, region_id)
    2A (country_id, country_name, region_id)
    table data are
    1 to 1
    2 b 2
    3 C 3
    NULL d 4
    5 e 5
    6 f 6
    7 g 7
    -----------------------
    Insert the record in the table a country table with the help of the cursor, insert all the non-null records.
    This procedure does not correct result
    -----------------------

    create or replace
    Amit procedure as
    cursor c1 is select * from a;
    RW a % rowtype;
    Start
    Open c1;
    Fetch c1 into rw.
    While (C1% found)
    loop
    insert into countries values (rw.country_id, rw.country_name, rw.region_id);
    commit;
    Fetch c1 into rw.
    If rw.country_id is null then
    Fetch c1 into rw.
    end if;
    end loop;
    Close c1;
    exception
    while others then
    dbms_output.put_line ('exception = name ' |) RW.country_name);
    end;

    You don't need cursor at all;

    create or replace procedure amit as
    
    begin
      insert into countries (Country_ID, Country_Name, Region_ID)
      (select a.Country_ID
             ,a.Country_Name
             ,a.Region_ID
       from a
      );
    
      dbms_output.put_line('Rows inserted : ' || sql%rowcount);
    
      commit;
    
    end;
    /
    
  • How to update one table from another table

    Hello

    I have two tables, t1 or t2, I wrote the below query, but got an error as ORA-00904 ' identifier Inavlid b.purchase_capturedate. The query is:

    Update t1 a
    Set a.docdate = b.purchase_capturedate
    where (a.docid))
    Select docid_request from t2 b where a.docid = b.docid_request and b.itemcategoryid = 6)



    Help, please.


    Kind regards

    Hello

    describe your tables t1 and t2

    Concerning
    Sankar MN

  • How to replace one table with another?

    I need to replace one table with another. Both tables have the same structure, primary keys, indexes, constraints, but different data (about 50 million records).
    I would like to make this replacement in line, with no passage of database in offline mode.
    There is no clause CREATE or REPLACE TABLE in Oracle unfortunely.
    I could use just DROP and ALTER TABLE RENAME instructions, but it is necessary that a user receive message error "table or view does not exist. It may be possible to block incoming requests at the moment, while old and new droppping table rename are performed?

    Thanks in advance.

    Hi again!

    You can detect normal users with session sessions $ v. A session of a normal user has a username (username of the column). Systemsessions PMON and SMON have no user name. So, you can use the following query to detect sessions, you need to kill:

    SELECT sid, serial#, username
    FROM   v$session
    WHERE type NOT LIKE 'BACKGROUND';
    

    concerning

  • FRM-92101 happens when I open one form from another and then close it.

    FRM-92101 happens when I open one form from another, check something, display a message to the user and exit the screen to the previous shape.

    Version of forms: 10.1.2.0.2. Java: 1.6.0_23. Browser: IE6

    When I put forward two messages of 'EXIT_FORM', all right and the second form is closed again to the first shape just like I wanted.
    In 9.0 forms, it did not.

    It has to do with the fact that I use JRE instead of JInitiator?
    Thank you.

    Take a look by using the built-in NAME_IN forms. You will find the NAME_IN function takes a STRING as parameter. Change your code to:

    IF NAME_IN('SYSTEM.CURSOR_ITEM') IS NOT NULL THEN
       SYNCHRONIZE;
    END IF;
    

    Hope this helps,
    Craig B-)

    If someone useful or appropriate, please mark accordingly.

  • Create a new table from another table which are ussing a stored procedure

    Hello

    I want to know if it is posibble to create a new table from another table which are ussing a stored procedure. This new table is created from another table that exists in the DB.
    (in the following code the table tbl1 exist in the schema of the DB, but temp_tbl1 does not exist, it must be created by the procedure)

    create or replace procedute temp is
    temp_tbl1 tbl1% TYPE; the temp_tbl1 will have the same type of tbl1
    Start
    create the table temp_tbl1 as (select * from tbl1);
    time of the end;
    \


    Thank you very much

    Yes, it is possible to create a table using a procedure.
    Do everything that use dynamic SQL is

    Try this:

    ==================================================
    create or replace PROCEDURE Create Table as
    BEGIN
    EXECUTE IMMEDIATE ' CREATE TABLE testtable in select * from testingtable';
    END createtable;
    ==================================================

    Kind regards
    Ankur

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

    Hello

    I am trying to create a trigger that will move data from one table to the other.

    I have two tables (Trial1, Trial2) two of them contains the same attributes (code, c_index)

    I want to spend each new record inserted in (code Trial1) (code in Trial2)

    It's my trigger:
    Create or replace trigger trg_move_to_trial2
    After Insert on Trial1
    for each row
    Start
    insert into Trial2 (code)
    Select: new.code of Trial1;
    end;
    He compiled, but when I insert a new record (the code) in (Trial1), it shows this error:
    Error report:
    SQL error: ORA-04091: table STU101. TRIAL1 is changing, function of triggering/can not see
    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 changing, function of triggering/can not see.
    * Cause: A trigger (or plsql user-defined function that is referenced in)
    This statement) attempted to watch (or modify) a table that has been
    in the Middle being modified by the statement that shot.
    * Action: Rewrite the trigger (or function) so it does not read this table.
    I know matter what it means error, but I did not how to fix the error.

    ..................................................................................................

    I tried to change the (insert after on Trial1) before (insert on Trial1); It worked, but not in a good way. When I insert value in (code Trial1) new and refreshed Trial2 table, just as much as the records I have 2 test they will be duplicated. For example
    Trial2
    code
    111
    222
    333
    when I insert in Trial1
    Trial1
    code
    444
    Trial2 will be:
    code
    111
    222
    333
    444
    444
    444
    can you please tell me how to fix this?

    Kind regards

    Published by: 1002059 on April 23, 2013 17:36

    You should not select Trial1 - you already have data. Simply insert this 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; 
    

    Kind regards
    David

  • Copy from one table to another

    Is there a simple way to copy/add all the records from one table to a master table?

    INSERT INTO master_table (Field1, Field2, field3)
    SELECT field1, Field2, field3
    From other_table
    WHERE everything what

    If the data types, order and the column names are the same for both tables, then it would also work to copy all other_table lines in master_table:

    INSERT INTO master_table
    SELECT *.
    From other_table

    Phil

  • Inserting data from one table to another table

    Hello

    I have the following SQL where I am updating a table by adding new data from another table, but without success.

    INSERT INTO
    () TOP_PROSPECTS
    COMMON_ID
    DATE_ADDED
    REVIEW_RANK
    EVAL_DATE
    PM_ASSIGN
    WHY_NOTES)
    SELECT
    t.COMMON_ID
    t.DATE_ADDED
    t.REVIEW_RANK
    t.EVAL_DATE
    t.PM_ASSIGN
    t.WHY_NOTES
    Of
    TEMP_IVAN_MARY t
    WHERE
    COMMON_ID <>t.COMMON_ID

    Any suggestions?

    Thank you.

    Published by: user13822709 on August 14, 2012 09:14

    Published by: user13822709 on August 14, 2012 09:15

    Is that what you're trying to do with the insert. I think there may be a sign {noformat}<{noformat}{noformat}>{noformat} missing in the where clause. This site eat those, so you need to use the equivalent! = post here.

    If I'm wrong about the missing trader, then it looks like you want to insert rows in temp_ivan_mary that are not already in top_prospects. If Yes, then you need something like:

    insert into top_prospects
       (common_id, date_added, review_rank, eval_date, pm_assign,
        why_notes)
    select t.common_id, t.date_added, t.review_rank, t.eval_date,
           t.pm_assign, t.why_notes
    from temp_ivan_mary t
    where t.common_id not in (select common_id from top_prospects
                              where common_id is not null)
    

    Function index and data available volumnes etc. then a mergr can be more effective. Something like:

    merge into top_prospects p
       using (select common_id, date_added, review_rank, eval_date,
                     pm_assign, why_notes
              from temp_ivan_mary) t
       on (p.common_id = t.common_id)
       when not matched then
          insert (common_id, date_added, review_rank, eval_date, pm_assign,
                  why_notes)
          values (t.common_id, t.date_added, t.review_rank, t.eval_date,
                  t.pm_assign, t.why_notes)
    from temp_ivan_mary t
    

    John

  • Copy all the BLOBs from one table to another

    Hi all

    I hope that I put in the right place. I am trying to copy from one table to the other BLOBs, but were usuccessful. Here is the script that I wrote to do, but it just loaded a field saying not supported. Is there something I'm missing, I'm using the APEX 3.1.2.

    Thanks for your help.

    DECLARE
    number of v_id;
    v_document blob.
    v_filename varchar2 (200);
    v_mimetype varchar2 (200);



    CURSOR c_Document IS
    SELECT id, name of the document file, mimetype
    IN v_id, v_document, v_filename, v_mimetype

    OF CAB_APPEAL_ACTIONS
    WHEN THE DOCUMENT IS NOT NULL;

    BEGIN

    FOR r_Document in c_Document
    LOOP
    INSERT INTO CAB_APPEAL_DOCUMENTS
    (APPEAL_ACTION_ID,
    DOCUMENT,
    FILE NAME,
    MIMETYPE
    )
    VALUES
    (v_id,
    v_document,
    v_filename,
    v_mimetype
    );

    END LOOP;

    END;

    In addition, what is wrong with just...

    INSERT INTO CAB_APPEAL_DOCUMENTS (APPEAL_ACTION_ID,
                                      DOCUMENT,
                                      FILENAME,
                                      MIMETYPE)
       SELECT   id,
                document,
                filename,
                mimetype
         FROM   CAB_APPEAL_ACTIONS
        WHERE   DOCUMENT IS NOT NULL;
    

    APEX will end process page in a BEGIN block... END; block anyway.

    See you soon

    Ben

  • Passing a value from one table to another

    Access database:
    I have 2 tables, table 1 has a field that is a primary key (not indexed, no dups), table 2 has a field that should receive the same number as the table represented in 1.
    The problem is that when the query runs, it gets the MAX (number), but when it is inserted in table 2, all records in table 2 are updated with this number.
    Is there a way to prevent all the records in a table 2 updated and only the most recent file receiving the number in table 1?
    Any ideas?

    This is my query:

    < cftransaction >

    < cfif len (trim (form. GT Time_Spent)) 0 >
    < cfquery "InsertRecord' datasource = name ="NBProdReports">
    Insert Into TblMasterTrans (Time_Spent) Values ('#form.) Time_Spent #')
    < / cfquery >
    < / cfif >

    < cfif len (trim (form. WG Notes)) 0 >
    < cfquery "InsertRecord' datasource = name ="NBProdReports">
    Insert into TblContractInfo_SubMenuTable (Contract_Number, Transaction_Type, Num_Checks_Trans, Notes)
    Values ('#form.) Contract_Number # ',' #form. Trans_Type # ',' #form. Num_Checks_Trans # ',' #form. Notes #')
    < / cfquery >
    < / cfif >

    < name cfquery = "getTask_Number" datasource = "NBProdReports" >
    SELECT MAX (Task_Number) AS theTask_Number
    Of TblMasterTrans
    < / cfquery >

    < name cfquery = "SetTaskNumber" datasource = "NBProdReports" >
    Update TblContractInfo_SubMenuTable
    Set
    Task_Number = #getTask_Number.theTask_Number #.
    Where Task_Number = Null
    < / cfquery >

    < / cftransaction >

    In fact, you could even with impunity with a single query by selecting the Task_Number MAX in the second insert statement.



    Insert Into TblMasterTrans (Time_Spent) Values ('#form.) Time_Spent #')



    Insert into TblContractInfo_SubMenuTable (Task_Number, Contract_Number,
    Transaction_Type, Num_Checks_Trans, Notes)
    SELECT MAX (Task_Number), ' #form. Contract_Number #'.
    ' #form. Trans_Type # ',' #form. Num_Checks_Trans # ',' #form. Note #'
    Of TblMasterTrans

    Phil

  • How to select a record in one table to manipulate data in a database?

    Hello community,

    Using 32-bit Labview 2015.

    I created a user interface that runs a query and retrieves my table from a sql database.

    I want to be able to manage only one record at a time by selecting the record in my table and then manipulate the data according to the needs.

    Whenever the user runs a query, I want as the first record in the table to be selected / highlighted.

    I want an indicator that is currently active.

    Then a click of a button, to be able to scroll the actively selected record.

    Once I have the selected record, I want a way to write a query to edit or delete the record.

    Is attached a photo of my query to select all of my table and connect data in my table (results).

    Attached a photo of my painting showing the timeline of my sql database.

    What is the best way to go on a record selection in a table and the modification of data with a query?

    Any help would be greatly appreciated.

    Thank you

    I guess that's not a table, but multi-column listbox.

    Right click, select--> highlight whole line selection Mode

    The value of the multicolumn listbox is the row index - you can write a local variable to highlight the line, the event structure to handle the user clicking on, etc.

    If you enable the property editable ListBox cells, you can allow users to edit the items of the listbox.

    If you want to get the data in row, you hint REF table and work with the array of strings in row - convert it to cluster, etc..

    I don't know, what type of data, it is, how you structure the database looks like, I don't even know if you use the wrapper to work with the database, I can't write queries for you.

    Something like Update Tablica Set Serial = '5' where ID = '22';

  • Insertion of one table to another is too slow

    I have 129975 records in a table. I'm trying to transfer to another table. It was 50 minutes, and the process is still ongoing. What could be the problem? Index can solve this problem? Please give me the code.
    Thank you

    What awaits the session? Don't know how to check it

    Your DBA knows how to check: a TRACE/TKPROF with wait events (10046 level)

    SQL and PL/SQL FAQ
    Read the explanations of these links:
    -When your query takes too long...
    -How to send a SQL tuning request

  • Inserting data into one table to another table.

    Hi all

    I'm having a few problems when copying data from the 1 table to another table. I have a data 1 date in a table, and I want to insert data in a partition of the main table. As it is the dev database space by getting a problem. I don't have enough space that I can maintain the data for the same date in 2 places.

    Here every way possible in oracle this 1 table may be made partition in the other table. (Just a question).

    Please suggest me a way out and if possible should be fast that data are more than 50 million lines and size along 10 GB.

    Thank you

    Are the columns of your source table identical to that of the destination partitioned table?

    If so, you can create an empty partition in the partitioned table and then create a swap partition to swap the source with the new empty partition table.

Maybe you are looking for