CreateTable creates a new table within the database.
unsigned __int64 CreateTable (
   const CODBPP::Schema *schema,
   unsigned int *tableID = NULL


schemaa valid schema definition for the desired table.
tableIDon successful creation of a table where the schema.tableID was set to zero, the next allocated ID is written to this return value.

Return Values

If the method succeeds, the return value is zero else see error codes for more details.


  • Database must be in exculsive mode before this method is called.
  • CreateTable is atomic and will be undone if method fails.
  • CreateTable checks to see if the given schema is valid, if it is capable of being repaired, it will do it.
  • CreateTable is not part of the transaction so there is no need to call CommitTransaction.
Example Use
  • C++
#include "ODBPP.h"

CODBPP::Segment index1Segments[] = {{0,(CODBPP::Mode)0}};
CODBPP::Index indexes[] = {{0,CODBPP::B_TREE,1,0,index1Segments}
CODBPP::Field fields[] = {
   {CODBPP::UINT32, 0, 4, 0,u"First"},
   {CODBPP::FLOAT64,8, 8, 0,u"Second"},
   {CODBPP::ASTR,   16,32,0,u"Third"}
CODBPP::Schema schema = {0,1,0,0,3,0,u"Table Name",NULL,fields, indexes};

int wmain(int argc, wchar_t* argv[])
   unsigned __int64 error;
   const char16_t *message;
   CODBPP database;
   if(database.OpenDatabase(u"YourDatabase") == NO_ERROR){
      if((error = database.BeginTransaction(CODBPP::EXCLUSIVE)) == NO_ERROR){
         if((error = database.CreateTable(&schema)) == NO_ERROR){
      if(error && database.GetErrorMessage(&message) == NO_ERROR)
   return NO_ERROR;

Also See

AddTable, CloseTable, OpenTable, RemoveTable
Listen All
Comments (0)
Characters left: 2500
Ekky Software Homepage T-Accounts Online ObjectDatabase++ TScript Ekky Software Homepage T-Accounts Onlinee ObjectDatabase++ TScript