从一个表中查询出数据 经过简单处理然后插入到另外一个表中,如何保证另外一个表中的数据不重复呢?

解决方案 »

  1.   

    建立一个临时表,用merge into来处理
      

  2.   

    merge into很好
    merge into tb1 a using(select * from tb2) b on(a.col=b.col)
    when not matched then insert(a.col.....) values(b.col.....)
      

  3.   

    删除表中重复记录
    delete from table tab where rowid not in(selecct min(rowid) from tab group by id)
      

  4.   

    create table AA_BAK AS 
    SELECT * from AA;然后 把编辑后的记录查到AA_BAK
    AA_BAK 中没有约束条件,也没有键值
    然后delete from AA_BAK  where rowid  in(selecct min(rowid) from AA group by rowid);
    COMMIT;最后,
    inset into AA  SELECT * FROM AA_BAK ;
    COMMIT;
      

  5.   

    补充,
    delete句 应该用key值 
    最后把 备份表删除
    drop table AA_BAK ; 应该可以吧