如何删除具有2000万行数据集的MySQL中的重复项? [英] How to remove duplicate items in MySQL with a dataset of 20 million rows?

查看:90
本文介绍了如何删除具有2000万行数据集的MySQL中的重复项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有很大的MySQL数据库.我需要快速删除重复的项目.外观如下:

I've got big MySQL database. I need to delete the duplicate item quickly. Here's how it looks:

id | text1 | text2|    
1  | 23    |  43  |   
2  | 23    |  44  |  
3  | 23    |  44  |

删除后,表的其余部分应为:

After the deleting, the remain part of table should be:

id | text1 | text2|   
1  | 23    |  43  |   
3  | 23    |  44  |

我不在乎ID.最重要的是不会有重复的项目消失.

I don't care about the id. the most important is no duplicate items will be disappear.

推荐答案

您可以尝试以下方法:

ALTER IGNORE TABLE my_tablename ADD UNIQUE INDEX idx_name (text1 , text2);

即,尝试将UNIQUE INDEX添加到您的列中,并将alter添加到表中

ie, try to add UNIQUE INDEX to your columns and alter the table

这有一个优势,将来也不会有重复的行可以插入表中

This has an advantage that in future also there will be no duplicate rows which you can insert in your table

这篇关于如何删除具有2000万行数据集的MySQL中的重复项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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