删除重复行 各位好。现在有一张表的某些行的各字段值都是一模一样的,如何写一个delete语句来去重呢? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 这个在baidu里面一搜 很多吧?http://apps.hi.baidu.com/share/detail/9249849 delete from table_name t where rowid<(select max(rowid) from table_name a where a.field1=t.field1 and a.field2=t.field2....); --参考:delete from table_name awhere not exists( select 1 from table_name b where a.id = b.id --表的自连接条件 and a.col < b.col --这个是最重要的条件,它确定了保存那条数据 ) 一般采用伪列rowid来删除重复数据比较好 根据rowid 来删除rowid比最小值更大的。delete from tab a where rowid>(select min(rowid) from tab b where a.id=b.id and ....) Mysql不明的原因重启失败。 关于表设计的字典表问题 VC如何获取Oracle存储过程定义的异常处理 请教oracle 数据库专家 oracle 10g 不能登陆了 请教怎么在Oracle存储过程返回结果集? Oracle创建表失败 并发操作数据库发生异常时该怎么处理? oracle 8 不支持join吗? 32位的win7装了Oracle11g标准版,开始菜单不显示Oracle11ghome Oracle 11G客户端配置问题 关于表空间的一点小问题
--参考:
delete from table_name a
where not exists(
select 1
from table_name b
where a.id = b.id --表的自连接条件
and a.col < b.col --这个是最重要的条件,它确定了保存那条数据
)
delete from tab a where rowid>(select min(rowid) from tab b where a.id=b.id and ....)