ctdbAddField
Add a new field to table
Declaration
CTHANDLE ctdbAddField(CTHANDLE Handle, pTEXT FieldName,
CTDBTYPE FieldType, VRLEN FieldLength)
Description
ctdbAddField() adds a new field to the end of a table. Fields added with this function are sequentially-numbered, starting with field number zero. If the table has no fields, the first field added will be field number zero. If the table has five fields already (numbered zero to four), the next field added by this function will be field number five.
Use ctdbInsField() and ctdbInsFieldByName() to insert a field in a table in a specified position. Use ctdbDelField() and ctdbDelFieldByName() to delete fields from the table. Note that ctdbAddField() does the field handle allocation, so no explicit "alloc" calls need to be made on the field handles. Field handle deallocation is automatically handled by ctdbCloseTable() and ctdbCloseAll(). After the segments, indexes, and fields have been defined, the table can be created or altered with ctdbCreateTable() or ctdbAlterTable().
Returns
ctdbAddField returns a newly-allocated field handle on success, or NULL on failure.
Example
pMyTable = ctdbAllocTable(pMyDatabase);
pMyField0 = ctdbAddField(pMyTable, "Name", CT_FSTRING, 32); /* Field #0 */
pMyField1 = ctdbAddField(pMyTable, "Balance", CT_SFLOAT, 4); /* Field #1 */
pMyIndex = ctdbAddIndex(pMyTable, "iName", CTINDEX_FIXED, NO, NO);
pMyIseg = ctdbAddSegment(pMyIndex, pMyField0, 2);
RetVal = ctdbCreateTable(pMyTable,"Table1",CTCREATE_NORMAL);
See also
ctdbAllocTable(), ctdbInsField(), ctdbInsFieldByName(), ctdbDelField(), ctdbDelFieldByName(), ctdbMoveField(), ctdbCreateTable(), ctdbAlterTable()