Created
March 20, 2015 00:21
-
-
Save martjanz/df81fe29ae00c3c1e1b3 to your computer and use it in GitHub Desktop.
Delete duplicate rows (PostgreSQL)
This file contains hidden or 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
-- Works OK in PostgreSQL 9.3 | |
DELETE FROM table_name | |
WHERE ctid NOT IN | |
(SELECT MAX(ctid) | |
FROM | |
table_name t | |
GROUP BY | |
t.column_1, t.column_2; -- t.* for completely duplicate rows |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment