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