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>DB->remove()</title> 7 <link rel="stylesheet" href="apiReference.css" type="text/css" /> 8 <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /> 9 <link rel="start" href="index.html" title="Berkeley DB C API Reference" /> 10 <link rel="up" href="db.html" title="Chapter 2. The DB Handle" /> 11 <link rel="prev" href="dbput.html" title="DB->put()" /> 12 <link rel="next" href="dbrename.html" title="DB->rename()" /> 13 </head> 14 <body> 15 <div class="navheader"> 16 <table width="100%" summary="Navigation header"> 17 <tr> 18 <th colspan="3" align="center">DB->remove()</th> 19 </tr> 20 <tr> 21 <td width="20%" align="left"><a accesskey="p" href="dbput.html">Prev</a> </td> 22 <th width="60%" align="center">Chapter 2. 23 The DB Handle 24 </th> 25 <td width="20%" align="right"> <a accesskey="n" href="dbrename.html">Next</a></td> 26 </tr> 27 </table> 28 <hr /> 29 </div> 30 <div class="sect1" lang="en" xml:lang="en"> 31 <div class="titlepage"> 32 <div> 33 <div> 34 <h2 class="title" style="clear: both"><a id="dbremove"></a>DB->remove()</h2> 35 </div> 36 </div> 37 </div> 38 <pre class="programlisting">#include <db.h> 39 40int 41DB->remove(DB *db, 42 const char *file, const char *database, u_int32_t flags); </pre> 43 <p> 44 The <code class="methodname">DB->remove()</code> method removes the database specified by the 45 <span class="bold"><strong>file</strong></span> and <span class="bold"><strong>database</strong></span> parameters. If no <span class="bold"><strong>database</strong></span> is specified, the underlying file 46 represented by <span class="bold"><strong>file</strong></span> is removed, 47 incidentally removing all of the databases it contained. 48 </p> 49 <p> 50 Applications should never remove databases with open 51 <a class="link" href="db.html" title="Chapter 2. The DB Handle">DB</a> handles, or in the case of 52 removing a file, when any database in the file has an open handle. 53 For example, some architectures do not permit the removal of files 54 with open system handles. On these architectures, attempts to remove 55 databases currently in use by any thread of control in the system may 56 fail. 57 </p> 58 <p> 59 The <code class="methodname">DB->remove()</code> method should not be called if the remove is 60 intended to be transactionally safe; the 61 <a class="xref" href="envdbremove.html" title="DB_ENV->dbremove()">DB_ENV->dbremove()</a> method 62 should be used instead. 63 </p> 64 <p> 65 The <code class="methodname">DB->remove()</code> method may not be called after calling the 66 <a class="xref" href="dbopen.html" title="DB->open()">DB->open()</a> method on any 67 <a class="link" href="db.html" title="Chapter 2. The DB Handle">DB</a> handle. If the 68 <a class="xref" href="dbopen.html" title="DB->open()">DB->open()</a> method has already 69 been called on a <a class="link" href="db.html" title="Chapter 2. The DB Handle">DB</a> 70 handle, close the existing handle and create a new one before calling 71 <code class="methodname">DB->remove. 72()</code> </p> 73 <p> 74 The <a class="link" href="db.html" title="Chapter 2. The DB Handle">DB</a> handle may not be 75 accessed again after <code class="methodname">DB->remove()</code> is called, regardless of its 76 return. 77 </p> 78 <p> 79 The <code class="methodname">DB->remove()</code> <span> 80 <span> 81 method returns a non-zero error value on failure and 0 on success. 82 </span> 83 84 </span> 85 </p> 86 <div class="sect2" lang="en" xml:lang="en"> 87 <div class="titlepage"> 88 <div> 89 <div> 90 <h3 class="title"><a id="id1641682"></a>Parameters</h3> 91 </div> 92 </div> 93 </div> 94 <div class="sect3" lang="en" xml:lang="en"> 95 <div class="titlepage"> 96 <div> 97 <div> 98 <h4 class="title"><a id="id1641691"></a>database</h4> 99 </div> 100 </div> 101 </div> 102 <p> 103 The <span class="bold"><strong>database</strong></span> parameter is the 104 database to be removed. 105 </p> 106 </div> 107 <div class="sect3" lang="en" xml:lang="en"> 108 <div class="titlepage"> 109 <div> 110 <div> 111 <h4 class="title"><a id="id1641753"></a>file</h4> 112 </div> 113 </div> 114 </div> 115 <p> 116 The <span class="bold"><strong>file</strong></span> parameter is the physical 117 file which contains the database(s) to be removed. 118 </p> 119 </div> 120 </div> 121 <div class="sect2" lang="en" xml:lang="en"> 122 <div class="titlepage"> 123 <div> 124 <div> 125 <h3 class="title"><a id="id1641766"></a>Environment Variables</h3> 126 </div> 127 </div> 128 </div> 129 <p> 130 If the database was opened within a database environment, the 131 environment variable <code class="literal">DB_HOME</code> may be used as the path of the 132 database environment home. 133 </p> 134 <p> 135 <code class="methodname">DB->remove()</code> is affected by any database directory specified using the 136 <a class="xref" href="envset_data_dir.html" title="DB_ENV->set_data_dir()">DB_ENV->set_data_dir()</a> 137 method, or by setting the "set_data_dir" string in the environment's 138 <a href="../../programmer_reference/env_db_config.html#env_db_config.DB_CONFIG" class="olink">DB_CONFIG</a> 139 file. 140 </p> 141 </div> 142 <div class="sect2" lang="en" xml:lang="en"> 143 <div class="titlepage"> 144 <div> 145 <div> 146 <h3 class="title"><a id="id1641563"></a>Errors</h3> 147 </div> 148 </div> 149 </div> 150 <p> 151 The <code class="methodname">DB->remove()</code> <span> 152 <span> 153 method may fail and return one of the following non-zero errors: 154 </span> 155 156 </span> 157 </p> 158 <div class="sect3" lang="en" xml:lang="en"> 159 <div class="titlepage"> 160 <div> 161 <div> 162 <h4 class="title"><a id="id1641733"></a>EINVAL</h4> 163 </div> 164 </div> 165 </div> 166 <p> 167 If the method was called after <a class="xref" href="dbopen.html" title="DB->open()">DB->open()</a> 168 was called; or if an invalid flag value or parameter was specified. 169 </p> 170 </div> 171 <div class="sect3" lang="en" xml:lang="en"> 172 <div class="titlepage"> 173 <div> 174 <div> 175 <h4 class="title"><a id="id1641841"></a>ENOENT</h4> 176 </div> 177 </div> 178 </div> 179 <p> 180 The file or directory does not exist. 181 </p> 182 </div> 183 </div> 184 <div class="sect2" lang="en" xml:lang="en"> 185 <div class="titlepage"> 186 <div> 187 <div> 188 <h3 class="title"><a id="id1641704"></a>Class</h3> 189 </div> 190 </div> 191 </div> 192 <p> 193 <a class="link" href="db.html" title="Chapter 2. The DB Handle">DB</a> 194 </p> 195 </div> 196 <div class="sect2" lang="en" xml:lang="en"> 197 <div class="titlepage"> 198 <div> 199 <div> 200 <h3 class="title"><a id="id1641714"></a>See Also</h3> 201 </div> 202 </div> 203 </div> 204 <p> 205 <a class="xref" href="db.html#dblist" title="Database and Related Methods">Database and Related Methods</a> 206 </p> 207 </div> 208 </div> 209 <div class="navfooter"> 210 <hr /> 211 <table width="100%" summary="Navigation footer"> 212 <tr> 213 <td width="40%" align="left"><a accesskey="p" href="dbput.html">Prev</a> </td> 214 <td width="20%" align="center"> 215 <a accesskey="u" href="db.html">Up</a> 216 </td> 217 <td width="40%" align="right"> <a accesskey="n" href="dbrename.html">Next</a></td> 218 </tr> 219 <tr> 220 <td width="40%" align="left" valign="top">DB->put() </td> 221 <td width="20%" align="center"> 222 <a accesskey="h" href="index.html">Home</a> 223 </td> 224 <td width="40%" align="right" valign="top"> DB->rename()</td> 225 </tr> 226 </table> 227 </div> 228 </body> 229</html> 230