SQL Removal Duplicate Delete duplicate data (Tens data volume)

Source: Internet
Author: User

MySQL has 5 million data, but most of it is repetitive, true on the 1.8 million, so want to how to get these duplicate data out, find a lap on the internet, a lot of it is not in such a code, so inefficient, their own pondering a combination of, find an efficient way to deal with this way, 5 million of data , 10 minutes to remove all repeat, please refer to.

Step One: Extract the data_content_152 fields from the 5 million datasheet SFZHM the corresponding ID fields to the TMP3 table

The code is as follows Copy Code

CREATE TABLE Tmp3 as select min (id) as col1 from data_content_152 Group by SFZHM;

Step Two: Create a new table res

CREATE TABLE ' Res ' (

The code is as follows Copy Code

' ID ' int (11),
' Sfz ' char (20)
) Engine=myisam;

Step three: Add the TMP3 table ID to the data_content_152 data to be extracted in the SFZ field of the Res table
INSERT into Res (SFZ) SELECT sfzhm from Data_content_152,tmp3 where data_content_152.id=tmp3.col1
At this point, it is implemented in MySQL, to the data table data_content_152 completely delete duplicate data, the data to be repeated to the Res table.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.