Statement
The Stars last night
Blog:http://yestreenstars.blog.51cto.com/
This article by oneself creation, if need reprint, please indicate source, thank cooperation!
Objective
Manually implement MySQL Archive
Demand
A table has a large amount of data, but only the last 3 months of data, delete the data directly and afraid of customer trouble, so you want to create a spare table, 3 months ago to move the data into the alternate table.
Environment
CentOS 6.6 32bit
MySQL 5.6
Operation
# Create an archive table (duplicate table structure and index only) create table Mytablebak like mytable;# Delete all indexes of the archive table (this will increase the insertion speed) # import data from 3 months ago into the archive table insert into Mytablebak SELECT * from MyTable where date < ' 2015-12-25 '; # Delete data from the original table 3 months ago Delete from MyTable where date < ' 2015-12-25 '
This article is from the "Last Night Stars" blog, please make sure to keep this source http://yestreenstars.blog.51cto.com/1836303/1744832
Manually implement MySQL Archive