pgsql删除重复记录
时间:2021-07-01 10:21:17
帮助过:15人阅读
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.
参照:oracle rowid and postgresql ctid
参照:SQL 删除重复记录,并保留其中一条
pgsql删除重复记录
标签:postgresq group font pos from _id sel sql sdn