Created
March 7, 2020 09:22
-
-
Save yuhangch/c96849a389e3fd0dff92735a142acde6 to your computer and use it in GitHub Desktop.
Delete Repeat Records in Postgresql
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
--将数据去重后存入临时表,PostgreSQL会自动创建tmp_table以及表结构 | |
select distinct * into tmp_table from repeat_table; | |
--删除原记录 | |
delete from repeat_table; | |
--将临时表数据插入原表 | |
insert into repeat_table select * from tmp_table; | |
--删除临时表 | |
drop table tmp_table; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment