4.5.1 OPTIMIZE TABLE Syntax OPTIMIZE TABLE tbl_name[,tbl_name]... OPTIMIZE TABLE should be used if you have deleted a large part of a table or if you have made many changes to a table with variable-length rows (tables that have VARCHAR, BLOB, or TEXT columns). Deleted records are maintained in a linked list and subsequent INSERT operations reuse old record positions. You can use OPTIMIZE TABLE to reclaim the unused space and to defragment the data le. For the moment OPTIMIZE TABLE only works on MyISAM and BDB tables. For BDB tables, OPTIMIZE TABLE is currently mapped to ANALYZE TABLE. See Section 4.5.2 [ANALYZE TABLE], page 227. You can get optimise table to work on other table types by starting mysqld with --skip-new or --safe-mode, but in this case OPTIMIZE TABLE is just mapped to ALTER TABLE. OPTIMIZE TABLE works the following way: If the table has deleted or split rows, repair the table. If the index pages are not sorted, sort them. If the statistics are not up to date (and the repair couldn't be done by sorting the index), update them. OPTIMIZE TABLE for MyISAM tables is equvialent of running myisamchk --quick --checkchanged- tables --sort-index --analyze on the table. Note that the table is locked during the time OPTIMIZE TABLE is running!
没有?!
我看书里写这有的!
用这个命令可以把中间被删除的记录的空间,用后面的记录填补上的!
这样可以优化数据库!若真的是没有这条命令的话,
那么请问:
把中间的某一条记录DEL了,要怎么样才可以把后面的记录填补上被DEL的空白??谢谢了!
OPTIMIZE TABLE tbl_name[,tbl_name]...
OPTIMIZE TABLE should be used if you have deleted a large part of a table or if you have
made many changes to a table with variable-length rows (tables that have VARCHAR, BLOB,
or TEXT columns). Deleted records are maintained in a linked list and subsequent INSERT
operations reuse old record positions. You can use OPTIMIZE TABLE to reclaim the unused
space and to defragment the data le.
For the moment OPTIMIZE TABLE only works on MyISAM and BDB tables. For BDB tables,
OPTIMIZE TABLE is currently mapped to ANALYZE TABLE. See Section 4.5.2 [ANALYZE
TABLE], page 227.
You can get optimise table to work on other table types by starting mysqld with --skip-new
or --safe-mode, but in this case OPTIMIZE TABLE is just mapped to ALTER TABLE.
OPTIMIZE TABLE works the following way:
If the table has deleted or split rows, repair the table.
If the index pages are not sorted, sort them.
If the statistics are not up to date (and the repair couldn't be done by sorting the
index), update them.
OPTIMIZE TABLE for MyISAM tables is equvialent of running myisamchk --quick --checkchanged-
tables --sort-index --analyze on the table.
Note that the table is locked during the time OPTIMIZE TABLE is running!
mysql>optimize table tbl_name;
上述两条命令都可以进行表优化,消除由于删除或更新记录而浪费的空间。两个命令的区别是前者比后者更快。