Debian Codegraph @

docs/api_reference/C/db_load.html

raw symbols SCIP
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_load</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="utilities.html" title="Appendix A.  Berkeley DB Command Line Utilities" />
11 <link rel="prev" href="db_hotbackup.html" title="db_hotbackup" />
12 <link rel="next" href="db_log_verify.html" title="db_log_verify" />
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">db_load</th>
22 </tr>
23 <tr>
24 <td width="20%" align="left"><a accesskey="p" href="db_hotbackup.html">Prev</a> </td>
25 <th width="60%" align="center">Appendix A. 
26 Berkeley DB Command Line Utilities
27 </th>
28 <td width="20%" align="right"> <a accesskey="n" href="db_log_verify.html">Next</a></td>
29 </tr>
30 </table>
31 <hr />
32 </div>
33 <div class="sect1" lang="en" xml:lang="en">
34 <div class="titlepage">
35 <div>
36 <div>
37 <h2 class="title" style="clear: both"><a id="db_load"></a>db_load</h2>
38 </div>
39 </div>
40 </div>
41 <pre class="programlisting">db_load [-nTV] [-b blob_dir] [-c name=value] [-f file]
42 [-h home] [-P password] [-o blob_threshold]
43 [-t btree | hash | queue | recno] file
44
45 db_load [-r lsn | fileid] [-h home] [-P password] file </pre>
46 <p>
47 The <span class="command"><strong>db_load</strong></span> utility reads from the standard input and loads it into
48 the database <span class="bold"><strong>file</strong></span>. The database
49 <span class="bold"><strong>file</strong></span> is created if it does not
50 already exist.
51 </p>
52 <p>
53 The input to <span class="command"><strong>db_load</strong></span> must be in the output format specified by the
54 <a class="xref" href="db_dump.html" title="db_dump">db_dump</a> utility
55 or as specified by the <span class="bold"><strong>-T</strong></span>
56 option below.
57 </p>
58 <p>
59 The options are as follows:
60 </p>
61 <div class="itemizedlist">
62 <ul type="disc">
63 <li>
64 <p>
65 <span class="bold"><strong>-b</strong></span>
66 </p>
67 <p>
68 Identifies the directory where BLOB data is stored. If
69 this option is not specified, then BLOB data is placed in a
70 subdirectory within the DB's environment. See also the
71 <span class="bold"><strong>-o</strong></span> option.
72 </p>
73 </li>
74 <li>
75 <p>
76 <span class="bold"><strong>-c</strong></span>
77 </p>
78 <p>
79 Specify configuration options ignoring any value they may have based
80 on the input. The command-line format is <span class="bold"><strong>name=value</strong></span>. See the Supported Keywords section
81 below for a list of keywords supported by the <span class="bold"><strong>-c</strong></span> option.
82 </p>
83 </li>
84 <li>
85 <p>
86 <span class="bold"><strong>-f</strong></span>
87 </p>
88 <p>
89 Read from the specified <span class="bold"><strong>input</strong></span> file
90 instead of from the standard input.
91 </p>
92 </li>
93 <li>
94 <p>
95 <span class="bold"><strong>-h</strong></span>
96 </p>
97 <p>
98 Specify a home directory for the database environment.
99 </p>
100 <p>
101 If a home directory is specified, the database environment is opened
102 using the
103 <a class="link" href="envopen.html#envopen_DB_INIT_LOCK">DB_INIT_LOCK</a>,
104 <a class="link" href="envopen.html#envopen_DB_INIT_LOG">DB_INIT_LOG</a>,
105 <a class="link" href="envopen.html#envopen_DB_INIT_MPOOL">DB_INIT_MPOOL</a>,
106 <a class="link" href="envopen.html#envopen_DB_INIT_TXN">DB_INIT_TXN</a>, and
107 <a class="link" href="envopen.html#envopen_DB_USE_ENVIRON">DB_USE_ENVIRON</a>
108 flags to <a class="xref" href="envopen.html" title="DB_ENV-&gt;open()">DB_ENV-&gt;open()</a>
109 (This means that <span class="command"><strong>db_load</strong></span> can be used to load data into databases while
110 they are in use by other processes.) If the
111 <a class="xref" href="envopen.html" title="DB_ENV-&gt;open()">DB_ENV-&gt;open()</a> call fails, or if
112 no home directory is specified, the database is still updated, but the
113 environment is ignored; for example, no locking is done.
114 </p>
115 </li>
116 <li>
117 <p>
118 <span class="bold"><strong>-n</strong></span>
119 </p>
120 <p>
121 Do not overwrite existing keys in the database when loading into an
122 already existing database. If a key/data pair cannot be loaded into
123 the database for this reason, a warning message is displayed on the
124 standard error output, and the key/data pair are skipped.
125 </p>
126 </li>
127 <li>
128 <p>
129 <span class="bold"><strong>-o</strong></span>
130 </p>
131 <p>
132 Identifies the BLOB threshold in bytes. This threshold determines
133 when a data item will be stored as a BLOB. Data items sized
134 less than this threshold are stored as normal data within
135 the database. Data items larger than this size are stored
136 on-disk in a subdirectory set aside for the purpose.
137 Use the <span class="bold"><strong>-b</strong></span> command line
138 option to identify where BLOB data is stored.
139 </p>
140 </li>
141 <li>
142 <p>
143 <span class="bold"><strong>-P</strong></span>
144 </p>
145 <p>
146 Specify an environment password. Although Berkeley DB utilities
147 overwrite password strings as soon as possible, be aware there may be
148 a window of vulnerability on systems where unprivileged users can see
149 command-line arguments or where utilities are not able to overwrite
150 the memory containing the command-line arguments.
151 </p>
152 </li>
153 <li>
154 <p>
155 <span class="bold"><strong>-r</strong></span>
156 </p>
157 <p>
158 Reset the database's file ID or log sequence numbers (LSNs).
159 </p>
160 <p>
161 All database pages in transactional environments contain references to
162 the environment's log records. In order to copy a database into a
163 different database environment, database page references to the old
164 environment's log records must be reset, otherwise data corruption can
165 occur when the database is modified in the new environment. The
166 <span class="bold"><strong>-r</strong></span> <span class="bold"><strong>lsn</strong></span> option resets a database's log sequence
167 numbers.
168 </p>
169 <p>
170 All databases contain an ID string used to identify the database in
171 the database environment cache. If a database is copied, and used in
172 the same environment as another file with the same ID string,
173 corruption can occur. The <span class="bold"><strong>-r</strong></span>
174 <span class="bold"><strong>fileid</strong></span> option resets a database's
175 file ID to a new value.
176 </p>
177 <p>
178 <span class="bold"><strong>In both cases, the physical file specified by
179 the <span class="bold"><strong>file</strong></span> argument is modified
180 in-place.</strong></span>
181 </p>
182 </li>
183 <li>
184 <p>
185 <span class="bold"><strong>-T</strong></span>
186 </p>
187 <p>
188 The <span class="bold"><strong>-T</strong></span> option allows non-Berkeley DB
189 applications to easily load text files into databases.
190 </p>
191 <p>
192 If the database to be created is of type Btree or Hash, or the keyword
193 <span class="bold"><strong>keys</strong></span> is specified as set, the
194 input must be paired lines of text, where the first line of the pair is the
195 key item, and the second line of the pair is its corresponding data
196 item. If the database to be created is of type Queue or Recno and the
197 keyword <span class="bold"><strong>keys</strong></span> is not set, the input
198 must be lines of text, where each line is a new data item for the
199 database.
200 </p>
201 <p>
202 A simple escape mechanism, where newline and backslash (\) characters
203 are special, is applied to the text input. Newline characters are
204 interpreted as record separators. Backslash characters in the text
205 will be interpreted in one of two ways: If the backslash character
206 precedes another backslash character, the pair will be interpreted as
207 a literal backslash. If the backslash character precedes any other
208 character, the two characters following the backslash will be
209 interpreted as a hexadecimal specification of a single character; for
210 example, \0a is a newline character in the ASCII character set.
211 </p>
212 <p>
213 For this reason, any backslash or newline characters that naturally
214 occur in the text input must be escaped to avoid misinterpretation by
215 <span class="command"><strong>db_load</strong></span>.
216 </p>
217 <p>
218 If the <span class="bold"><strong>-T</strong></span> option is specified, the
219 underlying access method type must be specified using the <span class="bold"><strong>-t</strong></span> option.
220 </p>
221 </li>
222 <li>
223 <p>
224 <span class="bold"><strong>-t</strong></span>
225 </p>
226 <p>
227 Specify the underlying access method. If no <span class="bold"><strong>-t</strong></span> option is specified, the database will be
228 loaded into a database of the same type as was dumped; for example, a
229 Hash database will be created if a Hash database was dumped.
230 </p>
231 <p>
232 Btree and Hash databases may be converted from one to the other.
233 Queue and Recno databases may be converted from one to the other. If
234 the <span class="bold"><strong>-k</strong></span> option was specified on the
235 call to <a class="xref" href="db_dump.html" title="db_dump">db_dump</a> then
236 Queue and Recno databases may be converted to Btree or Hash, with the
237 key being the integer record number.
238 </p>
239 </li>
240 <li>
241 <p>
242 <span class="bold"><strong>-V</strong></span>
243 </p>
244 <p>
245 Write the library version number to the standard output, and exit.
246 </p>
247 </li>
248 </ul>
249 </div>
250 <p>
251 The <span class="command"><strong>db_load</strong></span> utility may be used with a Berkeley DB
252 environment (as described for the <span class="bold"><strong>-h</strong></span>
253 option, the environment variable
254 <span class="bold"><strong>DB_HOME</strong></span>, or because the utility
255 was run in a directory containing a Berkeley DB environment).
256 In order to avoid environment corruption when using a
257 Berkeley DB environment, <span class="command"><strong>db_load</strong></span> should always be given the chance to
258 detach from the environment and exit gracefully. To cause <span class="command"><strong>db_load</strong></span> to
259 release all environment resources and exit cleanly, send it an
260 interrupt signal (SIGINT).
261 </p>
262 <p>
263 The <span class="command"><strong>db_load</strong></span> utility exits 0 on success, 1 if one or more key/data
264 pairs were not loaded into the database because the key already
265 existed, and &gt;1 if an error occurs.
266 </p>
267 <div class="sect2" lang="en" xml:lang="en">
268 <div class="titlepage">
269 <div>
270 <div>
271 <h3 class="title"><a id="idp55152152"></a>Examples</h3>
272 </div>
273 </div>
274 </div>
275 <p>
276 The <span class="command"><strong>db_load</strong></span> utility can be used to load text files into databases. For
277 example, the following command loads the standard UNIX
278 <span class="emphasis"><em>/etc/passwd</em></span> file into a database, with the login
279 name as the key item and the entire password entry as the data item:
280 </p>
281 <pre class="programlisting"> awk -F: '{print $1; print $0}' &lt; /etc/passwd |
282 sed 's/\\/\\\\/g' | db_load -T -t hash passwd.db </pre>
283 <p>
284 Note that backslash characters naturally occurring in the text are
285 escaped to avoid interpretation as escape characters by
286 <span class="command"><strong>db_load</strong></span>.
287 </p>
288 </div>
289 <div class="sect2" lang="en" xml:lang="en">
290 <div class="titlepage">
291 <div>
292 <div>
293 <h3 class="title"><a id="idp55212448"></a>Environment Variables</h3>
294 </div>
295 </div>
296 </div>
297 <div class="sect3" lang="en" xml:lang="en">
298 <div class="titlepage">
299 <div>
300 <div>
301 <h4 class="title"><a id="idp55213992"></a>DB_HOME</h4>
302 </div>
303 </div>
304 </div>
305 <p>
306 If the <span class="bold"><strong>-h</strong></span> option is not specified and
307 the environment variable DB_HOME is set, it is used as the path of the
308 database home, as described in the
309 <a class="xref" href="envopen.html" title="DB_ENV-&gt;open()">DB_ENV-&gt;open()</a> method.
310 </p>
311 </div>
312 </div>
313 <div class="sect2" lang="en" xml:lang="en">
314 <div class="titlepage">
315 <div>
316 <div>
317 <h3 class="title"><a id="idp55192880"></a>Supported Keywords</h3>
318 </div>
319 </div>
320 </div>
321 <p>
322 The following keywords are supported for the <span class="bold"><strong>-c</strong></span> command-line
323 option to the <span class="command"><strong>db_load</strong></span> utility. See the
324 <a class="xref" href="envopen.html" title="DB_ENV-&gt;open()">DB_ENV-&gt;open()</a> method
325 for further discussion of these keywords and what values should be
326 specified.
327 </p>
328 <p>
329 The parenthetical listing specifies how the value part of the <span class="bold"><strong>name=value</strong></span> pair is interpreted. Items listed as (boolean)
330 expect value to be <span class="bold"><strong>1</strong></span> (set) or <span class="bold"><strong>0</strong></span> (unset). Items listed as (number) convert value to a
331 number. Items listed as (string) use the string value without modification.
332 </p>
333 <div class="itemizedlist">
334 <ul type="disc">
335 <li>
336 <p>
337 <span class="bold"><strong>bt_minkey (number)</strong></span>
338 </p>
339 <p>
340 The minimum number of keys per page.
341 </p>
342 </li>
343 <li>
344 <p>
345 <span class="bold"><strong>chksum (boolean)</strong></span>
346 </p>
347 <p>
348 Enable page checksums.
349 </p>
350 </li>
351 <li>
352 <p>
353 <span class="bold"><strong>database (string)</strong></span>
354 </p>
355 <p>
356 The database to load.
357 </p>
358 </li>
359 <li>
360 <p>
361 <span class="bold"><strong>db_lorder (number)</strong></span>
362 </p>
363 <p>
364 The byte order for integers in the stored database metadata.
365 For big endian systems, the order should be 4,321 while
366 for little endian systems is should be 1,234.
367 </p>
368 </li>
369 <li>
370 <p>
371 <span class="bold"><strong>db_pagesize (number)</strong></span>
372 </p>
373 <p>
374 The size of database pages, in bytes.
375 </p>
376 </li>
377 <li>
378 <p>
379 <span class="bold"><strong>duplicates (boolean)</strong></span>
380 </p>
381 <p>
382 The value of the
383 <a class="link" href="dbset_flags.html#dbset_flags_DB_DUP">DB_DUP</a>
384 flag.
385 </p>
386 </li>
387 <li>
388 <p>
389 <span class="bold"><strong>dupsort (boolean)</strong></span>
390 </p>
391 <p>
392 The value of the
393 <a class="link" href="dbset_flags.html#dbset_flags_DB_DUPSORT">DB_DUPSORT</a>
394 flag.
395 </p>
396 </li>
397 <li>
398 <p>
399 <span class="bold"><strong>extentsize (number)</strong></span>
400 </p>
401 <p>
402 The size of database extents, in pages, for Queue databases configured to use
403 extents.
404 </p>
405 </li>
406 <li>
407 <p>
408 <span class="bold"><strong>h_ffactor (number)</strong></span>
409 </p>
410 <p>
411 The density within the Hash database.
412 </p>
413 </li>
414 <li>
415 <p>
416 <span class="bold"><strong>h_nelem (number)</strong></span>
417 </p>
418 <p>
419 The size of the Hash database.
420 </p>
421 </li>
422 <li>
423 <p>
424 <span class="bold"><strong>keys (boolean)</strong></span>
425 </p>
426 <p>
427 Specify whether keys are present for Queue or Recno databases.
428 </p>
429 </li>
430 <li>
431 <p>
432 <span class="bold"><strong>re_len (number)</strong></span>
433 </p>
434 <p>
435 Specify the length for fixed-length records. This
436 number represents different things, depending on the
437 access method the database is using. See the
438 <a class="xref" href="dbset_re_len.html" title="DB-&gt;set_re_len()">DB-&gt;set_re_len()</a>
439 method for details on what this number represents.
440 </p>
441 </li>
442 <li>
443 <p>
444 <span class="bold"><strong>re_pad (string)</strong></span>
445 </p>
446 <p>
447 Specify the fixed-length record pad character.
448 </p>
449 </li>
450 <li>
451 <p>
452 <span class="bold"><strong>recnum (boolean)</strong></span>
453 </p>
454 <p>
455 The value of the
456 <a class="link" href="dbset_flags.html#dbset_flags_DB_RECNUM">DB_RECNUM</a>
457 flag.
458 </p>
459 </li>
460 <li>
461 <p>
462 <span class="bold"><strong>renumber (boolean)</strong></span>
463 </p>
464 <p>
465 The value of the
466 <a class="link" href="dbset_flags.html#dbset_flags_DB_RECNUM">DB_RENUMBER</a>
467 flag.
468 </p>
469 </li>
470 <li>
471 <p>
472 <span class="bold"><strong>subdatabase (string)</strong></span>
473 </p>
474 <p>
475 The subdatabase to load.
476 </p>
477 </li>
478 </ul>
479 </div>
480 </div>
481 </div>
482 <div class="navfooter">
483 <hr />
484 <table width="100%" summary="Navigation footer">
485 <tr>
486 <td width="40%" align="left"><a accesskey="p" href="db_hotbackup.html">Prev</a> </td>
487 <td width="20%" align="center">
488 <a accesskey="u" href="utilities.html">Up</a>
489 </td>
490 <td width="40%" align="right"> <a accesskey="n" href="db_log_verify.html">Next</a></td>
491 </tr>
492 <tr>
493 <td width="40%" align="left" valign="top">db_hotbackup </td>
494 <td width="20%" align="center">
495 <a accesskey="h" href="index.html">Home</a>
496 </td>
497 <td width="40%" align="right" valign="top"> db_log_verify</td>
498 </tr>
499 </table>
500 </div>
501 </body>
502 </html>