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.62.4" /> 9 <link rel="home" href="index.html" title="Getting Started with Berkeley DB" /> 10 <link rel="up" href="DB.html" title="Chapter 2. Databases" /> 11 <link rel="previous" 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></div> 36 </div> 37 <p> 38 The following are the flags that you may want to use at database open time. 39 Note that this list is not exhaustive — it includes only those flags likely 40 to be of interest for introductory, single-threaded 41 database applications. For a complete list of the flags available to you, see the 42 43 <i class="citetitle">Berkeley DB C++ API guide.</i> 44 </p> 45 <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"> 46 <h3 class="title">Note</h3> 47 <p> 48 To specify more than one flag on the call to 49 50 <span><tt class="methodname">Db::open()</tt>,</span> 51 you must bitwise inclusively OR them together: 52 </p> 53 <a id="c_db3"></a> 54 <pre class="programlisting">u_int32_t open_flags = DB_CREATE | DB_EXCL;</pre> 55 </div> 56 <div class="itemizedlist"> 57 <ul type="disc"> 58 <li> 59 <p> 60 <tt class="literal">DB_CREATE</tt> 61 </p> 62 <p> 63 If the database does not currently exist, create it. By default, the database open 64 fails if the database does not already exist. 65 </p> 66 </li> 67 <li> 68 <p> 69 <tt class="literal">DB_EXCL</tt> 70 </p> 71 <p> 72 Exclusive database creation. Causes the database open to fail if the database 73 already exists. This flag is only meaningful when used with 74 <tt class="literal">DB_CREATE</tt>. 75 </p> 76 </li> 77 <li> 78 <p> 79 <tt class="literal">DB_RDONLY</tt> 80 </p> 81 <p> 82 Open the database for read operations only. Causes any subsequent database write 83 operations to fail. 84 </p> 85 </li> 86 <li> 87 <p> 88 <tt class="literal">DB_TRUNCATE</tt> 89 </p> 90 <p> 91 Physically truncate (empty) the on-disk file that contains the database. 92 Causes DB to delete all databases physically contained in that file. 93 </p> 94 </li> 95 </ul> 96 </div> 97 </div> 98 <div class="navfooter"> 99 <hr /> 100 <table width="100%" summary="Navigation footer"> 101 <tr> 102 <td width="40%" align="left"><a accesskey="p" href="coredbclose.html">Prev</a> </td> 103 <td width="20%" align="center"> 104 <a accesskey="u" href="DB.html">Up</a> 105 </td> 106 <td width="40%" align="right"> <a accesskey="n" href="CoreDBAdmin.html">Next</a></td> 107 </tr> 108 <tr> 109 <td width="40%" align="left" valign="top">Closing Databases </td> 110 <td width="20%" align="center"> 111 <a accesskey="h" href="index.html">Home</a> 112 </td> 113 <td width="40%" align="right" valign="top"> Administrative Methods</td> 114 </tr> 115 </table> 116 </div> 117 </body> 118</html> 119