| 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>Chapter 3. Access Method Operations</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="Berkeley DB Programmer's Reference Guide" /> |
| 10 | <link rel="up" href="index.html" title="Berkeley DB Programmer's Reference Guide" /> |
| 11 | <link rel="prev" href="rq_conf.html" title="Queue and Recno access method specific configuration" /> |
| 12 | <link rel="next" href="am_opensub.html" title="Opening multiple databases in a single file" /> |
| 13 | </head> |
| 14 | <body> |
| 15 | <div xmlns="" class="navheader"> |
| 16 | <div class="libver"> |
| 17 | <p>Library Version 11.2.5.3</p> |
| 18 | </div> |
| 19 | <table width="100%" summary="Navigation header"> |
| 20 | <tr> |
| 21 | <th colspan="3" align="center">Chapter 3. |
| 22 | Access Method Operations |
| 23 | </th> |
| 24 | </tr> |
| 25 | <tr> |
| 26 | <td width="20%" align="left"><a accesskey="p" href="rq_conf.html">Prev</a> </td> |
| 27 | <th width="60%" align="center"> </th> |
| 28 | <td width="20%" align="right"> <a accesskey="n" href="am_opensub.html">Next</a></td> |
| 29 | </tr> |
| 30 | </table> |
| 31 | <hr /> |
| 32 | </div> |
| 33 | <div class="chapter" lang="en" xml:lang="en"> |
| 34 | <div class="titlepage"> |
| 35 | <div> |
| 36 | <div> |
| 37 | <h2 class="title"><a id="am"></a>Chapter 3. |
| 38 | Access Method Operations |
| 39 | </h2> |
| 40 | </div> |
| 41 | </div> |
| 42 | </div> |
| 43 | <div class="toc"> |
| 44 | <p> |
| 45 | <b>Table of Contents</b> |
| 46 | </p> |
| 47 | <dl> |
| 48 | <dt> |
| 49 | <span class="sect1"> |
| 50 | <a href="am.html#am_open">Database open</a> |
| 51 | </span> |
| 52 | </dt> |
| 53 | <dt> |
| 54 | <span class="sect1"> |
| 55 | <a href="am_opensub.html">Opening multiple databases in a single file</a> |
| 56 | </span> |
| 57 | </dt> |
| 58 | <dd> |
| 59 | <dl> |
| 60 | <dt> |
| 61 | <span class="sect2"> |
| 62 | <a href="am_opensub.html#idp50943544">Configuring databases sharing a file</a> |
| 63 | </span> |
| 64 | </dt> |
| 65 | <dt> |
| 66 | <span class="sect2"> |
| 67 | <a href="am_opensub.html#idp50944288">Caching databases sharing a file</a> |
| 68 | </span> |
| 69 | </dt> |
| 70 | <dt> |
| 71 | <span class="sect2"> |
| 72 | <a href="am_opensub.html#idp50944984">Locking in databases based on sharing a file</a> |
| 73 | </span> |
| 74 | </dt> |
| 75 | </dl> |
| 76 | </dd> |
| 77 | <dt> |
| 78 | <span class="sect1"> |
| 79 | <a href="am_partition.html">Partitioning databases</a> |
| 80 | </span> |
| 81 | </dt> |
| 82 | <dd> |
| 83 | <dl> |
| 84 | <dt> |
| 85 | <span class="sect2"> |
| 86 | <a href="am_partition.html#am_partition_keys">Specifying partition keys</a> |
| 87 | </span> |
| 88 | </dt> |
| 89 | <dt> |
| 90 | <span class="sect2"> |
| 91 | <a href="am_partition.html#am_partition_function">Partitioning callback</a> |
| 92 | </span> |
| 93 | </dt> |
| 94 | <dt> |
| 95 | <span class="sect2"> |
| 96 | <a href="am_partition.html#partition_file_placement">Placing partition files</a> |
| 97 | </span> |
| 98 | </dt> |
| 99 | </dl> |
| 100 | </dd> |
| 101 | <dt> |
| 102 | <span class="sect1"> |
| 103 | <a href="am_get.html">Retrieving records</a> |
| 104 | </span> |
| 105 | </dt> |
| 106 | <dt> |
| 107 | <span class="sect1"> |
| 108 | <a href="am_put.html">Storing records</a> |
| 109 | </span> |
| 110 | </dt> |
| 111 | <dt> |
| 112 | <span class="sect1"> |
| 113 | <a href="am_delete.html">Deleting records</a> |
| 114 | </span> |
| 115 | </dt> |
| 116 | <dt> |
| 117 | <span class="sect1"> |
| 118 | <a href="am_stat.html">Database statistics</a> |
| 119 | </span> |
| 120 | </dt> |
| 121 | <dt> |
| 122 | <span class="sect1"> |
| 123 | <a href="am_truncate.html">Database truncation</a> |
| 124 | </span> |
| 125 | </dt> |
| 126 | <dt> |
| 127 | <span class="sect1"> |
| 128 | <a href="am_upgrade.html">Database upgrade</a> |
| 129 | </span> |
| 130 | </dt> |
| 131 | <dt> |
| 132 | <span class="sect1"> |
| 133 | <a href="am_verify.html">Database verification and salvage</a> |
| 134 | </span> |
| 135 | </dt> |
| 136 | <dt> |
| 137 | <span class="sect1"> |
| 138 | <a href="am_sync.html">Flushing the database cache</a> |
| 139 | </span> |
| 140 | </dt> |
| 141 | <dt> |
| 142 | <span class="sect1"> |
| 143 | <a href="am_close.html">Database close</a> |
| 144 | </span> |
| 145 | </dt> |
| 146 | <dt> |
| 147 | <span class="sect1"> |
| 148 | <a href="am_second.html">Secondary indexes</a> |
| 149 | </span> |
| 150 | </dt> |
| 151 | <dd> |
| 152 | <dl> |
| 153 | <dt> |
| 154 | <span class="sect2"> |
| 155 | <a href="am_second.html#idp51040080">Error Handling With Secondary Indexes</a> |
| 156 | </span> |
| 157 | </dt> |
| 158 | </dl> |
| 159 | </dd> |
| 160 | <dt> |
| 161 | <span class="sect1"> |
| 162 | <a href="am_foreign.html">Foreign key indexes</a> |
| 163 | </span> |
| 164 | </dt> |
| 165 | <dt> |
| 166 | <span class="sect1"> |
| 167 | <a href="am_cursor.html">Cursor operations</a> |
| 168 | </span> |
| 169 | </dt> |
| 170 | <dd> |
| 171 | <dl> |
| 172 | <dt> |
| 173 | <span class="sect2"> |
| 174 | <a href="am_cursor.html#am_curget">Retrieving records with a cursor</a> |
| 175 | </span> |
| 176 | </dt> |
| 177 | <dt> |
| 178 | <span class="sect2"> |
| 179 | <a href="am_cursor.html#am_curput">Storing records with a cursor</a> |
| 180 | </span> |
| 181 | </dt> |
| 182 | <dt> |
| 183 | <span class="sect2"> |
| 184 | <a href="am_cursor.html#am_curdel">Deleting records with a cursor</a> |
| 185 | </span> |
| 186 | </dt> |
| 187 | <dt> |
| 188 | <span class="sect2"> |
| 189 | <a href="am_cursor.html#am_curdup">Duplicating a cursor</a> |
| 190 | </span> |
| 191 | </dt> |
| 192 | <dt> |
| 193 | <span class="sect2"> |
| 194 | <a href="am_cursor.html#am_join">Equality Join</a> |
| 195 | </span> |
| 196 | </dt> |
| 197 | <dt> |
| 198 | <span class="sect2"> |
| 199 | <a href="am_cursor.html#am_count">Data item count</a> |
| 200 | </span> |
| 201 | </dt> |
| 202 | <dt> |
| 203 | <span class="sect2"> |
| 204 | <a href="am_cursor.html#am_curclose">Cursor close</a> |
| 205 | </span> |
| 206 | </dt> |
| 207 | </dl> |
| 208 | </dd> |
| 209 | </dl> |
| 210 | </div> |
| 211 | <p>Once a database handle has been created using <a href="../api_reference/C/dbcreate.html" class="olink">db_create()</a>, there |
| 212 | are several standard access method operations. Each of these operations |
| 213 | is performed using a method referred to by the returned handle. |
| 214 | Generally, the database will be opened using <a href="../api_reference/C/dbopen.html" class="olink">DB->open()</a>. If the |
| 215 | database is from an old release of Berkeley DB, it may need to be upgraded to |
| 216 | the current release before it is opened using <a href="../api_reference/C/dbupgrade.html" class="olink">DB->upgrade()</a>.</p> |
| 217 | <p>Once a database has been opened, records may be retrieved (<a href="../api_reference/C/dbget.html" class="olink">DB->get()</a>), |
| 218 | stored (<a href="../api_reference/C/dbput.html" class="olink">DB->put()</a>), and deleted (<a href="../api_reference/C/dbdel.html" class="olink">DB->del()</a>).</p> |
| 219 | <p>Additional operations supported by the database handle include |
| 220 | statistics (<a href="../api_reference/C/dbstat.html" class="olink">DB->stat()</a>), truncation (<a href="../api_reference/C/dbtruncate.html" class="olink">DB->truncate()</a>), |
| 221 | version upgrade (<a href="../api_reference/C/dbupgrade.html" class="olink">DB->upgrade()</a>), verification and salvage |
| 222 | (<a href="../api_reference/C/dbverify.html" class="olink">DB->verify()</a>), flushing to a backing file (<a href="../api_reference/C/dbsync.html" class="olink">DB->sync()</a>), |
| 223 | and association of secondary indices (<a href="../api_reference/C/dbassociate.html" class="olink">DB->associate()</a>). Database |
| 224 | handles are eventually closed using <a href="../api_reference/C/dbclose.html" class="olink">DB->close()</a>.</p> |
| 225 | <p>For more information on the access method operations supported by the database handle, see the <a href="../api_reference/C/db.html#dblist" class="olink">Database and Related Methods</a> section in the <em class="citetitle">Berkeley DB C API Reference Guide.</em> </p> |
| 226 | <div class="sect1" lang="en" xml:lang="en"> |
| 227 | <div class="titlepage"> |
| 228 | <div> |
| 229 | <div> |
| 230 | <h2 class="title" style="clear: both"><a id="am_open"></a>Database open</h2> |
| 231 | </div> |
| 232 | </div> |
| 233 | </div> |
| 234 | <p> |
| 235 | The <a href="../api_reference/C/dbopen.html" class="olink">DB->open()</a> method opens a database, and takes five arguments: |
| 236 | </p> |
| 237 | <div class="variablelist"> |
| 238 | <dl> |
| 239 | <dt> |
| 240 | <span class="term">file</span> |
| 241 | </dt> |
| 242 | <dd> |
| 243 | The name of the file to be opened. |
| 244 | </dd> |
| 245 | <dt> |
| 246 | <span class="term">database</span> |
| 247 | </dt> |
| 248 | <dd> |
| 249 | An optional database name. |
| 250 | </dd> |
| 251 | <dt> |
| 252 | <span class="term">type</span> |
| 253 | </dt> |
| 254 | <dd> |
| 255 | The type of database to open. This value will be one of |
| 256 | the five access methods Berkeley DB supports: DB_BTREE, |
| 257 | DB_HASH, DB_HEAP, DB_QUEUE or DB_RECNO, or the special |
| 258 | value DB_UNKNOWN, which allows you to open an existing file |
| 259 | without knowing its type. |
| 260 | </dd> |
| 261 | <dt> |
| 262 | <span class="term">mode</span> |
| 263 | </dt> |
| 264 | <dd> |
| 265 | The permissions to give to any created file. |
| 266 | </dd> |
| 267 | </dl> |
| 268 | </div> |
| 269 | <p> |
| 270 | There are a few flags that you can set to customize open: |
| 271 | </p> |
| 272 | <div class="variablelist"> |
| 273 | <dl> |
| 274 | <dt> |
| 275 | <span class="term"> |
| 276 | <a href="../api_reference/C/dbopen.html#open_DB_CREATE" class="olink">DB_CREATE</a> |
| 277 | </span> |
| 278 | </dt> |
| 279 | <dd> |
| 280 | Create the underlying database and any necessary physical files. |
| 281 | </dd> |
| 282 | <dt> |
| 283 | <span class="term"> |
| 284 | <a href="../api_reference/C/dbopen.html#open_DB_NOMMAP" class="olink">DB_NOMMAP</a> |
| 285 | </span> |
| 286 | </dt> |
| 287 | <dd> |
| 288 | Do not map this database into process memory. |
| 289 | </dd> |
| 290 | <dt> |
| 291 | <span class="term"> |
| 292 | <a href="../api_reference/C/dbopen.html#dbopen_DB_RDONLY" class="olink">DB_RDONLY</a> |
| 293 | </span> |
| 294 | </dt> |
| 295 | <dd> |
| 296 | Treat the data base as read-only. |
| 297 | </dd> |
| 298 | <dt> |
| 299 | <span class="term"> |
| 300 | <a href="../api_reference/C/dbopen.html#open_DB_THREAD" class="olink">DB_THREAD</a> |
| 301 | </span> |
| 302 | </dt> |
| 303 | <dd> |
| 304 | The returned handle is free-threaded, that is, it can be |
| 305 | used simultaneously by multiple threads within the process. |
| 306 | </dd> |
| 307 | <dt> |
| 308 | <span class="term"> |
| 309 | <a href="../api_reference/C/dbopen.html#open_DB_TRUNCATE" class="olink">DB_TRUNCATE</a> |
| 310 | </span> |
| 311 | </dt> |
| 312 | <dd> |
| 313 | Physically truncate the underlying database file, |
| 314 | discarding all databases it contained. Underlying |
| 315 | filesystem primitives are used to implement this flag. For |
| 316 | this reason it is only applicable to the physical file and |
| 317 | cannot be used to discard individual databases from within |
| 318 | physical files. |
| 319 | </dd> |
| 320 | <dt> |
| 321 | <span class="term"> |
| 322 | <a href="../api_reference/C/dbset_feedback.html#set_feedback_DB_UPGRADE" class="olink">DB_UPGRADE</a> |
| 323 | </span> |
| 324 | </dt> |
| 325 | <dd> |
| 326 | Upgrade the database format as necessary. |
| 327 | </dd> |
| 328 | </dl> |
| 329 | </div> |
| 330 | </div> |
| 331 | </div> |
| 332 | <div class="navfooter"> |
| 333 | <hr /> |
| 334 | <table width="100%" summary="Navigation footer"> |
| 335 | <tr> |
| 336 | <td width="40%" align="left"><a accesskey="p" href="rq_conf.html">Prev</a> </td> |
| 337 | <td width="20%" align="center"> </td> |
| 338 | <td width="40%" align="right"> <a accesskey="n" href="am_opensub.html">Next</a></td> |
| 339 | </tr> |
| 340 | <tr> |
| 341 | <td width="40%" align="left" valign="top">Queue and Recno access method specific configuration </td> |
| 342 | <td width="20%" align="center"> |
| 343 | <a accesskey="h" href="index.html">Home</a> |
| 344 | </td> |
| 345 | <td width="40%" align="right" valign="top"> Opening multiple databases in a single file</td> |
| 346 | </tr> |
| 347 | </table> |
| 348 | </div> |
| 349 | </body> |
| 350 | </html> |