Product Documentation

c-treeDB API for C# - Developers Guide

Previous Topic

Next Topic

Forcing an Index Rebuild

There may be situations where you need to rebuild the indexes of a table. You can use the ALTER_TABLE.INDEX action parameter of the CTTable.Alter() method to force the rebuild of all indexes of a table. When ALTER_TABLE.INDEX is specified, CTTable.Alter() will rebuild all indexes of a table regardless of any changes made to the table specification.

// rebuild all indexes

CTTable ATable = new CTTable(ADatabase);


// open the table

ATable.Open("MyTable", OPEN_MODE.NORMAL_OPEN);


// rebuild all indexes

// alter the table to commit index changes to disk

try

{

ATable.Alter(ALTER_TABLE.INDEX);

}

catch (CTException err)

{

Console.Write("Alter table failed with error {0}\n", err.GetErrorCode());

}

TOCIndex