数据库中的重复条目 [英] Duplicate Entries in DB

查看:55
本文介绍了数据库中的重复条目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个巨大的产品表,但有很多重复的条目.该表有超过 1 万个条目,我想删除其中的重复条目,而无需手动查找和删除它.如果您能为我提供解决方案,请告诉我

I have a huge table of products but there are lot of duplicate entries. The table has more than10 Thousand entries and I want to remove the duplicate entries in it without manually finding and deleting it. Please let me know if you can provide me a solution for this

推荐答案

删除重复行有不同的解决方案,完全取决于您的方案来利用它们中的一个.最简单的方法是更改​​表,使产品名称字段的唯一索引:

There are different solutions to remove duplicate rows and it fully depends upon your scenario to make use of one from them. The simplest method is to alter the table making the Unique Index on Product Name field:

alter ignore table products add unique index `unique_index` (product_name);

您可以在删除所有重复行后删除索引:

You can remove the index after getting all the duplicate rows deleted:

alter table products drop index `unique_index`;

如果这能解决问题,请告诉我.如果没有,我可以为您提供替代解决方案.

Please let me know if this resolves the issue. If not I can give you alternate solutions for that.

这篇关于数据库中的重复条目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆