Change the default value of a large table using alter table without recreating the table. Modify the. frm directly.

Source: Internet
Author: User

To change the default value of a large table, use alter table instead of recreating the table. frm executes most of the modification operations in mysql. It needs to recreate a table, put the data in it, and delete the old table! Sometimes, when there are a large number of indexed columns and frequent tables, the system performance will be seriously degraded. Here, you can make some adjustments on modifying the SQL statement, reduce the system pressure caused by the relevant build structure! For example, when you modify the default value of 8 for a table at www.2cto.com, the general practice is: (1): alter table modes modify column dept tinyint (3) not null default 8; the show status analysis shows that a large number of read and insert operations are performed each time, similar to creating a new table style. In this way, in some large tables, a bottleneck may occur when tens of millions of data records exist! Here we need to flexibly know that the default values of mysql are actually placed in the related table structure. frm file; we can directly adjust them without going through the data layer! The above modify column will cause the relevant table to be copied, which is not conducive to the normal and stable operation of the system. You can use the following method; www.2cto.com (2): alter table modes alter column dept set default 8; here, we only changed the relevant frm file and did not change the table, so the speed can be completed quickly. Summary: here we can note that the related alter table is followed by different commands, it may have different degrees of impact on data. Here there is also a change column operation!

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.