我需要从包含30列的表中删除完全重复的记录。 我的数据看起来像附件。高级谢谢!
答案 0 :(得分:1)
你的问题我这样理解......
1)如果你只想删除重复行中的一个记录。在这种情况下,你需要一个列表日期(表中的当前时间戳)
delete from tableName t1 where
t1.id in (SELECT t2.id
FROM tableName t2
where t1.id = t2.id and t1.date(timestamp) < t2.date(timestamp))
2)如果你想删除完整的重复行
delete from tableName t1 where
t1.id in (SELECT t2.id
FROM tableName t2
group by t2.id
having count(*) >1)
答案 1 :(得分:0)
这个应该有效:
delete from <table>
where rowid IN (
SELECT LEAD(rowid) OVER (PARTITION BY <col1>, <col2>,...,<coln> ORDER BY NULL)
FROM <table>
);
当然还有Fiddle