Product Documentation

c-treeDB API API for C

Previous Topic

Next Topic


Add an existing table to a database with additional physical file information.


ctdbAddTableXtd( CTHANDLE Handle, pTEXT Name, pTEXT PhysicalName, pTEXT Path )


ctdbAddTableXtd() adds an existing table to a database. Use the Path parameter to specify where the table files are on disk. If Path is left empty, c-treeDB API will attempt to locate the files in the Server directory (client/server) or in the execution directory (standalone).

  • Handle [in] the database handle. As of V12 Handle can be a table handle. If it is a table handle, the database handle is derived from it, and any dictionary mark setting in the table handle is used when adding the table to the dictionary. See ctdbSetTableDictionaryMark() (ctdbSetTableDictionaryMark, ctdbSetTableDictionaryMark)
  • Name [in] the logical name of the table to be added as referenced in the c-treeDB API database.
  • PhysicalName [in] the physical name of the file on disk, including the file extension, usually .dat.
  • Path [in] the table path.

This extended function allows adding a table to a c-treeDB API database specified with a logical and physical table name (the physical table name is the name on disk without extension and path), the logical table name is the one associated with file operations such as ctdbOpenTable().

Note: While multiple files with the same physical names can be added to a c-treeDB API database dictionary, they logical names must still be unique.

A mirrored table can be added to a c-treeDB API database dictionary by calling ctdbAddTable() function and specifying the table name and path using the appropriate mirror naming convention:

if (ctdbAddTable(hDatabase, "customer|mirror", "primary_path|mirror_path"))

printf("ctdbAddTable failed\n");

If a table is created originally without mirroring, it can subsequently be mirrored as follows:

  1. Copy the original table to the mirror location.
  2. Change the ctdbOpenTable() function to use the mirror naming convention.


ctdbAddTable() returns CTDBRET_OK on success, or the c-tree error code on failure.



eRet = ctdbAddTable(hTable, "custmast1", "customer.dat" "c:\company1");

eRet = ctdbAddTable(hTable, "custmast2", "customer.dat" "c:\company2");

See also

ctdbAddTable(), ctdbCreateTable(), ctdbAllocTable(), ctdbDeleteTable(), ctdbDropTable()