pgsql删除重复记录
如下:
DELETE FROM categories a WHERE ( a.id, a.name, a.parent_id ) IN ( SELECT id, name, parent_id FROM categories GROUP BY id, name, parent_id HAVING count( * ) > 1 ) AND ctid NOT IN ( SELECT min(ctid) FROM categories GROUP BY id, name, parent_id HAVING count( * ) > 1 )
关键点:oracle中有内部id为rowid, 在postgresql中有ctid.