Created
January 22, 2020 16:59
-
-
Save wriglz/da8dc43d7d33b92b53bb2aa4f4b7b4cb to your computer and use it in GitHub Desktop.
Replace schema.table and duplicate_field.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DELETE | |
FROM schema.table a USING | |
(SELECT MIN(ctid) AS ctid, | |
duplicate_field | |
FROM schema.table | |
GROUP BY duplicate_field | |
HAVING COUNT(*) > 1) b | |
WHERE a.duplicate_field = b.duplicate_field | |
AND a.ctid <> b.ctid; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment