Icon REPAIR TABLE

Repairs a table.

Syntax
REPAIR TABLE <TableName>
[STRUCTURE ONLY]
[STATISTICS]

Usage
Use this statement to repair the specified table.

The STRUCTURE ONLY clause can be used to specify that ElevateDB should only do a structural scan, and not actually examine the contents of rows for more in-depth corruption checks. Using this clause can improve the performance of a repair greatly, but does not guarantee that the row contents are not possibly still corrupted. Usually the best practice is to first execute the VERIFY TABLE statement on the specified table with the STRUCTURE ONLY clause. If the VERIFY TABLE execution indicates any corruption at all, then you should execute the REPAIR TABLE statement on the specified table without the STRUCTURE ONLY clause so that the table is exhaustively repaired.

The STATISTICS clause was added in ElevateDB 2.03 Build 7 in order to correct an issue with prior releases and builds where the engine was incorrectly calculating the index statistics for a table. These statistics are used by the query optimizer to estimate the amount of I/O that a particular index scan will cause, and so it is very important that this information be correct. Running the REPAIR TABLE statement with the STATISTICS clause will cause the index statistics to be recalculated for all indexes present in the specified table.

Information The STATISTICS clause causes the REPAIR TABLE to only recalculate the index statistics, and not actually perform a complete repair.

If you create a table with ElevateDB 2.03 Build 7 or higher, then you will never need to use the STATISTICS clause. The STATISTICS clause is deprecated in 2.04 or higher due to the new repair/verify functionality.

You can use the STMTRESULT function to retrieve the result of a table repair in any procedure, function, script, or job. For retrieving the result of a table repair from a client application, please see your compiler-specific manual for retrieving the result of a statement exectuion.

The REPAIR TABLE statement requires exclusive access to the specified table.

Examples
REPAIR TABLE Orders

Required Privileges
The current user must be granted the MAINTAIN privilege on the current database in order to execute this statement. Please see the User Security topic for more information.

SQL 2003 Standard Deviations
This statement deviates from the SQL 2003 standard in the following ways:

DeviationDetails
ExtensionThis SQL statement is an ElevateDB extension.
Image