Manually implement MySQL Archive

Source: Internet
Author: User

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

Related Article

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.