Home > Database > Mysql Tutorial > The database size remains unchanged after mysql delete deletes the record_MySQL

The database size remains unchanged after mysql delete deletes the record_MySQL

WBOY
Release: 2016-07-06 13:32:50
Original
1211 people have browsed it

When DELETE is followed by a condition, this problem will occur

delete from table_name where condition

After deleting data, the space occupied by the data table will not change.

When you delete directly without following the conditions.

delete from table_name
Copy after login

The data is cleared, and the space of the data table will also become 0

If a large portion of the table data has been deleted, or there are many changes and variable length table rows (VARCHAR tables, VARBINARY, BLOB or text columns) have been changed because of the fragmentation left in the data file after the deletion operation To. DELETE only deletes the data identification bits and does not organize the data files. When new data is inserted, the record space set as the deletion identification will be used again. You can use OPTIMIZE TABLE to reclaim unused space and defragment the data files. .

OPTIMIZE TABLE only works on MyISAM, BDB and InnoDB tables.

OPTIMIZE TABLE table name;

For the myisam engine, using optimize table also has the following functions:

If the table has deleted or split rows, repair the table. [修复表]
If the index pages are not sorted, sort them. [索引未排序,会排序]
If the table's statistics are not up to date (and the repair could not be accomplished by sorting the index), update them.[若表的统计信息不是最新的,更新它]
Copy after login

After batch deletion of the myiam data table, it was found that the space was not reclaimed. The space needs to be reclaimed through optimize table

The above is the knowledge that the editor introduces to you about how the database size remains unchanged after the MySQL delete deletes the record. I hope it will be helpful to everyone!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template