Product Documentation

c-treeDB API API for C

Previous Topic

Next Topic


Add an existing table to a database.


CTDBRET ctdbAddTable(CTHANDLE Handle, pTEXT Name, pTEXT Path)


ctdbAddTable() 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.
  • Name [in] - the name of the table be added, including the file extension, usually .dat.
  • Path [in] - the table path.

A mirrored table can be added to a c-treeDB API database dictionary by calling the 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, "custmast", "");

See also

ctdbAddTableXtd (ctdbAddTableXtd, ctdbAddTableXtd), ctdbCreateTable, ctdbAllocTable, ctdbDeleteTable, ctdbDropTable, ctdbSetDefaultSqlTableOwner