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>Administrative Methods</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="DBOpenFlags.html" title="Database Open Flags" /> 12 <link rel="next" href="dbErrorReporting.html" title="Error Reporting Functions" /> 13 </head> 14 <body> 15 <div class="navheader"> 16 <table width="100%" summary="Navigation header"> 17 <tr> 18 <th colspan="3" align="center">Administrative Methods</th> 19 </tr> 20 <tr> 21 <td width="20%" align="left"><a accesskey="p" href="DBOpenFlags.html">Prev</a> </td> 22 <th width="60%" align="center">Chapter 2. Databases</th> 23 <td width="20%" align="right"> <a accesskey="n" href="dbErrorReporting.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="CoreDBAdmin"></a>Administrative Methods</h2> 33 </div> 34 </div> 35 </div> 36 <p> 37 The following 38 <code class="classname">DB</code> 39 40 41 42 methods may be useful to you when managing DB databases: 43 </p> 44 <div class="itemizedlist"> 45 <ul type="disc"> 46 <li> 47 <p> 48 <code class="methodname">DB->get_open_flags()</code> 49 50 </p> 51 <p> 52 Returns the current open flags. It is an error to use this method on 53 an unopened database. 54 </p> 55 <a id="c_db5"></a> 56 <pre class="programlisting">#include <db.h> 57... 58DB *dbp; 59u_int32_t open_flags; 60 61/* Database open and subsequent operations omitted for clarity */ 62 63dbp->get_open_flags(dbp, &open_flags); </pre> 64 </li> 65 <li> 66 <p> 67 <code class="methodname">DB->remove()</code> 68 69 </p> 70 <p> 71 Removes the specified database. If no value is given for the 72 <em class="parameter"><code>database</code></em> parameter, then the entire file 73 referenced by this method is removed. 74 </p> 75 <p> 76 Never remove a database that has handles opened for it. Never remove a file that 77 contains databases with opened handles. 78 </p> 79 <a id="c_db6"></a> 80 <pre class="programlisting">#include <db.h> 81... 82DB *dbp; 83 84/* Database handle creation omitted for clarity */ 85 86dbp->remove(dbp, /* Database pointer */ 87 "mydb.db", /* Database file to remove */ 88 NULL, /* Database to remove. This is 89 * NULL so the entire file is 90 * removed. */ 91 0); /* Flags. None used. */</pre> 92 </li> 93 <li> 94 <p> 95 <code class="methodname">DB->rename()</code> 96 97 </p> 98 <p> 99 Renames the specified database. If no value is given for the 100 <em class="parameter"><code>database</code></em> parameter, then the entire file 101 referenced by this method is renamed. 102 </p> 103 <p> 104 Never rename a database that has handles opened for it. Never rename a file that 105 contains databases with opened handles. 106 </p> 107 <a id="c_db7"></a> 108 <pre class="programlisting">#include <db.h> 109... 110DB *dbp; 111 112/* Database handle creation omitted for clarity */ 113 114dbp->rename(dbp, /* Database pointer */ 115 "mydb.db", /* Database file to rename */ 116 NULL, /* Database to rename. This is 117 * NULL so the entire file is 118 * renamed. */ 119 "newdb.db", /* New database file name */ 120 0); /* Flags. None used. */</pre> 121 </li> 122 </ul> 123 </div> 124 <span> 125 126 </span> 127 </div> 128 <div class="navfooter"> 129 <hr /> 130 <table width="100%" summary="Navigation footer"> 131 <tr> 132 <td width="40%" align="left"><a accesskey="p" href="DBOpenFlags.html">Prev</a> </td> 133 <td width="20%" align="center"> 134 <a accesskey="u" href="DB.html">Up</a> 135 </td> 136 <td width="40%" align="right"> <a accesskey="n" href="dbErrorReporting.html">Next</a></td> 137 </tr> 138 <tr> 139 <td width="40%" align="left" valign="top">Database Open Flags </td> 140 <td width="20%" align="center"> 141 <a accesskey="h" href="index.html">Home</a> 142 </td> 143 <td width="40%" align="right" valign="top"> Error Reporting Functions</td> 144 </tr> 145 </table> 146 </div> 147 </body> 148</html> 149