TurboDB VCL Component Library

Updating or Reparing an Index

Previous  Top  Next

Sometimes, mainly because of crashes or program termination during debugging, an index might go out of sync with the table. You will notice this, when the number of records in the table is less then expected, when this index is set or by doing a check of the table in TurboDB Viewer. If the index is no more correct, you can repair it by just re-building it:

Rebuild an index with TurboDB Viewer:

1.Connect to the database and select the table you want to rebuild the index for.
2.Select Table/Maintain... in the main menu.
3.If you want to check the table first, click on the Start button and wait until the analysis is finished. It will display problems found with the table. If there is something about an index, the index must be re-built.
4.Check the Rebuild all indexes check box in the Repair Options group and click Apply. TurboDB Viewer will now rebuild all indexes of the table. Which might take a few minutes if the table is large.

Rebuild an index at run-time with a TTdbTable component:

1.Create a TTdbTable component for the table you want to rebuild the index for.
2.If the index is a normal index call the UpdateIndex method, if it is a full-text index, call the UpdateFulltextIndex method.

Rebuild an index at run-time using SQL:

1.Create a TTdbQuery component for the database the index is in.
2.Set the SQL text property to
UPDATE INDEX <Table-Name>.<Index-Name>
or in case of a full-text indes to
UPDATE FULLTEXTINDEX <Table-Name>.<Full-text-Index-Name>
3.Call the ExecSQL method on the TTdbQuery component.