MySQL database data correction

Source: Internet
Author: User
This operation is not difficult because data correction is often required during work. Rollback is required during operation ~ For rollback requirements, I usually perform backup tables and then execute

This operation is not difficult because data correction is often required during work. Rollback is required during operation ~ For rollback requirements, I usually perform backup tables and then execute

This operation is not difficult because data correction is often required during work. Rollback is required during operation ~ For rollback requirements, I usually perform a backup table and then perform a change! If a correction error is sent or the user requests a rollback, the entire table is completely restored. This operation is redundant because we only need
You can select the data to be backed up for correction! For example:
Update usage_type = 'unused' and user_id = 166 to user_id = 169! 100 updates!
1. Back up the table first
Create table test. resource_20120221
Select * from resource where usage_type = 'unused' and user_id = 166 order by id limit 100;
2. perform data correction
Update resource set user_id = 169 where user_id = 166 and id in (select id from test. resource_20120221 );
If you want to roll back, you only need to execute
Update resource set user_id = 166 where id in (select id from test. resource_20120221 );
You can!
Correction of small batches of data is involved here. If a large amount of data is used, the batch submission method is required!

Attached:
DDL change techniques for M-M Architecture
L M-M replication architecture, only one provides all or primary data services
Recommended DDL statements, in the current M-M architecture is the standby Database Server priority execution, there are four advantages:
1. Data Services Provided by the database are not immediately affected;
2. Log Recovery Operations for data replication between the master and slave databases are not blocked;
3. During DDL statement execution, if a problem occurs, only the stability of the standby database is affected, but the primary database is rarely affected;
4. If there is a seamless switchover function for data services (such as heartbeat and autonomous data layer), you can switch between the master and slave databases provided by the data service after the slave database is executed, especially when a table with a large data capacity is changed, it can reduce the impact on the business and the downtime maintenance time and the number of times;
Operations

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.