Insert data from one table to another

I have two tables SALES_MASTER and SALESMAN_MASTER which is described below.

SQL > desc SALES_MASTER;
Name Null? Type
----------------------------------------- -------- ----------------------------
NO VARCHAR2 (6)
NAME VARCHAR2 (20)
PIN NUMBER (8)
CITY VARCHAR2 (20)
VARCHAR2 (20) STATE



SQL > desc SALESMAN_MASTER;
Name Null? Type
----------------------------------------- -------- -----------------------
SALESMANNO VARCHAR2 (6)
SALESMANNAME VARCHAR2 (20)
ADDRESS1 VARCHAR2 (30)
ADDRESS2 VARCHAR2 (30)
CITY VARCHAR2 (20)
PIN NUMBER (8)
VARCHAR2 (20) STATE
SALAMT NUMBER (8.2)
TGTTOGET NUMBER (6.2)
YTDSALES NUMBER (6.2)
REMARKS VARCHAR2 (60)

I want to insert data from SALESMAN_MASTER (2nnd table) to SALES_MASTER(first table). I want to insert only two columns NO, NAME and PIN code. All of these columns are compatible. I tried this command. But it's not working. Help me.

SQL > insert into SALES_MASTER
2 (NO., NAME, PIN CODE)
3 values
4. Select SALESMANNO, SALESMANNAME, PIN code
5 SALESMAN_MASTER;
Select SALESMANNO, SALESMANNAME, PIN code
*
ERROR on line 4:
ORA-00936: lack of expression
INSERT INTO SALES_MASTER
   ( NO
   , Name
   , PINCODE )
   SELECT SALESMANNO
        , SALESMANNAME
        , PINCODE
     FROM SALESMAN_MASTER;

Kind regards
Christian Balz

Tags: Database

Similar Questions

  • 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

  • Load data from one table into another table of 2 different schemes

    Hello

    We have a requirement to insert data into a table in a schema of a table that is in other schemas in ODI.

    We are able to do so by creating interfaces and mappings. But we now expect to do using SQL instead of ODI interfaces.

    Is it possible to do this using the SQL statements we have source and target data sources defined in ODI.

    should be like "Insert into src.table select * from tar.table'"

    Thank you...

    Hello

    If you try to load a db to another db using sql (sql free hand) instead of interfaces instructions.

    It is possible using procedures odi too.

    1. Select the project (designer navigator) odi mode

    2. create the new procedure. Then add the command.

    in this command on the source command on the tabs of the target.

    Enter the sql statements. See the screenshots below...

    I think this will help for you,

    Thank you best regards &,.

    A.Kavya

  • Load data from one table to another

    Hi all

    Please help me for my sous condition.

    Oracle version: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod

    Rules
    -------
    (1) first two city must be loaded in city_1 and city_2.
    (2) if there are more than two cities, only two must be loaded first.
    (3) if only a city_1 is set, it must be loaded in city_1.

    drop table seven_cities;
    
    create table seven_cities
    (id     number,
     city_1  varchar2(100),
     city_2  varchar2(100),
     city_3  varchar2(100),
     city_4  varchar2(100),
     city_5  varchar2(100),
     city_6  varchar2(100),
     city_7  varchar2(100)
     );
     
     
    insert into seven_cities(id,city_1,city_2,city_3,city_4,city_5,city_6,city_7)
    values (1,'New York',null,null,null,'Chicago',null,null);
    
    insert into seven_cities(id,city_1,city_2,city_3,city_4,city_5,city_6,city_7)
    values (2,null,'Hyderabad','Delhi','Mumbai',null,null,null);
    
    
    insert into seven_cities(id,city_1,city_2,city_3,city_4,city_5,city_6,city_7)
    values (3,null,null,null,null,null,null,'London');  
    
    insert into seven_cities(id,city_1,city_2,city_3,city_4,city_5,city_6,city_7)
    values (4,null,null,null,'Sydeny','Melbourne','Paris','Berlin');
    
    commit;
    
    select * from seven_cities;
    
    drop table two_cities;
    
    create table two_cities
    (id number,
     city_1  varchar2(100),
     city_2  varchar2(100));
     
     Expected data to be loaded
     ----------------------------
    
    id       city_1          city_2
    1     New York             Chicago
    2     Hyderabad             Delhi
    3     London          null
    4     Sydney          Melbourne
    Thank you
    Rambeau

    The one I have already posted in response to your message duplicate (next time please do not submit duplicate messages):

    select  id,
            coalesce(city_1,city_2,city_3,city_4,city_5,city_6,city_7) city_1,
            nvl2(
                 city_1,
                 coalesce(city_2,city_3,city_4,city_5,city_6,city_7),
                 nvl2(
                      city_2,
                      coalesce(city_3,city_4,city_5,city_6,city_7),
                      nvl2(
                           city_3,
                           coalesce(city_4,city_5,city_6,city_7),
                           nvl2(
                                city_4,
                                coalesce(city_5,city_6,city_7),
                                nvl2(
                                     city_5,
                                     coalesce(city_6,city_7),
                                     nvl2(
                                          city_6,
                                          city_7,
                                          null
                                         )
                                    )
                               )
                          )
                     )
                ) city_2
      from  seven_cities
    / 
    
     ID CITY_1     CITY_2
    --- ---------- ----------
      1 New York   Chicago
      2 Hyderabad  Delhi
      3 London
      4 Sydeny     Melbourne
    
    SQL>
    

    And this solution, you are prompted by the solution of Tubby:

    with t as (
               select  id,
                       row_number() over(partition by id order by rownum) rn,
                       column_value city_1,
                       lead(column_value) over(partition by id order by rownum) city_2
                 from  seven_cities,
                       table(sys.OdciVarchar2List(city_1,city_2,city_3,city_4,city_5,city_6,city_7))
                 where column_value is not null
              )
    select  id,
            city_1,
            city_2
      from  t
      where rn = 1
    /
    
     ID CITY_1     CITY_2
    --- ---------- ----------
      1 New York   Chicago
      2 Hyderabad  Delhi
      3 London
      4 Sydeny     Melbourne
    
    SQL> 
    

    And if there is a concern on the use of the items in the collection without papers are read in the order behaviour, just create object & nested table types:

    create or replace
      type num_str_obj
        as object(
                  n number,
                  s varchar2(4000)
                 )
    /
    create or replace
      type num_str_list
        as table of num_str_obj
    /
    

    Now:

    with t as (
               select  id,
                       row_number() over(partition by id order by n) rn,
                       s city_1,
                       lead(s) over(partition by id order by n) city_2
                 from  seven_cities,
                       table(
                             num_str_list(num_str_obj(1,city_1),
                                          num_str_obj(2,city_2),
                                          num_str_obj(3,city_3),
                                          num_str_obj(4,city_4),
                                          num_str_obj(5,city_5),
                                          num_str_obj(6,city_6),
                                          num_str_obj(7,city_7)
                                         )
                            )
                 where s is not null
              )
    select  id,
            city_1,
            city_2
      from  t
      where rn = 1
    /
    
     ID CITY_1     CITY_2
    --- ---------- ----------
      1 New York   Chicago
      2 Hyderabad  Delhi
      3 London
      4 Sydeny     Melbourne
    
    SQL> 
    

    SY.

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

  • Insert records from one table to another table

    Hello

    I want to insert all records in table 1 which are not in table 2 in table2

    o/p
    Insert into table2
    Select * from table1
    where a.id! = b.id;

    Please let me know is there any way I can complete reviews
    insert
      into table2
      select  *
        from  table1
        where id not in (
                         select  id
                           from  table2
                        );
    

    SY.

  • Corresponding to a set of data from one table to another

    I have a table - Table_1 with columns A, B, C, D, I have another (Table_2) table with columns B, C, D.

    I try to get all the rows in Table_1 where the values correspond to columns B, C, D.

    The catch here is that returned from TABLE_1 lines should be the same number of rows as in TABLE_2 and the value in TABLE_1 from 'A' should be the same for all these lines. So--Table_1 could return several sets of data where the VALUE of A is different for each SET but - the 'GAME' must match all other values in TABLE_2 exactly (including the number of lines for each game)...

    Any help is greatly appreciated. I hope that I said above clearly enough.

    -create tables

    create table t1 (a varchar2 (10), varchar2 (10) b, c varchar (10), varchar2 (10)) d;
    create table t2 (varchar2 (10) b, varchar2 (10) c, varchar (10)) d;

    -create data, 5 games in t1 with 2 correspondents sets

    insert into t2 values ('1 ', '2',' 3');
    insert into t2 values ('2 ', '2',' 3');
    insert into t2 values ('3 ', '2',' 3');
    insert into t1 values ('a', '1', ' 2 ', 3');
    insert into t1 values ('a', '2', ' 2 ', 3');
    insert into t1 values ('a', '3', ' 2 ', 3');
    insert into t1 values ('b', '1', ' 2 ', ' 3');
    insert into t1 values ('b', '2', ' 2 ', ' 3');
    insert into t1 values ('c', '1', ' 2 ', ' 3');
    insert into t1 values ('c', '2', ' 2 ', ' 3');
    insert into t1 values ('c', '3', ' 2 ', ' 3');
    insert into t1 values ('c', '4', ' 2 ', ' 3');
    insert into t1 values (has "', 1 ', ' 2 ', ' 3'");
    insert into t1 values (has "', 2 ', ' 2 ', ' 3'");
    insert into t1 values (has "', ' 3, ' 2 ', ' 3'");
    insert into t1 values ('e', '4', ' 2 ', ' 3');
    insert into t1 values ('e', '5', ' 2 ', ' 3');
    insert into t1 values ('e', '6', ' 2 ', ' 3');

    Select * from t1 where one (not in
    Select a from t1 where does not exist (select 1 from t2 where b = t1.b and c = t1.c and d = t1.d)
    Union
    Select one of (select one, count (*) NTC group by a t1) where NTC! = (select count (*) from t2)
    )

    A B C D
    ---------- ---------- ---------- ----------
    1 2 3
    2 2 3
    3-2-3
    1 2 3 d
    2 2 3 d
    3 2 3 d

    6 selected lines

  • moving data from one table to another

    Hello

    I have a table called ABC. It is to have about 15 columns with a column having the LONG data type.

    ABC
    {
    Column1 varchar2 (10)
    Column2 number (7)
    Column3 LONG
    Column4 char (1)
    column 5...
    ...
    }

    What I want is to move all the records in another table called ABC_BACKUP where column4 of the ABC table value is * "X." Which means cutting all the records from ABC where column4 is * 'X' * and paste it into ABC_BACKUP. Can anyone suggest what is the best way to move this data? The volume of data can be maximum 400 000 records.

    I have oracle 10g.

    Thanks in advance.

    Ketan,

    Miss to ' * ' in the tips, you should be ok now. Keep us informed of your progress and I hope that helps you.

    INSERT / * + APPEND * / into ABC_BACKUP SELECT * FROM ABC WHERE ABC WHERE COLUMN = 'X '. *

    INSERT / * + PARALLEL (ABC_BACKUP, 2) * / select into ABC_BACKUP / * + PARALLEL (ABC, 2) * / * ABC WHERE column = 'X '. *
    Concerning

  • Create the trigger to insert data from one user to another user in same Databas

    Dear Sir, I created a trigger as follows

    CREATE OR REPLACE TRIGGER TRIGGER1
    BEFORE INSERTING
    ON table1
    FOR EACH LINE
    BEGIN
    INSERT IN THE TEST. TABLE2
    VALUES (: NEW.) COLUMN1,: NEW. COLUMN2,: NEW. COLUMN3,: NEW. COLUMN4);
    END;
    /

    I want here to insert my user to user Test data. In this Situation when I Execute The above Trigger it shows error PL/SQL: ORA-00942: table or view does not exist

    Help, please

    What do you mean by run the trigger?
    Do you compile?
    Can be open as a TEST and do the following and try to compile your code of the trigger again.

    grant insert on TEST.TABLE2 to youruser;
    

    See you soon,.
    Manik.

  • Need some ideas on the copy of the data from one schema to another.

    Dear all,

    I would like to know the best method and possible by copying data from one schema to another. (I won't use EXP / IMP).
    Example:


    I have a scheme of production on which I have hundreds of tables. I copy the data of the TEST environment after comparing data, I should copy the data incrementally.
    Maybe this copy of data may occur once a month, or on request.

    I want to have this done by a procedure.
    I was thinking about the logic below, using a procedure I will compare the tables and the structures between the two schemas.
    Then I willl use the primary key in both tables column and compare the data first. If the data if it does not exist then I only inserts these records in the target.
    The above said logic could be as similar as the synchronization of data or records, but the table does not all columns to track records archived / copied from the source.
    Suggest me so if you can give me the best logic or solution.

    Thanks in advance...

    Concerning
    Suresh

    GSKumar wrote:
    Dear all,

    I would like to know the best method and possible by copying data from one schema to another. (I won't use EXP / IMP).
    Example:
    I have a scheme of production on which I have hundreds of tables. I copy the data of the TEST environment after comparing data, I should copy the data incrementally.
    Maybe this copy of data may occur once a month, or on request.

    I want to have this done by a procedure.
    I was thinking about the logic below, using a procedure I will compare the tables and the structures between the two schemas.
    Then I willl use the primary key in both tables column and compare the data first. If the data if it does not exist then I only inserts these records in the target.
    The above said logic could be as similar as the synchronization of data or records, but the table does not all columns to track records archived / copied from the source.
    Suggest me so if you can give me the best logic or solution.

    I don't know why you don't want to opt for EXP/IMP.
    As an alternative, if you have a link DB between Production and Test pattern (which I seriously doubt), you can use the MERGER to a copy of data from Production to Test Delta.
    a. INTRODUCE IN test_schema.table_name SELECT sequence_columns, column_list FROM (SELECT column_list FROM prod_schema.table_name LESS SELECT column_list from test_schema.table_name)
    Column_list must not contain columns that contain sequence values because they may differ and result in an incorrect result; Therefore, this is taken into account in the outer query rather than Inline mode.
    b. MERGE STATEMENT
    c. FALL of test_schema.table_name. CREATE test_schema.table_name as SELECT column_list from prod_schema.table_name; -A way very neat to copy all the data, provided you do not keep any changes to test the tables in the schema.

    However, you mentioned to find existing records based on the primary key; IMO, primary key is normally a sequence (may be alphanumeric) and its value on env Production and Test may defer or even can have different attributes, therefore, I find it incorrect to match only the primary keys. I would say to match the key attributes.

    If you want to follow the last update/insert for a record, you can add a column that puts the time of last modification. In this way, you can track the changes of a column. Another alternative would be to use a check to the table.

    Let us know your thoughts or concerns, so that help can be provided.

    I suggest that you read and follow {message identifier: = 9360002}.
    If you will be useful if you can provide all the information required in advance to help us provide you with a quick resolution.

  • 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 data from one schema to another. Reopen the Question

    Hello

    I had asked this question earlier to copy data from tables of one schema to another in the same database using the database link. In my previous post have mentioned below.
    Re: copy data from one schema to another.
    Now I am faced with the question for the remote copy of database

    I have created a DB connection between my local system and the remote database. with the chain of connection as shown below
    CREATE THE DATABASE PUBLIC LINK "MERU_DEV_LOCAL_DEV".
    CONNECT TO MERUDEV IDENTIFIED BY MERUDEV WITH THE HELP OF "MERUPROD";
    In the above script
    LOCAL DEVELOPMENT scheme IS
    REMOTE schema is MERUDEV
    I try to copy remote database to my local database tables using the script below.
    network_link DEVELOPMENT impdp = schema MERU_DEV_LOCAL_DEV = MERUDEV remap_schema = MERUDEV:DEVELOPMENT TABLE_EXISTS_ACTION = REPLACE
    But the copy of the table does not occur. What could be the problem? Please suggest me or do I need to modify the script

    Thank you
    Sudhir

    You can:
    -monitor the BONE with ps - ef
    -monitor data pump: jobs are dba_datapump_jobs and dba_datapump_sessions
    -monitor with logops: v$ session_longops

  • copy data from one database to another

    Hello

    I want to copy data from one database to another.

    I have two patterns such as

    dev1/dev@ORCL
    DEV2/dev@DCEL


    I have same tables dev1 and dev2 (tables)
    but I have not given in dev2 (tables).
    now, I want to copy dev1 (tables) in dev2 (tables).

    You can also use the database link:

    select * from dev1.emp@orcl;
    

    What database are you connected to?
    You must create and use the links in the database for all other databases.

    For example if you are connected to the database A and to retrieve data from database B, you must create a connection of database in base B

    create database link B connect to  identified by  using 'B';
    

    Then you can retrieve data from database B with

    select * from [yourschema.]yourtable@B;
    

    This will work only for tables that are visible to the user that you used in the definition of database link.

    Published by: hm on 10.08.2011 22:15

  • Best way to move data from one page to another within the app

    Hi all as I started to write that and was way to complicated to explain in full without a novel.

    Brief description. I use the query string that begins in the parent (from href in JSON) window must then be moved in the iframe url when moving to other pages to avoid security as a page and iframe is conflicting http and https. and are not accessible... It seems that there must be a better way.

    So my question is what is the best way in a platform open to move data from one page to another?

    You do it this way, it's in the menu.json, but when you work within the iframe and if your loading pages in applications using vairable relative URLS cross they come through.
    Discovered only this framework using the browser and you can se the construction and scope of all URLS used.

    The apps are sandboxed you cannot access aything in the parent frame, this is a feature of derliberate if something you can not do.

    As I said, you have a few methods to your own data storage space.

  • transfer of data from one server to another server

    transfer of data from one server to another server... How is possible?

    We used to transfer data of one cube to another using... report script... then load rule... so can we use even for that?
    but

    I would like to know any other comments and other means (like to explore)

    If you move the range of data to load into the different cube, then you can use report script or calc extrcat data and can use the rule files to load the data.
    If you move the data to load into a cube replicated in another environment, you can take the lev0 data and can do the free form of loading.

Maybe you are looking for