There may be situations where you may need to build the indexes of a table. You can use the CTDB_ALTER_INDEX action parameter of CTTable::Alter() method to force the rebuild of all indexes of a table. when CTDB_ALTER_INDEX is specified, CTTable::Alter() will rebuild all indexes of a table regardless of any changes done to the table specification.
// rebuild all indexes
CTTable ATable(ADatabase);
// open the table
ATable.Open("MyTable", CTOPEN_NORMAL);
// rebuild all indexes
// alter the table to commit index changes to disk
try
{
ATable.Alter(CTDB_ALTER_INDEX);
}
catch (CTExplorer &err)
{
printf("Alter table failed with error %d\n", err.GetErrorCode());
}