A表和B表,表结构一致,如何把B表中和A表不相同的数据插入A表,这是我的面试题,请大家帮忙想一想。

解决方案 »

  1.   

    方法很多minus就是其中一个insert into a 
    select id,name,addr from a
    minus
    select id,name,addr from b;(语法忘记了 )大致就是这样也可以用外连接   
      

  2.   

    insert into a 
    select id,name,addr from b where not exists(select id from a where a.id=b.id)
      

  3.   

    insert into a 
    select id,name,addr from b where not exists(select id from a where a.id=b.id)
    正解。
    取得相同的把not exist改为exist即可
      

  4.   

    insert into a 
    select id,name,addr from b
    minus
    select id,name,addr from a;
      

  5.   

    insert into A
    select * from A,B where a.id(+)=b.id where a.id is null