Icon OPTIMIZE TABLE Statement

Introduction
The SQL OPTIMIZE TABLE statement is used to optimize a table.

Syntax
OPTIMIZE TABLE [IF EXISTS] table_reference

[ON index_name]

[NOBACKUP]

Use the OPTIMIZE TABLE statement to remove all free space from a table and organize the data more efficiently.

ON Clause
The ON clause is optional and specifies the name of an index in the table to use for organizing the physical data records. It is usually recommended that you do not specify this clause, which will result in the table being organized using the primary index.

NOBACKUP Clause
The NOBACKUP clause specifies that no backup files should be created during the process of optimizing the table.

The statement below optimizes a table and suppresses any backup files:

OPTIMIZE TABLE Employee NOBACKUP

Please see the Optimizing Tables topic for more information on optimizing tables.
Image