Product Documentation

FairCom DB API for C

Previous Topic

Next Topic

ctdbCreateDatabase

Create a new database.

Declaration

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

Description

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.

Returns

ctdbCreateDatabase() returns CTDBRET_OK on success, or FairCom DB API error code on failure.

Example

CTHANDLE hDatabase;

hDatabase = ctdbAllocDatabase(hSession);

eRet = ctdbCreateDatabase(hSession, database_name, database_path);

eRet = ctdbConnect(hDatabase, database_name);

See also

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

TOCIndex