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
|
<!--Copyright 1999-2006 by Oracle Corporation.-->
<!--All rights reserved.-->
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="GENERATOR" CONTENT="Mozilla/4.08 [en] (X11; I; FreeBSD 3.3-RELEASE i386) [Netscape]">
</HEAD>
<BODY>
<H2>
<A NAME="Database Commands"></A>Database Commands</H2>
The database commands provide a fairly straightforward mapping to the
DB method functions.
<P>
<B>> berkdb open</B>
<dl>
<dt><B>[-btcompare <I>proc</I>]</B><dd>
Sets the Btree comparison function to the Tcl procedure named
<I>proc</I> using the
<A HREF="../../docs/api_c/db_set_bt_compare.html">DB->set_bt_compare</A>
method.
<dt><B>[-btree|-hash|-recno|-queue|-unknown]</B><dd>
</td><td>
Select the database type:<br>
DB_BTREE, DB_HASH, DB_RECNO, DB_QUEUE or DB_UNKNOWN.
<dt><B>[-cachesize {<I>gbytes bytes ncaches</I>}]</B><dd>
Sets the size of the database cache to the size specified by
<I>gbytes</I> and <I>bytes</I>, broken up into <I>ncaches</I> number of
caches using the
<A HREF="../../docs/api_c/db_set_cachesize.html">DB->set_cachesize</A>
method.
<dt><B>[-create]</B><dd>
Selects the DB_CREATE flag to create underlying files.
<dt><B>[-delim <I>delim</I>]</B><dd>
Sets the delimiting byte for variable length records to <I>delim</I>
using the
<A HREF="../../docs/api_c/db_set_re_delim.html">DB->set_re_delim</A>
method.
<dt><B>[-dup]</B><dd>
Selects the DB_DUP flag to permit duplicates in the database.
<dt><B>[-dupcompare <I>proc</I>]</B><dd>
Sets the duplicate data comparison function to the Tcl procedure named
<I>proc</I> using the
<A HREF="../../docs/api_c/db_set_dup_compare.html">DB->set_dup_compare</A>
method.
<dt><B>[-dupsort]</B><dd>
Selects the DB_DUPSORT flag to support sorted duplicates.
<dt><B>[-env <I>env</I>]</B><dd>
The database environment.
<dt><B>[-errfile <I>filename</I>]</B><dd>
Specifies the error file to use for this environment to <I>filename</I>
by calling
<A HREF="../../docs/api_c/db_set_errfile.html">DB->set_errfile</A>.
If the file already exists then we will append to the end of the file.
<dt><B>[-excl]</B><dd>
Selects the DB_EXCL flag to exclusively create underlying files.
<dt><B>[-extent <I>size</I>]</B><dd>
Sets the size of a Queue database extent to the given <I>size</I> using
the
<A HREF="../../docs/api_c/db_set_q_extentsize.html">DB->set_q_extentsize</A>
method.
<dt><B>[-ffactor <I>density</I>]</B><dd>
Sets the hash table key density to the given <I>density</I> using the
<A HREF="../../docs/api_c/db_set_h_ffactor.html">DB->set_h_ffactor</A>
method.
<dt><B>[-hashproc <I>proc</I>]</B><dd>
Sets a user-defined hash function to the Tcl procedure named <I>proc</I>
using the
<A HREF="../../docs/api_c/db_set_h_hash.html">DB->set_h_hash</A> method.
<dt><B>[-len <I>len</I>]</B><dd>
Sets the length of fixed-length records to <I>len</I> using the
<A HREF="../../docs/api_c/db_set_re_len.html">DB->set_re_len</A>
method.
<dt><B>[-lorder <I>order</I>]</B><dd>
Sets the byte order for integers stored in the database meta-data to
the given <I>order</I> using the
<A HREF="../../docs/api_c/db_set_lorder.html">DB->set_lorder</A>
method.
<dt><B>[-minkey <I>minkey</I>]</B><dd>
Sets the minimum number of keys per Btree page to <I>minkey</I> using
the
<A HREF="../../docs/api_c/db_set_bt_minkey.html">DB->set_bt_minkey</A>
method.
<dt><B>[-mode <I>mode</I>]</B><dd>
Specifies the mode for created files.
<dt><B>[-nelem <I>size</I>]</B><dd>
Sets the hash table size estimate to the given <I>size</I> using the
<A HREF="../../docs/api_c/db_set_h_nelem.html">DB->set_h_nelem</A>
method.
<dt><B>[-nommap]</B><dd>
Selects the DB_NOMMAP flag to forbid mmaping of files.
<dt><B>[-pad <I>pad</I>]</B><dd>
Sets the pad character used for fixed length records to <I>pad</I> using
the
<A HREF="../../docs/db_set_re_pad.html">DB->set_re_pad</A> method.
<dt><B>[-pagesize <I>pagesize</I>]</B><dd>
Sets the size of the database page to <I>pagesize</I> using the
<A HREF="../../docs/api_c/db_set_pagesize.html">DB->set_pagesize</A>
method.
<dt><B>[-rdonly]</B><dd>
Selects the DB_RDONLY flag for opening in read-only mode.
<dt><B>[-recnum]</B><dd>
Selects the DB_RECNUM flag to support record numbers in Btrees.
<dt><B>[-renumber]</B><dd>
Selects the DB_RENUMBER flag to support mutable record numbers.
<dt><B>[-revsplitoff]</B><dd>
Selects the DB_REVSPLITOFF flag to suppress reverse splitting of pages
on deletion.
<dt><B>[-snapshot]</B><dd>
Selects the DB_SNAPSHOT flag to support database snapshots.
<dt><B>[-source <I>file</I>]</B><dd>
Sets the backing source file name to <I>file</I> using the
<A HREF="../../docs/api_c/db_set_re_source.html">DB->set_re_source</A>
method.
<dt><B>[-truncate]</B><dd>
Selects the DB_TRUNCATE flag to truncate the database.
<dt><B>[--]</B><dd>
Terminate the list of options and use remaining arguments as the file
or subdb names (thus allowing the use of filenames beginning with a dash
'-').
<dt><B>[<I>filename </I>[<I>subdbname</I>]]</B><dd>
The names of the database and sub-database.
</dl>
<HR WIDTH="100%">
<B>> berkdb upgrade [-dupsort] [-env <I>env</I>] [--] [<I>filename</I>]</B>
<P>This command will invoke the <A HREF="../../docs/api_c/db_upgrade.html">DB->upgrade</A>
function. If the command is given the <B>-env</B> option, then we
will accordingly upgrade the database filename within the context of that
environment. The <B>-dupsort</B> option selects the DB_DUPSORT flag for
upgrading. The use of --<B> </B>terminates the list of options, thus allowing
filenames beginning with a dash.
<P>
<HR WIDTH="100%">
<B>> berkdb verify [-env <I>env</I>] [--] [<I>filename</I>]</B>
<P>This command will invoke the <A HREF="../../docs/api_c/db_verify.html">DB->verify</A>
function. If the command is given the <B>-env</B> option, then we
will accordingly verify the database filename within the context of that
environment. The use of --<B> </B>terminates the list of options,
thus allowing filenames beginning with a dash.
<P>
<HR WIDTH="100%"><B>> <I>db</I> del</B>
<P>There are no undocumented options.
<HR WIDTH="100%">
<B>> <I>db</I> join [-nosort] <I>db0.c0 db1.c0</I> ...</B>
<P>This command will invoke the <A HREF="../../docs/api_c/db_join.html">db_join</A>
function. After it successfully joins a database, we bind it to a
new Tcl command of the form <B><I>dbN.cX, </I></B>where X is an integer
starting at 0 (e.g. <B>db2.c0, db3.c0, </B>etc). We use the <I>Tcl_CreateObjCommand() </I>
to create the top level database function. It is through this cursor
handle that the user can access the joined data items.
<P>The options are:
<UL>
<LI>
<B>-nosort -</B> This flag causes DB not to sort the cursors based on the
number of data items they reference. It results in the DB_JOIN_NOSORT
flag being set.</LI>
</UL>
<P>
This command will invoke the
<A HREF="../../docs/api_c/db_create.html">db_create</A> function. If
the command is given the <B>-env</B> option, then we will accordingly
creating the database within the context of that environment. After it
successfully gets a handle to a database, we bind it to a new Tcl
command of the form <B><I>dbX, </I></B>where X is an integer starting
at 0 (e.g. <B>db0, db1, </B>etc).
<p>
We use the <I>Tcl_CreateObjCommand()</I> to create the top level
database function. It is through this handle that the user can access
all of the commands described in the <A HREF="#Database Commands">
Database Commands</A> section. Internally, the database handle
is sent as the <I>ClientData</I> portion of the new command set so that
all future database calls access the appropriate handle.
<P>
After parsing all of the optional arguments affecting the setup of the
database and making the appropriate calls to DB to manipulate those
values, we open the database for the user. It translates to the
<A HREF="../../docs/api_c/db_open.html">DB->open</A> method call after
parsing all of the various optional arguments. We automatically set the
DB_THREAD flag. The arguments are:
<HR WIDTH="100%">
<B>> <I>db</I> get_join [-nosort] {db key} {db key} ...</B>
<P>This command performs a join operation on the keys specified and returns
a list of the joined {key data} pairs.
<P>The options are:
<UL>
<LI>
<B>-nosort</B> This flag causes DB not to sort the cursors based on the
number of data items they reference. It results in the DB_JOIN_NOSORT
flag being set.</LI>
</UL>
<HR WIDTH="100%">
<B>> <I>db</I> keyrange [-txn <I>id</I>] key</B>
<P>This command returns the range for the given <B>key</B>. It returns
a list of 3 double elements of the form {<B><I>less equal greater</I></B>}
where <B><I>less</I></B> is the percentage of keys less than the given
key, <B><I>equal</I></B> is the percentage equal to the given key and <B><I>greater</I></B>
is the percentage greater than the given key. If the -txn option
is specified it performs this operation under transaction protection.
<HR WIDTH="100%"><B>> <I>db</I> put</B>
<P>The <B>undocumented</B> options are:
<dl>
<dt><B>-nodupdata</B><dd>
This flag causes DB not to insert the key/data pair if it already
exists, that is, both the key and data items are already in the
database. The -nodupdata flag may only be specified if the underlying
database has been configured to support sorted duplicates.
</dl>
<HR WIDTH="100%"><B>> <I>dbc</I> put</B>
<P>The <B>undocumented</B> options are:
<dl>
<dt><B>-nodupdata</B><dd>
This flag causes DB not to insert the key/data pair if it already
exists, that is, both the key and data items are already in the
database. The -nodupdata flag may only be specified if the underlying
database has been configured to support sorted duplicates.
</dl>
</BODY>
</HTML>
|