1<!--$Id: db_class.so,v 10.53 2007/10/26 14:52:37 bostic Exp $--> 2<!--Copyright (c) 1997,2008 Oracle. All rights reserved.--> 3<!--See the file LICENSE for redistribution information.--> 4<html> 5<head> 6<title>Berkeley DB: db_create</title> 7<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit."> 8<meta name="keywords" content="embedded,database,programmatic,toolkit,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++"> 9</head> 10<body bgcolor=white> 11<table width="100%"><tr valign=top> 12<td> 13<b>db_create</b> 14</td> 15<td align=right> 16<a href="../api_c/api_core.html"><img src="../images/api.gif" alt="API"></a> 17<a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a></td> 18</tr></table> 19<hr size=1 noshade> 20<tt> 21<b><pre> 22#include <db.h> 23<p> 24typedef struct __db DB; 25<p> 26int 27db_create(DB **dbp, DB_ENV *dbenv, u_int32_t flags); 28</pre></b> 29<hr size=1 noshade> 30<b>Description: db_create</b> 31<p>The DB handle is the handle for a Berkeley DB database, which may or 32may not be part of a database environment.</p> 33<p>DB handles are free-threaded if the <a href="../api_c/env_open.html#DB_THREAD">DB_THREAD</a> flag is 34specified to the <a href="../api_c/db_open.html">DB->open</a> method when the database is opened or if the 35database environment in which the database is opened is free-threaded. 36The handle should not be closed while any other handle that refers to 37the database is in use; for example, database handles must not be closed 38while cursor handles into the database remain open, or transactions that 39include operations on the database have not yet been committed or 40aborted. Once the <a href="../api_c/db_close.html">DB->close</a>, <a href="../api_c/db_remove.html">DB->remove</a>, 41<a href="../api_c/db_rename.html">DB->rename</a>, or <a href="../api_c/db_verify.html">DB->verify</a> methods are called, the handle may 42not be accessed again, regardless of the method's return.</p> 43<p>The db_create function creates a DB structure that is 44the handle for a Berkeley DB database. This function allocates memory for the 45structure, returning a pointer to the structure in the memory to which 46<b>dbp</b> refers. To release the allocated memory and discard the 47handle, call the <a href="../api_c/db_close.html">DB->close</a>, <a href="../api_c/db_remove.html">DB->remove</a>, 48<a href="../api_c/db_rename.html">DB->rename</a>, or <a href="../api_c/db_verify.html">DB->verify</a> methods.</p> 49<p>The DB handle contains a special field, "app_private", which is 50declared as type "void *". This field is provided for the use of the 51application program. It is initialized to NULL and is not further used 52by Berkeley DB in any way.</p> 53<p>The db_create method 54returns a non-zero error value on failure 55and 0 on success. 56</p> 57<b>Parameters</b> <br> 58 <b>dbp</b><ul compact><li>The <b>dbp</b> parameter references the memory into which the returned 59structure pointer is stored.</ul> 60 <b>dbenv</b><ul compact><li>If the <b>dbenv</b> parameter is NULL, the database is standalone; that 61is, it is not part of any Berkeley DB environment. 62<p>If the <b>dbenv</b> parameter is not NULL, the database is created 63within the specified Berkeley DB environment. The database access methods 64automatically make calls to the other subsystems in Berkeley DB, based on the 65enclosing environment. For example, if the environment has been 66configured to use locking, the access methods will automatically acquire 67the correct locks when reading and writing pages of the database.</p></ul> 68 <b>flags</b><ul compact><li>The <b>flags</b> parameter must be set to 0 or 69the following value: 70<br> 71<b><a name="DB_XA_CREATE">DB_XA_CREATE</a></b><ul compact><li>Instead of creating a standalone database, create a database intended 72to be accessed via applications running under an X/Open conformant 73Transaction Manager. The database will be opened in the environment 74specified by the OPENINFO parameter of the GROUPS section of the 75ubbconfig file. See the <a href="../ref/xa/xa_intro.html">XA 76Introduction</a> section in the Berkeley DB Reference Guide for more information.</ul> 77<br></ul> 78<br> 79<br><b>Errors</b> 80<p>The db_create method 81may fail and return one of the following non-zero errors:</p> 82<br> 83<b>EINVAL</b><ul compact><li>An 84invalid flag value or parameter was specified.</ul> 85<br> 86<hr size=1 noshade> 87<br><b>Class</b> 88DB 89<br><b>See Also</b> 90<a href="../api_c/db_list.html">Databases and Related Methods</a> 91</tt> 92<table width="100%"><tr><td><br></td><td align=right> 93<a href="../api_c/api_core.html"><img src="../images/api.gif" alt="API"></a><a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a> 94</td></tr></table> 95<p><font size=1>Copyright (c) 1996,2008 Oracle. All rights reserved.</font> 96</body> 97</html> 98