Database Commands

The database commands provide a conduit into the DB method functions.  They are all fairly straightforward and I describe them in terms of their DB functions briefly here, with a link to the DB page where appropriate.  The first set of commands are those I believe will be the primary functions used by most databases.  Some are directly related to their DB counterparts, and some are higher level functions that are useful to provide the user.

> berkdb open [-env env]
    [-btree|-hash|-recno|-queue|-unknown]
    [-create] [-excl] [-nommap] [-rdonly] [-truncate] [-mode mode] [-errfile filename]
    [-dup] [-dupsort] [-recnum] [-renumber] [-revsplitoff] [-snapshot]
    [-extent size]
    [-ffactor density]
    [-nelem size]
    [-lorder order]
    [-delim delim]
    [-len len]
    [-pad pad]
    [-source file]
    [-minkey minkey]
    [-cachesize {gbytes bytes ncaches}]
    [-pagesize pagesize]
    [--]
    [filename [subdbname]]

This command will invoke the db_create function.  If the command is given the -env 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 dbX, where X is an integer starting at 0 (e.g. db0, db1, etc).  We use the Tcl_CreateObjCommand()  to create the top level database function.  It is through this handle that the user can access all of the commands described in the Database Commands section.  Internally, the database handle is sent as the ClientData portion of the new command set so that all future database calls access the appropriate handle.

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 DB->open method call after parsing all of the various optional arguments.  We automatically set the DB_THREAD flag.  The arguments are:



 berkdb upgrade [-dupsort] [-env env] [--] [filename]

This command will invoke the DB->upgrade function.  If the command is given the -env option, then we will accordingly upgrade the database filename within the context of that environment. The -dupsort option selects the DB_DUPSORT flag for upgrading. The use of -- terminates the list of options, thus allowing filenames beginning with a dash.


> berkdb verify [-env env] [--] [filename]

This command will invoke the DB->verify function.  If the command is given the -env option, then we will accordingly verify the database filename within the context of that environment.  The use of -- terminates the list of options, thus allowing filenames beginning with a dash.


> db join [-nosort] db0.c0 db1.c0 ...

This command will invoke the db_join function.  After it successfully joins a database, we bind it to a new Tcl command of the form dbN.cX, where X is an integer starting at 0 (e.g. db2.c0, db3.c0, etc).  We use the Tcl_CreateObjCommand()  to create the top level database function.  It is through this cursor handle that the user can access the joined data items.

The options are:


> db get_join [-nosort] {db key} {db key} ...

This command performs a join operation on the keys specified and returns a list of the joined {key data} pairs.

The options are:


> db keyrange [-txn id] key

This command returns the range for the given key.  It returns a list of 3 double elements of the form {less equal greater} where less is the percentage of keys less than the given key, equal is the percentage equal to the given key and greater is the percentage greater than the given key.  If the -txn option is specified it performs this operation under transaction protection.


> db put

The undocumented options are:


> db stat

The undocumented options are:


> dbc put

The undocumented options are: