The Command Line Tools

JE ships with several command line tools that you can use to help you manage your databases. They are:

DbDump

Dumps a database to a flat-text representation. Options are:

-h

Identifies the environment's directory. This parameter is required.

-s

Identifies the database to be dumped. If this option is not specified, then the -l is required.

-p

Prints database records in human-readable format.

-l

Lists the databases contained in the environment. If the -s is not provided, then this argument is required.

-f

Identifies the file to which the output from this command is written. The console (standard out) is used by default.

-V

Prints the database version number and then quits. All other command line options are ignored.

For example:

> java com.sleepycat.je.util.DbDump -h . -p -s VendorDB  
VERSION=3
format=print
type=btree
database=VendorDB
dupsort=false
HEADER=END
 Mom's Kitchen
 sr\01\01xpt\00\0d53 Yerman Ct.t\00\0c763 554 9200t\00\0bMiddle Townt\00
 \0eMaggie Kultgent\00\10763 554 9200 x12t\00\02MNt\00\0dMom's Kitchent\00
 \0555432
 Off the Vine
 sr\01\01xpt\00\10133 American Ct.t\00\0c563 121 3800t\00\0aCentennialt\00
 \08Bob Kingt\00\10563 121 3800 x54t\00\02IAt\00\0cOff the Vinet\00\0552002
 Simply Fresh
 sr\01\01xpt\00\1115612 Bogart Lanet\00\0c420 333 3912t\00\08Harrigant\00
 \0fCheryl Swedbergt\00\0c420 333 3952t\00\02WIt\00\0cSimply Fresht\00\0
 553704
 The Baking Pan
 sr\01\01xpt\00\0e1415 53rd Ave.t\00\0c320 442 2277t\00\07Dutchint\00\09
 Mike Roant\00\0c320 442 6879t\00\02MNt\00\0eThe Baking Pant\00\0556304
 The Pantry
 sr\01\01xpt\00\111206 N. Creek Wayt\00\0c763 555 3391t\00\0bMiddle Town
 t\00\0fSully Beckstromt\00\0c763 555 3391t\00\02MNt\00\0aThe Pantryt\00
 \0555432
 TriCounty Produce
 sr\01\01xpt\00\12309 S. Main Streett\00\0c763 555 5761t\00\0bMiddle Townt
 \00\0dMort Dufresnet\00\0c763 555 5765t\00\02MNt\00\11TriCounty Producet
 \00\0555432
DATA=END
> 

DbLoad

Loads a database from the output produced by DbDump. Options are:

-h

Identifies the environment's directory. This parameter is required.

-s

Overrides the database name, causing the data to be loaded into a database that uses the name supplied to this parameter.

-c

Specifies configuration options. The options supplied here override the corresponding options that appear in the data that is being loaded. This option takes values of the form name=value, where name is the configuration option that you are overriding and value is the new value for the option.

The following options can be specified:

  • database

    The name of the database to be loaded. This option duplicates the functionality of this command's -s command line option.

  • dupsort

    Indicates whether duplicates are allowed in the database. A value of true allows duplicates in the database.

-f

Identifies the file from which the database is to be loaded.

-n

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

-T

Causes a flat text file to be loaded into the database.

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.

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 a hexadecimal specification of a single character; for example, \0a is a newline character in the ASCII character set.

For this reason, any backslash or newline characters that naturally occur in the text input must be escaped to avoid misinterpretation by db_load.

-V

Prints the database version number and then quits. All other command line options are ignored.

For example:

> java com.sleepycat.je.util.DbDump -h . -s VendorDB -f vendordb.txt
> java com.sleepycat.je.util.DbLoad -h . -f vendordb.txt
> 

DbVerify

Examines the identified database for errors. Options are:

-h

Identifies the environment's directory. This parameter is required.

-s

Identifies the database to be verified. This parameter is required.

-q

Suppress the printing of any error descriptions. Instead, simply exit success or failure.

-V

Prints the database version number and then quits. All other command line options are ignored.

For example:

> java com.sleepycat.je.util.DbVerify -h . -s VendorDB

<DbVerify name="VendorDB">
<TreeInfo INcount="1" BINcount="1" LNcount="6" DeletedLNcount="0" 
DupCountLNCount="0" MaxDepth="65538" RootId="15"/>
<NodeInfo count="8">
<node id="21"/>
<node id="20"/>
<node id="19"/>
<node id="18"/>
<node id="17"/>
<node id="16"/>
<node id="15"/>
<node id="14"/>
</NodeInfo>
</DbVerify>