insert into table3(b,c,d)
select b,c,d from (
select b,c,d from table1 where ...
union  
select b,c,d from table2 where ...
)

解决方案 »

  1.   

    下面的就可以了,不过数据多的话比较慢。
    insert into table3
    select distinct b,c,d
    from table1;insert into table1
    select distinct b,c,d
    from table2
    where (b,c,d) not in (
     select b,c,d from table1
    );
    commit;
      

  2.   

    我执行的时候报错:ora-00001:unique constraint [device.pk_dddaa] violated
    这是什么原因
      

  3.   

    因为,你的主建重复,所以有问题,下面的不会有错。insert into table3(b,c,d)
    select b,c,max(d) 
    from 
    ( select b,c,d from table1 
      union  
      select b,c,d from table2 )
    group by b,c
      

  4.   

    我试了一下,是主键重复的问题,但我在table3中,把b,c作为主键,在插入俩条数据时,我改变b,c俩列中的一列值,报上面的错