Product Documentation

c-treeDB API API for C

Previous Topic

Next Topic


Create a new database.


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


ctdbCreateDatabase() creates a new database. This causes a database dictionary file (which maintains information about the tables in the database) to be created on disk, in the specified Path. If Path is left empty, the dictionary will be created by default in the Server directory (client/server applications) or in the execution directory (standalone applications). (Note that the LOCAL_DIRECTORY item in the server config file controls where in the server directory the file will appear.) The new database dictionary file will be named with the database name and the extension .FDD (FairCom Database Dictionary).

To create a Session, use ctdbCreateSession().

To create a table, use ctdbCreateTable(). The unique database identifier, UID, is associated with the database at the time of its creation. Generally, the UID is associated with the database when the database is added to the session dictionary using ctdbAddDatabase(), but since ctdbCreateDatabase() automatically adds the new database to the session dictionary, the UID is associated with the database at this time.

To create a database, first initiate a session with ctdbAllocSession() and then logon to the c-tree Server or c-tree instance using ctdbLogon(). Once created, the database is automatically added to the session specified by Handle.

  • Handle [in] the session handle.
  • Name [in] the database name.
  • Path [in] the database path.


ctdbCreateDatabase() returns CTDBRET_OK on success, or c-treeDB API error code on failure.


CTHANDLE hDatabase;

hDatabase = ctdbAllocDatabase(hSession);

eRet = ctdbCreateDatabase(hSession, database_name, database_path);

eRet = ctdbConnect(hDatabase, database_name);

See also

ctdbAllocDatabase(), ctdbAddDatabase(), ctdbCreateSession(), ctdbCreateTable(), ctdbLogon()