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.....)
删除表中重复记录 delete from table tab where rowid not in(selecct min(rowid) from tab group by id)
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;
补充, delete句 应该用key值 最后把 备份表删除 drop table AA_BAK ; 应该可以吧
merge into tb1 a using(select * from tb2) b on(a.col=b.col)
when not matched then insert(a.col.....) values(b.col.....)
delete from table tab where rowid not in(selecct min(rowid) from tab group by id)
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;
delete句 应该用key值
最后把 备份表删除
drop table AA_BAK ; 应该可以吧