1<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml">
4  <head>
5    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6    <title>Database Open Flags</title>
7    <link rel="stylesheet" href="gettingStarted.css" type="text/css" />
8    <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" />
9    <link rel="start" href="index.html" title="Getting Started with Berkeley DB" />
10    <link rel="up" href="DB.html" title="Chapter 2. Databases" />
11    <link rel="prev" href="coredbclose.html" title="Closing Databases" />
12    <link rel="next" href="CoreDBAdmin.html" title="Administrative Methods" />
13  </head>
14  <body>
15    <div class="navheader">
16      <table width="100%" summary="Navigation header">
17        <tr>
18          <th colspan="3" align="center">Database Open Flags</th>
19        </tr>
20        <tr>
21          <td width="20%" align="left"><a accesskey="p" href="coredbclose.html">Prev</a> </td>
22          <th width="60%" align="center">Chapter 2. Databases</th>
23          <td width="20%" align="right"> <a accesskey="n" href="CoreDBAdmin.html">Next</a></td>
24        </tr>
25      </table>
26      <hr />
27    </div>
28    <div class="sect1" lang="en" xml:lang="en">
29      <div class="titlepage">
30        <div>
31          <div>
32            <h2 class="title" style="clear: both"><a id="DBOpenFlags"></a>Database Open Flags</h2>
33          </div>
34        </div>
35      </div>
36      <p>
37		The following are the flags that you may want to use at database open time.  
38		Note that this list is not exhaustive — it includes only those flags likely 
39		to be of interest for introductory, single-threaded
40		database applications. For a complete list of the flags available to you, see the 
41		<em class="citetitle">Berkeley DB C API guide.</em>
42		
43	</p>
44      <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
45        <h3 class="title">Note</h3>
46        <p>
47		To specify more than one flag on the call to 
48		<span><code class="methodname">DB-&gt;open()</code>,</span>
49        
50		you must bitwise inclusively OR them together:
51	</p>
52        <a id="c_db3"></a>
53        <pre class="programlisting">u_int32_t open_flags = DB_CREATE | DB_EXCL;</pre>
54      </div>
55      <div class="itemizedlist">
56        <ul type="disc">
57          <li>
58            <p>
59				<code class="literal">DB_CREATE</code>
60			</p>
61            <p>
62				If the database does not currently exist, create it. By default, the database open 
63				fails if the database does not already exist.
64			</p>
65          </li>
66          <li>
67            <p>
68				<code class="literal">DB_EXCL</code>
69			</p>
70            <p>
71				Exclusive database creation. Causes the database open to fail if the database 
72				already exists.  This flag is only meaningful when used with 
73				<code class="literal">DB_CREATE</code>.
74			</p>
75          </li>
76          <li>
77            <p>
78				<code class="literal">DB_RDONLY</code>
79			</p>
80            <p>
81				Open the database for read operations only. Causes any subsequent database write 
82				operations to fail.
83			</p>
84          </li>
85          <li>
86            <p>
87				<code class="literal">DB_TRUNCATE</code>
88			</p>
89            <p>
90				Physically truncate (empty) the on-disk file that contains the database. 
91				Causes DB to delete all databases physically contained in that file.
92			</p>
93          </li>
94        </ul>
95      </div>
96    </div>
97    <div class="navfooter">
98      <hr />
99      <table width="100%" summary="Navigation footer">
100        <tr>
101          <td width="40%" align="left"><a accesskey="p" href="coredbclose.html">Prev</a> </td>
102          <td width="20%" align="center">
103            <a accesskey="u" href="DB.html">Up</a>
104          </td>
105          <td width="40%" align="right"> <a accesskey="n" href="CoreDBAdmin.html">Next</a></td>
106        </tr>
107        <tr>
108          <td width="40%" align="left" valign="top">Closing Databases </td>
109          <td width="20%" align="center">
110            <a accesskey="h" href="index.html">Home</a>
111          </td>
112          <td width="40%" align="right" valign="top"> Administrative Methods</td>
113        </tr>
114      </table>
115    </div>
116  </body>
117</html>
118