File: db.html

package info (click to toggle)
db5.3 5.3.28%2Bdfsg1-0.5
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 158,360 kB
  • sloc: ansic: 448,411; java: 111,824; tcl: 80,544; sh: 44,326; cs: 33,697; cpp: 21,604; perl: 14,557; xml: 10,799; makefile: 4,077; yacc: 1,003; awk: 965; sql: 801; erlang: 342; python: 216; php: 24; asm: 14
file content (523 lines) | stat: -rw-r--r-- 24,793 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Chapter 2.  The Db Handle</title>
    <link rel="stylesheet" href="apiReference.css" type="text/css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" />
    <link rel="start" href="index.html" title="Berkeley DB C++ API Reference" />
    <link rel="up" href="index.html" title="Berkeley DB C++ API Reference" />
    <link rel="prev" href="introduction.html" title="Chapter 1. Introduction to Berkeley DB APIs" />
    <link rel="next" href="dbassociate.html" title="Db::associate()" />
  </head>
  <body>
    <div xmlns="" class="navheader">
      <div class="libver">
        <p>Library Version 11.2.5.3</p>
      </div>
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">Chapter 2. 
                The Db Handle
        </th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="introduction.html">Prev</a> </td>
          <th width="60%" align="center"> </th>
          <td width="20%" align="right"> <a accesskey="n" href="dbassociate.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="chapter" lang="en" xml:lang="en">
      <div class="titlepage">
        <div>
          <div>
            <h2 class="title"><a id="db"></a>Chapter 2. 
                The Db Handle
        </h2>
          </div>
        </div>
      </div>
      <p>
                The Db is the handle for a single Berkeley DB database. A Berkeley DB database
                provides a mechanism for organizing key-data pairs of information. From the
                perspective of some database systems, a Berkeley DB database could be thought of as
                a single table within a larger database.
        </p>
      <p>
                You create a Db handle using the <a class="xref" href="dbcreate.html" title="Db">Db</a>
                
                <span>constructor.</span> 
                For most database activities, you must then open the handle using the 
                <a class="xref" href="dbopen.html" title="Db::open()">Db::open()</a>
                method. When you are done with them, handles must be closed using the
                <a class="xref" href="dbclose.html" title="Db::close()">Db::close()</a> method.
        </p>
      <p>
            Alternatively, you can create a Db and then rename, remove or verify the database
            without performing an open. See <a class="xref" href="dbrename.html" title="Db::rename()">Db::rename()</a>,
            <a class="xref" href="dbremove.html" title="Db::remove()">Db::remove()</a> or 
            <a class="xref" href="dbverify.html" title="Db::verify()">Db::verify()</a> for information on these
            activities.
        </p>
      <p>
            It is possible to create databases such that they are organized within a
            <span class="emphasis"><em>database environment</em></span>. Environments are optional for simple Berkeley
            DB applications that do not use transactions, recovery, replication or any other
            advanced features. For simple Berkeley DB applications, environments still offer some
            advantages. For example, they provide some organizational
            benefits on-disk (all databases are located on disk relative to the environment). Also,
            if you are using multiple databases, then environments allow your databases to share a
            common in-memory cache, which makes for more efficient usage of your hardware's
            resources. 
        </p>
      <p>
            See <a class="link" href="env.html" title="Chapter 5.  The DbEnv Handle">DbEnv</a> for information on using database
            environments.
        </p>
      <p>
            You specify the underlying organization of the data in the database (e.g. BTree, Hash,
            Queue, and Recno) when you open the database. When you create a database,
            you are free to specify any of the available database types. On subsequent opens,
            you must either specify the access method used when you first opened the database, or
            you can specify <code class="literal">DB_UNKNOWN</code> in order to have this information
            retrieved for you. See the <a class="xref" href="dbopen.html" title="Db::open()">Db::open()</a>
            method for information on specifying database types.
        </p>
      <div class="sect1" lang="en" xml:lang="en">
        <div class="titlepage">
          <div>
            <div>
              <h2 class="title" style="clear: both"><a id="dblist"></a>Database and Related Methods</h2>
            </div>
          </div>
        </div>
        <div class="navtable">
          <table border="1" width="80%">
            <thead>
              <tr>
                <th>Database Operations</th>
                <th>Description</th>
              </tr>
            </thead>
            <tbody>
              <tr>
                <td>
                  <a class="xref" href="dbassociate.html" title="Db::associate()">Db::associate()</a>
                </td>
                <td>Associate a secondary index</td>
              </tr>
              <tr>
                <td>
                  <a class="xref" href="dbassociate_foreign.html" title="Db::associate_foreign()">Db::associate_foreign()</a>
                </td>
                <td>Associate a foreign index</td>
              </tr>
              <tr>
                <td>
                  <a class="xref" href="dbclose.html" title="Db::close()">Db::close()</a>
                </td>
                <td>Close a database</td>
              </tr>
              <tr>
                <td>
                  <a class="xref" href="dbcompact.html" title="Db::compact()">Db::compact()</a>
                </td>
                <td>Compact a database</td>
              </tr>
              <tr>
                <td>
                  <a class="xref" href="dbcreate.html" title="Db">Db</a>
                </td>
                <td>Create a database handle</td>
              </tr>
              <tr>
                <td>
                  <a class="xref" href="dbdel.html" title="Db::del()">Db::del()</a>
                </td>
                <td>Delete items from a database</td>
              </tr>
              <tr>
                <td>
                  <a class="xref" href="dberr.html" title="Db::err()">Db::err()</a>
                </td>
                <td>Error message</td>
              </tr>
              <tr>
                <td>
                  <a class="xref" href="dbexists.html" title="Db::exists()">Db::exists()</a>
                </td>
                <td>Return if an item appears in a database</td>
              </tr>
              <tr>
                <td>
                  <a class="xref" href="dbfd.html" title="Db::fd()">Db::fd()</a>
                </td>
                <td>Return a file descriptor from a database</td>
              </tr>
              <tr>
                <td>
                  <a class="xref" href="dbget.html" title="Db::get()">Db::get()</a>
                </td>
                <td>Get items from a database</td>
              </tr>
              <tr>
                <td>
                  <a class="xref" href="dbget_byteswapped.html" title="Db::get_byteswapped()">Db::get_byteswapped()</a>
                </td>
                <td>Return if the underlying database is in host order</td>
              </tr>
              <tr>
                <td>
                  <a class="xref" href="dbget_dbname.html" title="Db::get_dbname()">Db::get_dbname()</a>
                </td>
                <td>Return the file and database name</td>
              </tr>
              <tr>
                <td>
                  <a class="xref" href="dbget_multiple.html" title="Db::get_multiple()">Db::get_multiple()</a>
                </td>
                <td>Return if the database handle references multiple databases</td>
              </tr>
              <tr>
                <td>
                  <a class="xref" href="dbget_open_flags.html" title="Db::get_open_flags()">Db::get_open_flags()</a>
                </td>
                <td>Returns the flags specified to Db::open</td>
              </tr>
              <tr>
                <td>
                  <a class="xref" href="dbget_type.html" title="Db::get_type()">Db::get_type()</a>
                </td>
                <td>Return the database type</td>
              </tr>
              <tr>
                <td>
                  <a class="xref" href="dbjoin.html" title="Db::join()">Db::join()</a>
                </td>
                <td>Perform a database join on cursors</td>
              </tr>
              <tr>
                <td>
                  <a class="xref" href="dbkey_range.html" title="Db::key_range()">Db::key_range()</a>
                </td>
                <td>Return estimate of key location</td>
              </tr>
              <tr>
                <td>
                  <a class="xref" href="dbopen.html" title="Db::open()">Db::open()</a>
                </td>
                <td>Open a database</td>
              </tr>
              <tr>
                <td>
                  <a class="xref" href="dbput.html" title="Db::put()">Db::put()</a>
                </td>
                <td>Store items into a database</td>
              </tr>
              <tr>
                <td>
                  <a class="xref" href="dbremove.html" title="Db::remove()">Db::remove()</a>
                </td>
                <td>Remove a database</td>
              </tr>
              <tr>
                <td>
                  <a class="xref" href="dbrename.html" title="Db::rename()">Db::rename()</a>
                </td>
                <td>Rename a database</td>
              </tr>
              <tr>
                <td><a class="xref" href="dbset_priority.html" title="Db::set_priority()">Db::set_priority()</a>, <a class="xref" href="dbget_priority.html" title="Db::get_priority()">Db::get_priority()</a></td>
                <td>Set/get cache page priority</td>
              </tr>
              <tr>
                <td>
                  <a class="xref" href="dbstat.html" title="Db::stat()">Db::stat()</a>
                </td>
                <td>Database statistics</td>
              </tr>
              <tr>
                <td>
                  <a class="xref" href="dbstat_print.html" title="Db::stat_print()">Db::stat_print()</a>
                </td>
                <td>Display database statistics</td>
              </tr>
              <tr>
                <td>
                  <a class="xref" href="dbsync.html" title="Db::sync()">Db::sync()</a>
                </td>
                <td>Flush a database to stable storage</td>
              </tr>
              <tr>
                <td>
                  <a class="xref" href="dbtruncate.html" title="Db::truncate()">Db::truncate()</a>
                </td>
                <td>Empty a database</td>
              </tr>
              <tr>
                <td>
                  <a class="xref" href="dbupgrade.html" title="Db::upgrade()">Db::upgrade()</a>
                </td>
                <td>Upgrade a database</td>
              </tr>
              <tr>
                <td>
                  <a class="xref" href="dbverify.html" title="Db::verify()">Db::verify()</a>
                </td>
                <td>Verify/salvage a database</td>
              </tr>
              <tr>
                <td>
                  <a class="xref" href="dbcursor.html" title="Db::cursor()">Db::cursor()</a>
                </td>
                <td>Create a cursor handle</td>
              </tr>
              <tr>
                <td colspan="2">
                  <span class="bold">
                    <strong>Database Configuration</strong>
                  </span>
                </td>
              </tr>
              <tr>
                <td>
                  <a class="xref" href="dbset_alloc.html" title="Db::set_alloc()">Db::set_alloc()</a>
                </td>
                <td>Set local space allocation functions</td>
              </tr>
              <tr>
                <td><a class="xref" href="dbset_cachesize.html" title="Db::set_cachesize()">Db::set_cachesize()</a>, <a class="xref" href="dbget_cachesize.html" title="Db::get_cachesize()">Db::get_cachesize()</a></td>
                <td>Set/get the database cache size</td>
              </tr>
              <tr>
                <td><a class="xref" href="dbset_create_dir.html" title="Db::set_create_dir()">Db::set_create_dir()</a>, <a class="xref" href="dbget_create_dir.html" title="Db::get_create_dir()">Db::get_create_dir()</a></td>
                <td>Set/get the directory in which a database is placed</td>
              </tr>
              <tr>
                <td>
                  <a class="xref" href="dbset_dup_compare.html" title="Db::set_dup_compare()">Db::set_dup_compare()</a>
                </td>
                <td>Set a duplicate comparison function</td>
              </tr>
              <tr>
                <td><a class="xref" href="dbset_encrypt.html" title="Db::set_encrypt()">Db::set_encrypt()</a>, <a class="xref" href="dbget_encrypt_flags.html" title="Db::get_encrypt_flags()">Db::get_encrypt_flags()</a></td>
                <td>Set/get the database cryptographic key</td>
              </tr>
              <tr>
                <td>
                  <a class="xref" href="dbset_errcall.html" title="Db::set_errcall()">Db::set_errcall()</a>
                </td>
                <td>Set error message callback</td>
              </tr>
              <tr>
                <td><a class="xref" href="dbset_errfile.html" title="Db::set_errfile()">Db::set_errfile()</a>, <a class="xref" href="dbget_errfile.html" title="Db::get_errfile()">Db::get_errfile()</a></td>
                <td>Set/get error message FILE</td>
              </tr>
              <tr>
                <td>
                  <a class="xref" href="dbset_error_stream.html" title="Db::set_error_stream()">Db::set_error_stream()</a>
                </td>
                <td>Set C++ ostream used for error messages</td>
              </tr>
              <tr>
                <td><a class="xref" href="dbset_errpfx.html" title="Db::set_errpfx()">Db::set_errpfx()</a>, <a class="xref" href="dbget_errpfx.html" title="Db::get_errpfx()">Db::get_errpfx()</a></td>
                <td>Set/get error message prefix</td>
              </tr>
              <tr>
                <td>
                  <a class="xref" href="dbset_feedback.html" title="Db::set_feedback()">Db::set_feedback()</a>
                </td>
                <td>Set feedback callback</td>
              </tr>
              <tr>
                <td><a class="xref" href="dbset_flags.html" title="Db::set_flags()">Db::set_flags()</a>, <a class="xref" href="dbget_flags.html" title="Db::get_flags()">Db::get_flags()</a></td>
                <td>Set/get general database configuration</td>
              </tr>
              <tr>
                <td><a class="xref" href="dbset_lk_exclusive.html" title="Db::set_lk_exclusive()">Db::set_lk_exclusive()</a>, <a class="xref" href="dbget_lk_exclusive.html" title="Db::get_lk_exclusive()">Db::get_lk_exclusive()</a></td>
                <td>Set/get exclusive database locking</td>
              </tr>
              <tr>
                <td><a class="xref" href="dbset_lorder.html" title="Db::set_lorder()">Db::set_lorder()</a>, <a class="xref" href="dbget_lorder.html" title="Db::get_lorder()">Db::get_lorder()</a></td>
                <td>Set/get the database byte order</td>
              </tr>
              <tr>
                <td>
                  <a class="xref" href="dbset_message_stream.html" title="Db::set_message_stream()">Db::set_message_stream()</a>
                </td>
                <td>Set C++ ostream used for informational messages</td>
              </tr>
              <tr>
                <td>
                  <a class="xref" href="dbset_msgcall.html" title="Db::set_msgcall()">Db::set_msgcall()</a>
                </td>
                <td>Set informational message callback</td>
              </tr>
              <tr>
                <td><a class="xref" href="dbset_msgfile.html" title="Db::set_msgfile()">Db::set_msgfile()</a>, <a class="xref" href="dbget_msgfile.html" title="Db::get_msgfile()">Db::get_msgfile()</a></td>
                <td>Set/get informational message FILE</td>
              </tr>
              <tr>
                <td><a class="xref" href="dbset_pagesize.html" title="Db::set_pagesize()">Db::set_pagesize()</a>, <a class="xref" href="dbget_pagesize.html" title="Db::get_pagesize()">Db::get_pagesize()</a></td>
                <td>Set/get the underlying database page size</td>
              </tr>
              <tr>
                <td>
                  <a class="xref" href="dbset_partition.html" title="Db::set_partition()">Db::set_partition()</a>
                </td>
                <td>Set database partitioning</td>
              </tr>
              <tr>
                <td><a class="xref" href="dbset_partition_dirs.html" title="Db::set_partition_dirs()">Db::set_partition_dirs()</a>, <a class="xref" href="dbget_partition_dirs.html" title="Db::get_partition_dirs()">Db::get_partition_dirs()</a></td>
                <td>Set/get the directories used for database partitions</td>
              </tr>
              <tr>
                <td colspan="2">
                  <span class="bold">
                    <strong>Btree/Recno Configuration</strong>
                  </span>
                </td>
              </tr>
              <tr>
                <td>
                  <a class="xref" href="dbset_append_recno.html" title="Db::set_append_recno()">Db::set_append_recno()</a>
                </td>
                <td>Set record append callback</td>
              </tr>
              <tr>
                <td>
                  <a class="xref" href="dbset_bt_compare.html" title="Db::set_bt_compare()">Db::set_bt_compare()</a>
                </td>
                <td>Set a Btree comparison function</td>
              </tr>
              <tr>
                <td>
                  <a class="xref" href="dbset_bt_compress.html" title="Db::set_bt_compress()">Db::set_bt_compress()</a>
                </td>
                <td>Set Btree compression functions</td>
              </tr>
              <tr>
                <td><a class="xref" href="dbset_bt_minkey.html" title="Db::set_bt_minkey()">Db::set_bt_minkey()</a>, <a class="xref" href="dbget_bt_minkey.html" title="Db::get_bt_minkey()">Db::get_bt_minkey()</a></td>
                <td>Set/get the minimum number of keys per Btree page</td>
              </tr>
              <tr>
                <td>
                  <a class="xref" href="dbset_bt_prefix.html" title="Db::set_bt_prefix()">Db::set_bt_prefix()</a>
                </td>
                <td>Set a Btree prefix comparison function</td>
              </tr>
              <tr>
                <td><a class="xref" href="dbset_re_delim.html" title="Db::set_re_delim()">Db::set_re_delim()</a>, <a class="xref" href="dbget_re_delim.html" title="Db::get_re_delim()">Db::get_re_delim()</a></td>
                <td>Set/get the variable-length record delimiter</td>
              </tr>
              <tr>
                <td><a class="xref" href="dbset_re_len.html" title="Db::set_re_len()">Db::set_re_len()</a>, <a class="xref" href="dbget_re_len.html" title="Db::get_re_len()">Db::get_re_len()</a></td>
                <td>Set/get the fixed-length record length</td>
              </tr>
              <tr>
                <td><a class="xref" href="dbset_re_pad.html" title="Db::set_re_pad()">Db::set_re_pad()</a>, <a class="xref" href="dbget_re_pad.html" title="Db::get_re_pad()">Db::get_re_pad()</a></td>
                <td>Set/get the fixed-length record pad byte</td>
              </tr>
              <tr>
                <td><a class="xref" href="dbset_re_source.html" title="Db::set_re_source()">Db::set_re_source()</a>, <a class="xref" href="dbget_re_source.html" title="Db::get_re_source()">Db::get_re_source()</a></td>
                <td>Set/get the backing Recno text file</td>
              </tr>
              <tr>
                <td colspan="2">
                  <span class="bold">
                    <strong>Hash Configuration</strong>
                  </span>
                </td>
              </tr>
              <tr>
                <td>
                  <a class="xref" href="dbset_h_compare.html" title="Db::set_h_compare()">Db::set_h_compare()</a>
                </td>
                <td>Set a Hash comparison function</td>
              </tr>
              <tr>
                <td><a class="xref" href="dbset_h_ffactor.html" title="Db::set_h_ffactor()">Db::set_h_ffactor()</a>, <a class="xref" href="dbget_h_ffactor.html" title="Db::get_h_ffactor()">Db::get_h_ffactor()</a></td>
                <td>Set/get the Hash table density</td>
              </tr>
              <tr>
                <td>
                  <a class="xref" href="dbset_h_hash.html" title="Db::set_h_hash()">Db::set_h_hash()</a>
                </td>
                <td>Set a hashing function</td>
              </tr>
              <tr>
                <td><a class="xref" href="dbset_h_nelem.html" title="Db::set_h_nelem()">Db::set_h_nelem()</a>, <a class="xref" href="dbget_h_nelem.html" title="Db::get_h_nelem()">Db::get_h_nelem()</a></td>
                <td>Set/get the Hash table size</td>
              </tr>
              <tr>
                <td colspan="2">
                  <span class="bold">
                    <strong>Queue Configuration</strong>
                  </span>
                </td>
              </tr>
              <tr>
                <td><a class="xref" href="dbset_q_extentsize.html" title="Db::set_q_extentsize()">Db::set_q_extentsize()</a>, <a class="xref" href="dbget_q_extentsize.html" title="Db::get_q_extentsize()">Db::get_q_extentsize()</a></td>
                <td>Set/get Queue database extent size</td>
              </tr>
              <tr>
                <td colspan="2">
                  <span class="bold">
                    <strong>Heap</strong>
                  </span>
                </td>
              </tr>
              <tr>
                <td><a class="xref" href="dbset_heapsize.html" title="Db::set_heapsize()">Db::set_heapsize()</a>, <a class="xref" href="dbget_heapsize.html" title="Db::get_heapsize()">Db::get_heapsize()</a></td>
                <td>Set/get the database heap size</td>
              </tr>
              <tr>
                <td><a class="xref" href="dbset_heap_regionsize.html" title="Db::set_heap_regionsize()">Db::set_heap_regionsize()</a>, <a class="xref" href="dbget_heap_regionsize.html" title="Db::get_heap_regionsize()">Db::get_heap_regionsize()</a></td>
                <td>Set/get the database region size</td>
              </tr>
              <tr>
                <td>
                  <a class="xref" href="db_heap_rid.html" title="DbHeapRecordId">DbHeapRecordId</a>
                </td>
                <td></td>
              </tr>
              <tr>
                <td colspan="2">
                  <span class="bold">
                    <strong>Database Utilities</strong>
                  </span>
                </td>
              </tr>
              <tr>
                <td>
                  <a class="xref" href="db_copy.html" title="db_copy">db_copy</a>
                </td>
                <td>Copy a named database to a target directory</td>
              </tr>
            </tbody>
          </table>
        </div>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="introduction.html">Prev</a> </td>
          <td width="20%" align="center"> </td>
          <td width="40%" align="right"> <a accesskey="n" href="dbassociate.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">Chapter 1. Introduction to Berkeley DB APIs </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> Db::associate()</td>
        </tr>
      </table>
    </div>
  </body>
</html>