Product Documentation

VCL/CLX Developers Guide

Previous Topic

Next Topic

Alter the table

AlterTable() scans the table, field, index, and segment structures to decide which changes need to be made and how to do it. At the very least, it may only update the DODA. If more than one index changed, or more than one index was added or deleted, then it may be necessary to rebuild all indexes of the table. If fields were added, deleted, inserted, or the changes in the field property were not compatible with each other, then Alter needs to perform a full rebuild of the table.

A table is rebuilt by creating a temporary table with the correct current properties taking into consideration all changes. All records are read from the original table and written into the temporary table. 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.

AlterTable() method takes as parameters an active table handle and an alter table action parameter:

Action

Value

Explanation

CTDB_ALTER_NORMAL

0

Check for table changes before altering the table and perform only the changes required.

CTDB_ALTER_INDEX

1

Force rebuild of all indexes, regardless of table changes.

CTDB_ALTER_FULL

3

Force full table rebuild, regardless of table changes.

CTDB_ALTER_PURGEDUP

4096

Purge duplicate records

CTDB_ALTER_TRUNCATE

8192

Quickly remove all records

TOCIndex