有2个表,结构相似,有一个字段关联,现在怎么把A表的数据添加到B表中,条件是A表不在B表的数据?? 请各位高手多多指点,是oracle的数据库

1insert into b(col1,col2
)select col1,col2 where not exists(select a.col1 from a where a.col1 = b.col1)
2INSERT INTO B
  (COL1, COL2)
  (SELECT COL1, COL2
     FROM A
   MINUS
   SELECT COL1, COL2 FROM B)
3:
使用merge
merge into B
  using A on b.col=a.col --关联字段
when not matched then insert values(...,...,...)

 

posted @ 2017-08-09 15:32  李清欣  阅读(421)  评论(0编辑  收藏  举报