在Oracle数据库中,删除重复数据,大都会使用如下方法:

delete from tbl a
where rowid<>(select max(b.rowid)
from tbl b where a.col1=b.col1 and a.col2 = b.col2);

但是,为什么这样能够删除数据呢?

我个人认为,max(rowid)应该得到一个唯一的值,而 <> max(rowid)则是表中的其它所有数据,所以删除应该是删除其它所有数据才对,为什么只是删除了重复的数据呢?rowid里面有什么玄机?

相关文章:

  • 2021-11-23
  • 2022-02-17
  • 2021-12-11
  • 2021-08-04
  • 2021-09-19
  • 2021-09-24
猜你喜欢
  • 2021-11-29
  • 2021-09-09
  • 2022-12-23
  • 2021-12-28
  • 2021-11-29
  • 2021-05-01
相关资源
相似解决方案