Product Documentation

c-treeDB API for C# - Developers Guide

Previous Topic

Next Topic

Alter the Table

If you need to add one or more indexes to an existing table, perform the following steps:

  1. Add the index by calling CTTable.AddIndex(). Repeat this step for each new index.
  2. Add, insert, or delete index segments by calling the overloaded methods CTTable.AddSeg, CTTable.InsertSegment(), or CTTable.DelSegment(). Repeat this step for each segment of the index.
  3. Call CTTable.Alter() to add the new index

// add new index to table

CTTable ATable = new CTTable(ADatabase);


// open the table

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


// add the new index

ATable.AddIndex("MyNewIndex", KEY_TYPE.FIXED_INDEX, true, false);


// add new index segments

ATable.AddSegment("MyNewIndex", "Field1", SEG_MODE.SCHSEG_SEG);


// alter the table to commit index changes to disk

try

{

ATable.Alter(ALTER_TABLE.NORMAL);

}

catch (CTException err)

{

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

}

TOCIndex