If you need to add one or more indexes to an existing table, perform the following steps:
// add new index to table
CTTable ATable(ADatabase);
// open the table
ATable.Open("MyTable", CTOPEN_ NORMAL);
// add the new index
ATable.AddIndex("MyNewIndex", CTINDEX_FIXED, YES, NO);
// add new index segments
ATable.AddSegment("MyNewIndex", "Field1", CTSEG_SCHSEG);
// alter the table to commit index changes to disk
try
{
ATable.Alter(CTDB_ALTER_NORMAL);
}
catch (CTExplorer &err)
{
printf("Alter table failed with error %d\n", err.GetErrorCode());
}