pgsql:删除表中重复数据保留其中的一条

1.在表中(表名:table 主键:id)增加一个字段rownum,类型为serial

2.执行语句:

delete from table where rownum not in( 
select max(rownum) from table group by id 
)

3.最后删除rownum

猜你喜欢

转载自blog.csdn.net/qq_27935743/article/details/72125649