Last active
August 20, 2021 05:46
-
-
Save mvodep/3681eb16e8793bfcc08cd8a85270cb2a to your computer and use it in GitHub Desktop.
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
BEGIN; | |
LOCK TABLE new_table IN ACCESS EXCLUSIVE MODE; | |
CREATE TABLE new_table_clean AS | |
(SELECT DISTINCT ON(column1, column2) * FROM new_table); | |
TRUNCATE TABLE new_table; | |
INSERT INTO new_table SELECT * FROM new_table_clean; | |
END; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment