The database size remains unchanged after the delete record of mysql is deleted, and mysqldelete

Source: Internet
Author: User
Tags mysql delete

The database size remains unchanged after the delete record of mysql is deleted, and mysqldelete

This problem occurs when conditions are followed after the DELETE operation.

Delete from table_name where Condition

After the data is deleted, the space occupied by the data table does not change.

When the condition is not followed, the delete operation is performed directly.

Delete from table_name

The data is cleared and the data table space is changed to 0.

If a large part of the table data has been deleted, or many changes and variable-length table rows (VARCHAR table, VARBINARY, BLOB, or text column) have been made, this is because fragments are left in the data file after the delete operation. DELETE only deletes data identifiers and does not organize data files. When new data is inserted, the deleted identifiers are used again, you can use optimize table to recycle unused space and sort data file fragments.

Optimize table only applies to MyISAM, BDB, and InnoDB tables.

Optimize table name;

For the myisam engine, optimize table also has the following features:

If the table has deleted or split rows, repair the table. [repair table] If the index pages are not sorted, sort them. [the index is not sorted and will be sorted] If the table's statistics are not up to date (and the repair cocould not be accomplished by sorting the index), update them. [update a table if its statistical information is not up-to-date]

After the myiam data table is deleted in batches, it is found that the space is not recycled. Use optimize table to recycle the space.

The above is a small Editor to introduce you to the mysql delete records after the database size remains unchanged, I hope to help you!

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.