Home > Database > Mysql Tutorial > How to quickly delete large amounts of data in mysql

How to quickly delete large amounts of data in mysql

coldplay.xixi
Release: 2020-10-26 17:03:06
Original
2759 people have browsed it

Mysql quick way to delete a large amount of data: first create a temporary table, the table structure is the same as the original table structure; then insert the data that needs to be retained into the temporary table, and drop the original table; finally, rename the temporary table The original table name will do.

How to quickly delete large amounts of data in mysql

Mysql quick way to delete large amounts of data:

Option 1,

Use delete directly

Because the delete execution speed is proportional to the number of indexes, if there are many indexes in the table, using delete will take hours or even days

Option 2,

(1) Create a temporary table, the table structure is the same as the original table structure

(2) Insert the data that needs to be retained into the temporary table Medium

(3) Drop the original table

(4) Rename the temporary table to the original table name

After testing, dropping the table is generally time-consuming Within 3 seconds

The main time-consuming step of this solution is the second step. If the amount of data that needs to be retained is not large, this solution is the best solution

Update More related free learning recommendations: mysql tutorial(Video)

The above is the detailed content of How to quickly delete large amounts of data in mysql. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template