Product Documentation

VCL/CLX Developers Guide

Previous Topic

Next Topic

Forcing a Table Rebuild

There may be situations where you may need to force a full table rebuild. Please remember that in a full table rebuild a temporary table is created based on the properties of the original table, all records are read from the original table and written into the temporary table. All indexes are also rebuilt. Once all data records have been moved, the original table is deleted and the temporary table is renamed with the name of the original table. To force a table rebuild call AlterTable() with CTDB_ALTER_FULL parameter.

Delphi Example


procedure Form1.AltTable();

begin

try

CtTable1.Database := CtDatabase1;

CtTable1.Table := 'MyTable';

CtTable1.DeleteField('Age');

CtTable1.AddIndex('Index02', CTINDEX_FIXED, True, False);

CtTable1.AddSegment('Index02', 'Salary', CTSEG_SCHSEG);

CtTable1.AlterTable();

except

on E : ECtError do

Application.ShowException(E);

end;

end;

C++ Example


void Form1::AltTable()

{

try

{

CtTable1->Table = "MyTable"

CtTable1->Database = CtDatabase1;

CtTable1->DeleteField("Age");

CtTable1->AddIndex("Index02",CTINDEX_FIXED,True, False);

CtTable1->AddSegment("Index02", "Salary", CTSEG_SCHSEG);

CtTable1->AlterTable();

}

catch (ECtError& E)

{

Application->ShowException(&E);

}

}

TOCIndex