Product Documentation

c-treeDB API for C++ - Developers Guide

Previous Topic

Next Topic

Deleting an index from a table

If you need to delete one or mode indexes from a table, perform the following steps:

  1. Delete the index by calling CTTable::DelIndex(). There is no need to delete the index segments. Repeat this step for each index you want to delete.
  2. Call CTTable::Alter() to delete the index from the table.

// delete the first index

CTTable ATable(ADatabase);


// open the table

ATable.Open("MyTable", CTOPEN_NORMAL);


// delete the first index - MyIndex0

ATable.DelIndex("MyIndex0");


// 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());

}

TOCIndex