db_load [-nT] [-c name=value] [-f file] [-h home] [-t btree | hash | recno] db_file
The db_load utility reads from the standard input and loads it into the database db_file. The database db_file is created if it does not already exist.
The input to db_load must be in the output format specified by the db_dump utility, utilities, or as specified for the -T below.
The options are as follows:
If a home directory is specified, the database environment is opened using the DB_INIT_LOCK, DB_INIT_LOG, DB_INIT_MPOOL, DB_INIT_TXN and DB_USE_ENVIRON flags to db_appinit. (This means that db_load can be used to load data into databases while they are in use by other processes.) If the db_appinit call fails, or if no home directory is specified, the database is still updated, but the environment is ignored, e.g., no locking is done.
If the database to be created is of type btree or hash, 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. If the database to be created is of type recno, the input must be lines of text, where each line is a new data item for the database.
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 hexadecimal specification of a single character, e.g., \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.
If the -T option is specified, the underlying access method type must be specified using the -t option.
Btree and hash databases may be converted from one to the other. Recno databases may not be converted to any other database type or from any other database type.
The db_archive utility attaches to one or more of the Berkeley DB shared memory regions. In order to avoid region corruption, it should always be given the chance to detach and exit gracefully. To cause db_archive to clean up after itself and exit, send it an interrupt signal (SIGINT).
The db_load utility exits 0 on success, 1 if one or more key/data pairs were not loaded into the database because the key already existed, and >1 if an error occurs.
awk -F: '{print $1; print $0}' < /etc/passwd | sed 's/\\/\\\\/g' | db_load -T -t hash passwd.db
Note that backslash characters naturally occurring in the text are escaped to avoid interpretation as escape characters by db_load.
The parenthetical listing specifies how the value part of the name=value pair is interpreted. Items listed as (boolean) expect value to be 1 (set) or 0 (unset). Items listed as (number) convert value to a number. Items listed as (string) use the characters of value directly.