File: db_load.html

package info (click to toggle)
db 2%3A2.4.14-2.7.7.1.c
  • links: PTS
  • area: main
  • in suites: potato
  • size: 12,716 kB
  • ctags: 9,382
  • sloc: ansic: 35,556; tcl: 8,564; cpp: 4,890; sh: 2,075; makefile: 1,723; java: 1,632; sed: 419; awk: 153; asm: 41
file content (159 lines) | stat: -rw-r--r-- 7,137 bytes parent folder | download | duplicates (6)
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
<! "@(#)db_load.so	10.10 (Sleepycat) 9/29/98">
<!Copyright 1997, 1998 by Sleepycat Software, Inc.  All rights reserved.>
<html>
<body bgcolor=white>
<head>
<title>Berkeley DB: db_load</title>
<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit.">
<meta name="keywords" content="embedded,database,programmatic,toolkit,b+tree,btr
ee,hash,hashing,transaction,transactions,locking,logging,access method,access me
thods,java,C,C++">
</head>
<h1>db_load</h1>
<hr size=1 noshade>
<tt>
<h3>
<pre>
db_load [<b>-nT</b>] [<b>-c name=value</b>]
    [<b>-f file</b>] [<b>-h home</b>] [<b>-t btree | hash | recno</b>] db_file
</pre>
</h3>
<h1>Description</h1>
<p>
The db_load utility reads from the standard input and loads it into
the database <b>db_file</b>.
The database <b>db_file</b> is created if it does not already exist.
<p>
The input to db_load must be in the output format specified by the
<a href="../utility/db_dump.html">db_dump</a> utility, utilities, or as specified for the <b>-T</b>
below.
<p>
The options are as follows:
<dl compact>
<p><dt><b>-c</b><dd>Specify configuration options for the DB_INFO structure provided to
<a href="../api_c/Db/open.html">db_open</a> ignoring any value they may have based on the input.
The command-line format is <b>name=value</b>.
See <a href="db_load.html#keywords">Supported Keywords</a> for a list of
supported words for the <b>-c</b> option.
<p><dt><b>-f</b><dd>Read from
the specified <b>input</b> file instead of from the standard input.
<p><dt><b>-h</b><dd>Specify a home directory for the database.
<p>
If a home directory is specified, the database environment is opened
using the DB_INIT_LOCK, DB_INIT_LOG, DB_INIT_MPOOL, DB_INIT_TXN and
DB_USE_ENVIRON flags to <a href="../api_c/DbEnv/appinit.html">db_appinit</a>.
(This means that db_load can be used to load data into databases
while they are in use by other processes.)
If the <a href="../api_c/DbEnv/appinit.html">db_appinit</a> call fails, or if no home directory is specified,
the database is still updated, but the environment is ignored, e.g., no
locking is done.
<p><dt><b>-n</b><dd>Do not overwrite existing keys in the database when loading into an
already existing database.
If a key/data pair cannot be loaded into the database for this reason,
a warning message is displayed on the standard error output and the
key/data pair are skipped.
<p><dt><b>-T</b><dd>The <b>-T</b>
option allows non-Berkeley DB applications to easily load text files into databases.
<p>
If the database to be created is of type btree or hash, the input must be
paired lines of text, where the first line of the pair is the key item,
and the second line of the pair is its corresponding data item.
If the database to be created is of type recno, the input must be lines of
text, where each line is a new data item for the database.
<p>
A simple escape mechanism, where newline and backslash (\)
characters are special, is applied to the text input.
Newline characters are interpreted as record separators.
Backslash characters in the text will be interpreted in one of two ways:
if the backslash character precedes another backslash character, the pair
will be interpreted as a literal backslash.
If the backslash character precedes any other character, the two characters
following the backslash will be interpreted as hexadecimal specification of
a single character, e.g., \0a is a newline character in the ASCII
character set.
<p>
For this reason, any backslash or newline characters that naturally
occur in the text input must be escaped to avoid misinterpretation by
db_load.
<p>
If the <b>-T</b> option is specified, the underlying access method type
must be specified using the <b>-t</b> option.
<p><dt><b>-t</b><dd>Specify the underlying access method.
If no <b>-t</b> option is specified, the database will be loaded into a
database of the same type as was dumped, e.g., a hash database will be
created if a hash database was dumped.
<p>
Btree and hash databases may be converted from one to the other.
Recno databases may not be converted to any other database type
or from any other database type.
</dl>
<p>
The <a href="../utility/db_archive.html">db_archive</a> utility attaches to one or more of the Berkeley DB shared memory
regions.  In order to avoid region corruption, it should always be given
the chance to detach and exit gracefully.  To cause <a href="../utility/db_archive.html">db_archive</a> to clean up
after itself and exit, send it an interrupt signal (SIGINT).
<p>
The db_load utility exits 0 on success,
1 if one or more
key/data pairs were not loaded into the database because the key already
existed, and >1 if an error occurs.
<p>
<h1>Examples</h1>
The db_load utility can be used to load text files into databases.
For example, the following command loads the standard UNIX
<i>/etc/passwd</i> file into a database, with the login name as
the key item and the entire password entry as the data item:
<p><ul><pre>
awk -F: '{print $1; print $0}' < /etc/passwd |
    sed 's/\\/\\\\/g' | db_load -T -t hash passwd.db</pre></ul><p>
<p>
Note that backslash characters naturally occurring in the text are escaped
to avoid interpretation as escape characters by db_load.
<p>
<h1>Environment Variables</h1>
<p>
<dl compact>
<p><dt>DB_HOME<dd>
If the <b>-h</b> option is not specified and the environment variable
DB_HOME is set, it is used as the path of the database home, as described
in <a href="../api_c/DbEnv/appinit.html">db_appinit</a>.
</dl>
<p>
<a name="keywords">
<h1>Supported Keywords</h1>
The following keywords are supported for the <b>-c</b> command-line option
to the db_load utility.
See <a href="../api_c/Db/open.html">db_open</a> for further discussion of these keywords and what values
should be specified.
<p>
The parenthetical listing specifies how the value part of the
<b>name=value</b> pair is interpreted.
Items listed as (boolean) expect value to be <b>1</b> (set) or <b>0</b>
(unset).
Items listed as (number) convert value to a number.
Items listed as (string) use the characters of value directly.
<dl compact>
<dt>bt_minkey (number)<dd>The minimum number of keys per page.
<dt>db_lorder (number)<dd>The byte order for integers in the stored database metadata.
<dt>db_pagesize (number)<dd>The size of pages used for nodes in the tree, in bytes.
<dt>duplicates (boolean)<dd>The value of the DB_DUP flag.
<dt>h_ffactor (number)<dd>The density within the hash table.
<dt>h_nelem (number)<dd>The size of the hash table.
<dt>re_len (number)<dd>Specify fixed-length records of the specified length.
<dt>re_pad (string)<dd>Specify the fixed-length record pad character.
<dt>recnum (boolean)<dd>The value of the DB_RECNUM flag.
<dt>renumber (boolean)<dd>The value of the DB_RENUMBER flag.
</dl>
<p>
<h1>See Also</h1>
<a href="../utility/db_archive.html">db_archive</a>,
<a href="../utility/db_checkpoint.html">db_checkpoint</a>,
<a href="../utility/db_deadlock.html">db_deadlock</a>,
<a href="../utility/db_dump.html">db_dump</a>,
db_load,
<a href="../utility/db_recover.html">db_recover</a>,
and
<a href="../utility/db_stat.html">db_stat</a>.
</tt>
</body>
</html>