PostgreSQL中的记录重复 [英] Duplicate records in postgresql
本文介绍了PostgreSQL中的记录重复的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在PostgreSQL中有一个表。我在那里导入了500万条记录。并且不小心导入了一些重复记录,所以我不需要从表中删除这些重复记录。这里的表主键是四列的组合。.
I have a table in PostgreSQL.And I have imported 5 Million records there .And accidentally imported some duplicate records there no I need to remove those duplicate records from the table.Here Table's primary key is the combination of four columns..
推荐答案
create table t2 as
select distinct on (col1, col2, col3, col4) *
from t;
drop table t;
alter table t2 rename to t;
这篇关于PostgreSQL中的记录重复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文