db_load

db_load [-nTV] [-c name=value] [-f file]
    [-h home] [-P password] [-t btree | hash | queue | recno] file

db_load [-r lsn | fileid] [-h home] [-P password] file  

The db_load utility reads from the standard input and loads it into the database file. The database 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:

The db_load utility may be used with a Berkeley DB environment (as described for the -h option, the environment variable DB_HOME, or because the utility was run in a directory containing a Berkeley DB environment). In order to avoid environment corruption when using a Berkeley DB environment, db_load should always be given the chance to detach from the environment and exit gracefully. To cause db_load to release all environment resources and exit cleanly, 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.

Examples

The db_load utility can be used to load text files into databases. For example, the following command loads the standard UNIX /etc/passwd file into a database, with the login name as the key item and the entire password entry as the data item:

  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.

Environment Variables

DB_HOME

If the -h option is not specified and the environment variable DB_HOME is set, it is used as the path of the database home, as described in the DB_ENV->open() method.

Supported Keywords

The following keywords are supported for the -c command-line option to the db_load utility. See the DB_ENV->open() method for further discussion of these keywords and what values should be specified.

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 string value without modification.

  • bt_minkey (number)

    The minimum number of keys per page.

  • chksum (boolean)

    Enable page checksums.

  • database (string)

    The database to load.

  • db_lorder (number)

    The byte order for integers in the stored database metadata. For big endian systems, the order should be 4,321 while for little endian systems is should be 1,234.

  • db_pagesize (number)

    The size of database pages, in bytes.

  • duplicates (boolean)

    The value of the DB_DUP flag.

  • dupsort (boolean)

    The value of the DB_DUPSORT flag.

  • extentsize (number)

    The size of database extents, in pages, for Queue databases configured to use extents.

  • h_ffactor (number)

    The density within the Hash database.

  • h_nelem (number)

    The size of the Hash database.

  • keys (boolean)

    Specify whether keys are present for Queue or Recno databases.

  • re_len (number)

    Specify the length for fixed-length records. This number represents different things, depending on the access method the database is using. See the DB->set_re_len() method for details on what this number represents.

  • re_pad (string)

    Specify the fixed-length record pad character.

  • recnum (boolean)

    The value of the DB_RECNUM flag.

  • renumber (boolean)

    The value of the DB_RENUMBER flag.

  • subdatabase (string)

    The subdatabase to load.