Faster ALTER TABLE ADD column

Source: Internet
Author: User

    1. Create a new table (using the structure of the current table) with the new column (s) included.
    2. Execute aINSERT INTO new_table SELECT (column1,..columnN) FROM current_table;
    3. Rename the current table
    4. Rename the new table using the name of the current table.

1. CREATE TABLE new_table LIKE table;

2. INSERT INTO new_table SELECT * FROM table;

3&4.RENAME TABLE table = old_table, table = new_table;

The usual trick for loading MyISAM table efficiently are to disable keys, load the data and renalbe the keys:

mysql> ALTER TABLE test.load_data DISABLE KEYS;-- load datamysql> ALTER TABLE test.load_data ENABLE KEYS;

dropped all indexes -- then added the field and recreate indexes

REF:

Http://stackoverflow.com/questions/5677932/optimize-mysql-for-faster-alter-table-add-column

Http://dba.stackexchange.com/questions/9746/mysql-fastest-way-to-alter-table-for-innodb

Http://dba.stackexchange.com/questions/134269/fastest-way-to-add-new-column-in-mysql

Faster ALTER TABLE ADD column

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.