~ubuntu-branches/ubuntu/edgy/rpm/edgy

« back to all changes in this revision

Viewing changes to db/tcl/docs/db.html

  • Committer: Bazaar Package Importer
  • Author(s): Joey Hess
  • Date: 2002-01-22 20:56:57 UTC
  • Revision ID: james.westby@ubuntu.com-20020122205657-l74j50mr9z8ofcl5
Tags: upstream-4.0.3
ImportĀ upstreamĀ versionĀ 4.0.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
 
2
<HTML>
 
3
<HEAD>
 
4
   <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
 
5
   <META NAME="GENERATOR" CONTENT="Mozilla/4.08 [en] (X11; I; FreeBSD 3.3-RELEASE i386) [Netscape]">
 
6
</HEAD>
 
7
<BODY>
 
8
 
 
9
<H2>
 
10
<A NAME="Database Commands"></A>Database Commands</H2>
 
11
The database commands provide a conduit into the DB method functions.&nbsp;
 
12
They are all fairly straightforward and I describe them in terms of their
 
13
DB functions briefly here, with a link to the DB page where appropriate.&nbsp;
 
14
The first set of commands are those I believe will be the primary functions
 
15
used by most databases.&nbsp; Some are directly related to their DB counterparts,
 
16
and some are higher level functions that are useful to provide the user.
 
17
<P><B>> berkdb open [-env <I>env</I>]</B>
 
18
<BR><B>&nbsp;&nbsp;&nbsp; [-btree|-hash|-recno|-queue|-unknown]</B>
 
19
<BR><B>&nbsp;&nbsp;&nbsp; [-create] [-excl] [-nommap] [-rdonly] [-truncate]
 
20
[-mode
 
21
<I>mode</I>] [-errfile <I>filename</I>]</B>
 
22
<BR><B>&nbsp;&nbsp;&nbsp; [-dup] [-dupsort] [-recnum] [-renumber] [-revsplitoff]
 
23
[-snapshot]</B>
 
24
<BR><B>&nbsp;&nbsp;&nbsp; [-btcompare <I>proc</I>] [-dupcompare <I>proc</I>]
 
25
[-hashproc <I>proc</I>]</B>
 
26
<BR><B>&nbsp;&nbsp;&nbsp; [-extent <I>size</I>]</B>
 
27
<BR><B>&nbsp;&nbsp;&nbsp; [-ffactor <I>density</I>]</B>
 
28
<BR><B>&nbsp;&nbsp;&nbsp; [-nelem <I>size</I>]</B>
 
29
<BR><B>&nbsp;&nbsp;&nbsp; [-lorder <I>order</I>]</B>
 
30
<BR><B>&nbsp;&nbsp;&nbsp; [-delim <I>delim</I>]</B>
 
31
<BR><B>&nbsp;&nbsp;&nbsp; [-len <I>len</I>]</B>
 
32
<BR><B>&nbsp;&nbsp;&nbsp; [-pad <I>pad</I>]</B>
 
33
<BR><B>&nbsp;&nbsp;&nbsp; [-source <I>file</I>]</B>
 
34
<BR><B>&nbsp;&nbsp;&nbsp; [-minkey <I>minkey</I>]</B>
 
35
<BR><B>&nbsp;&nbsp;&nbsp; [-cachesize {<I>gbytes bytes ncaches</I>}]</B>
 
36
<BR><B>&nbsp;&nbsp;&nbsp; [-pagesize <I>pagesize</I>]</B>
 
37
<BR><B>&nbsp;&nbsp;&nbsp; [--]</B>
 
38
<BR><B>&nbsp;&nbsp;&nbsp; [<I>filename </I>[<I>subdbname</I>]]</B>
 
39
<P>This command will invoke the <A HREF="../../docs/api_c/db_create.html">db_create</A>
 
40
function.&nbsp; If the command is given the <B>-env</B> option, then we
 
41
will accordingly creating the database within the context of that environment.&nbsp;
 
42
After it successfully gets a handle to a database, we bind it to a new
 
43
Tcl command of the form <B><I>dbX, </I></B>where X is an integer starting
 
44
at 0 (e.g. <B>db0, db1, </B>etc).&nbsp; We use the <I>Tcl_CreateObjCommand()&nbsp;</I>
 
45
to create the top level database function.&nbsp; It is through this handle
 
46
that the user can access all of the commands described in the <A HREF="#Database Commands">Database
 
47
Commands</A> section.&nbsp; Internally, the database handle is sent as
 
48
the <I>ClientData</I> portion of the new command set so that all future
 
49
database calls access the appropriate handle.
 
50
<P>After parsing all of the optional arguments affecting the setup of the
 
51
database and making the appropriate calls to DB to manipulate those values,
 
52
we open the database for the user. It&nbsp; translates to the
 
53
<A HREF="../../docs/api_c/db_open.html">DB->open</A>
 
54
method call after parsing all of the various optional arguments.&nbsp;
 
55
We automatically set the DB_THREAD flag.&nbsp; The arguments are:
 
56
<UL>
 
57
<LI>
 
58
<B>-- </B>- Terminate the list of options and use remaining arguments as
 
59
the file or subdb names (thus allowing the use of filenames beginning with
 
60
a dash '-')</LI>
 
61
 
 
62
<LI>
 
63
<B>-btree</B> - DB_BTREE database</LI>
 
64
 
 
65
<LI>
 
66
<B>-hash</B> -&nbsp; DB_HASH database</LI>
 
67
 
 
68
<LI>
 
69
<B>-recno&nbsp;</B> - DB_RECNO database</LI>
 
70
 
 
71
<LI>
 
72
<B>-queue</B> - DB_QUEUE database</LI>
 
73
 
 
74
<LI>
 
75
<B>-create</B> selects the DB_CREATE flag&nbsp; to create underlying files</LI>
 
76
 
 
77
<LI>
 
78
<B>-excl</B> selects the DB_EXCL flag&nbsp; to exclusively create underlying
 
79
files</LI>
 
80
 
 
81
<LI>
 
82
<B>-nommap</B> selects the DB_NOMMAP flag to forbid mmaping of files</LI>
 
83
 
 
84
<LI>
 
85
<B>-rdonly</B> selects the DB_RDONLY flag for opening in read-only mode</LI>
 
86
 
 
87
<LI>
 
88
<B>-truncate</B> selects the DB_TRUNCATE flag to truncate the database</LI>
 
89
 
 
90
<LI>
 
91
<B>-mode<I> mode</I></B> specifies the mode for created files</LI>
 
92
 
 
93
<LI>
 
94
<B>-errfile </B>specifies the error file to use for this environment to
 
95
<B><I>filename</I></B>
 
96
by calling <A HREF="../../docs/api_c/db_set_errfile.html">DB->set_errfile</A><B><I>.
 
97
</I></B>If
 
98
the file already exists then we will append to the end of the file</LI>
 
99
 
 
100
<LI>
 
101
<B>-dup </B>selects the DB_DUP flag to permit duplicates in the database</LI>
 
102
 
 
103
<LI>
 
104
<B>-dupsort</B> selects the DB_DUPSORT flag to support sorted duplicates</LI>
 
105
 
 
106
<LI>
 
107
<B>-recnum</B> selects the DB_RECNUM flag to support record numbers in
 
108
btrees</LI>
 
109
 
 
110
<LI>
 
111
<B>-renumber </B>selects the DB_RENUMBER flag to support mutable record
 
112
numbers</LI>
 
113
 
 
114
<LI>
 
115
<B>-revsplitoff </B>selects the DB_REVSPLITOFF flag to suppress reverse
 
116
splitting of pages on deletion</LI>
 
117
 
 
118
<LI>
 
119
<B>-snapshot </B>selects the DB_SNAPSHOT flag to support database snapshots</LI>
 
120
 
 
121
<LI>
 
122
<B>-btcompare</B> sets the Btree comparison function to the Tcl procedure
 
123
named <B><I>proc</I></B> using the <A HREF="../../docs/api_c/db_set_bt_compare.html">DB->set_bt_compare</A>
 
124
method.</LI>
 
125
 
 
126
<LI>
 
127
<B>-dupcompare</B> sets the duplicate data comparison function to the Tcl
 
128
procedure named <B><I>proc</I></B> using the <A HREF="../../docs/api_c/db_set_dup_compare.html">DB->set_dup_compare</A>
 
129
method.</LI>
 
130
 
 
131
<LI>
 
132
<B>-hashproc</B> sets a user-defined hash function to the Tcl procedure
 
133
named <B><I>proc</I></B> using the <A HREF="../../docs/api_c/db_set_h_hash.html">DB->set_h_hash</A>
 
134
method.</LI>
 
135
 
 
136
<LI>
 
137
<B>-extent </B>sets the size of a Queue database extent to the given <B><I>size
 
138
</I></B>using
 
139
the <A HREF="../../docs/api_c/db_set_q_extentsize.html">DB->set_q_extentsize</A>
 
140
method</LI>
 
141
 
 
142
<LI>
 
143
<B>-ffactor</B> sets the hash table key density to the given <B><I>density
 
144
</I></B>using
 
145
the <A HREF="../../docs/api_c/db_set_h_ffactor.html">DB->set_h_ffactor</A>
 
146
method</LI>
 
147
 
 
148
<LI>
 
149
<B>-nelem </B>sets the hash table size estimate to the given <B><I>size
 
150
</I></B>using
 
151
the <A HREF="../../docs/api_c/db_set_h_nelem.html">DB->set_h_nelem</A>
 
152
method</LI>
 
153
 
 
154
<LI>
 
155
<B>-lorder </B>sets the byte order for integers stored in the database
 
156
meta-data to the given <B><I>order</I></B> using the <A HREF="../../docs/api_c/db_set_lorder.html">DB->set_lorder</A>
 
157
method</LI>
 
158
 
 
159
<LI>
 
160
<B>-delim </B>sets the delimiting byte for variable length records to
 
161
<B><I>delim</I></B>
 
162
using the <A HREF="../../docs/api_c/db_set_re_delim.html">DB->set_re_delim</A>
 
163
method</LI>
 
164
 
 
165
<LI>
 
166
<B>-len </B>sets the length of fixed-length records to <B><I>len</I></B>
 
167
using the <A HREF="../../docs/api_c/db_set_re_len.html">DB->set_re_len</A>
 
168
method</LI>
 
169
 
 
170
<LI>
 
171
<B>-pad </B>sets the pad character used for fixed length records to
 
172
<B><I>pad</I></B>&nbsp;
 
173
using the <A HREF="../../docs/db_set_re_pad.html">DB->set_re_pad</A> method</LI>
 
174
 
 
175
<LI>
 
176
<B>-source </B>sets the backing source file name to <B><I>file</I></B>
 
177
using the <A HREF="../../docs/api_c/db_set_re_source.html">DB->set_re_source</A>
 
178
method</LI>
 
179
 
 
180
<LI>
 
181
<B>-minkey </B>sets the minimum number of keys per Btree page to <B><I>minkey</I></B>
 
182
using the <A HREF="../../docs/api_c/db_set_bt_minkey.html">DB->set_bt_minkey</A>
 
183
method</LI>
 
184
 
 
185
<LI>
 
186
<B>-cachesize </B>sets the size of the database cache to the size&nbsp;
 
187
specified by <B><I>gbytes </I></B>and <B><I>bytes, </I></B>broken up into
 
188
<B><I>ncaches</I></B>
 
189
number of caches using the <A HREF="../../docs/api_c/db_set_cachesize.html">DB->set_cachesize</A>
 
190
method</LI>
 
191
 
 
192
<LI>
 
193
<B>-pagesize </B>sets the size of the database page to <B><I>pagesize </I></B>using
 
194
the <A HREF="../../docs/api_c/db_set_pagesize.html">DB->set_pagesize</A>
 
195
method</LI>
 
196
 
 
197
<LI>
 
198
<B><I>filename</I></B> indicates the name of the database</LI>
 
199
 
 
200
<LI>
 
201
<B><I>subdbname</I></B> indicate the name of the sub-database</LI>
 
202
</UL>
 
203
 
 
204
<HR WIDTH="100%">
 
205
<BR><B>&nbsp;berkdb upgrade [-dupsort] [-env <I>env</I>] [--] [<I>filename</I>]</B>
 
206
<P>This command will invoke the <A HREF="../../docs/api_c/db_upgrade.html">DB->upgrade</A>
 
207
function.&nbsp; If the command is given the <B>-env</B> option, then we
 
208
will accordingly upgrade the database filename within the context of that
 
209
environment. The <B>-dupsort</B> option selects the DB_DUPSORT flag for
 
210
upgrading. The use of --<B> </B>terminates the list of options, thus allowing
 
211
filenames beginning with a dash.
 
212
<P>
 
213
<HR WIDTH="100%"><B>> berkdb verify [-env <I>env</I>] [--] [<I>filename</I>]</B>
 
214
<P>This command will invoke the <A HREF="../../docs/api_c/db_verify.html">DB->verify</A>
 
215
function.&nbsp; If the command is given the <B>-env</B> option, then we
 
216
will accordingly verify the database filename within the context of that
 
217
environment.&nbsp; The use of --<B> </B>terminates the list of options,
 
218
thus allowing filenames beginning with a dash.
 
219
<P>
 
220
<HR WIDTH="100%"><B>> <I>db</I> join [-nosort] <I>db0.c0 db1.c0</I> ...</B>
 
221
<P>This command will invoke the <A HREF="../../docs/api_c/db_join.html">db_join</A>
 
222
function.&nbsp; After it successfully joins a database, we bind it to a
 
223
new Tcl command of the form <B><I>dbN.cX, </I></B>where X is an integer
 
224
starting at 0 (e.g. <B>db2.c0, db3.c0, </B>etc).&nbsp; We use the <I>Tcl_CreateObjCommand()&nbsp;</I>
 
225
to create the top level database function.&nbsp; It is through this cursor
 
226
handle that the user can access the joined data items.
 
227
<P>The options are:
 
228
<UL>
 
229
<LI>
 
230
<B>-nosort -</B> This flag causes DB not to sort the cursors based on the
 
231
number of data items they reference.&nbsp; It results in the DB_JOIN_NOSORT
 
232
flag being set.</LI>
 
233
</UL>
 
234
 
 
235
<HR WIDTH="100%"><B>> <I>db</I> get_join [-nosort] {db key} {db key} ...</B>
 
236
<P>This command performs a join operation on the keys specified and returns
 
237
a list of the joined {key data} pairs.
 
238
<P>The options are:
 
239
<UL>
 
240
<LI>
 
241
<B>-nosort</B> This flag causes DB not to sort the cursors based on the
 
242
number of data items they reference.&nbsp; It results in the DB_JOIN_NOSORT
 
243
flag being set.</LI>
 
244
</UL>
 
245
 
 
246
<HR WIDTH="100%"><B>> <I>db</I> keyrange [-txn <I>id</I>] key</B>
 
247
<P>This command returns the range for the given <B>key</B>.&nbsp; It returns
 
248
a list of 3 double elements of the form {<B><I>less equal greater</I></B>}
 
249
where <B><I>less</I></B> is the percentage of keys less than the given
 
250
key, <B><I>equal</I></B> is the percentage equal to the given key and <B><I>greater</I></B>
 
251
is the percentage greater than the given key.&nbsp; If the -txn option
 
252
is specified it performs this operation under transaction protection.
 
253
<BR>
 
254
<HR WIDTH="100%"><B>> <I>db</I> put</B>
 
255
<P>The <B>undocumented</B> options are:
 
256
<UL>
 
257
<LI>
 
258
<B>-nodupdata</B> This flag causes DB not to insert the key/data pair if
 
259
it already exists, that is, both the key and data items are already in
 
260
the database. The -nodupdata flag may only be specified if the underlying
 
261
database has been configured to support sorted duplicates.</LI>
 
262
</UL>
 
263
 
 
264
<HR WIDTH="100%"><B>> <I>dbc</I> put</B>
 
265
<P>The <B>undocumented</B> options are:
 
266
<UL>
 
267
<LI>
 
268
<B>-nodupdata</B> This flag causes DB not to insert the key/data pair if
 
269
it already exists, that is, both the key and data items are already in
 
270
the database. The -nodupdata flag may only be specified if the underlying
 
271
database has been configured to support sorted duplicates.</LI>
 
272
</UL>
 
273
 
 
274
</BODY>
 
275
</HTML>