1<!--$Id: db_load.so,v 10.44 2007/10/26 15:02:55 bostic Exp $--> 2<!--Copyright (c) 1997,2008 Oracle. All rights reserved.--> 3<!--See the file LICENSE for redistribution information.--> 4<html> 5<head> 6<title>Berkeley DB: db_load</title> 7<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit."> 8<meta name="keywords" content="embedded,database,programmatic,toolkit,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++"> 9</head> 10<body bgcolor=white> 11<table width="100%"><tr valign=top> 12<td> 13<b>db_load</b> 14</td> 15</tr></table> 16<hr size=1 noshade> 17<tt> 18<b><pre>db_load [<b>-nTV</b>] [<b>-c name=value</b>] [<b>-f file</b>] 19 [<b>-h home</b>] [<b>-P password</b>] [<b>-t btree | hash | queue | recno</b>] file 20db_load [<b>-r lsn | fileid</b>] [<b>-h home</b>] [<b>-P password</b>] file</pre></b> 21<b>Description</b> 22<a name="2"><!--meow--></a> 23<p>The db_load utility reads from the standard input and loads it 24into the database <b>file</b>. The database <b>file</b> is created if 25it does not already exist.</p> 26<p>The input to db_load must be in the output format specified by the 27<a href="../utility/db_dump.html">db_dump</a> utility, utilities, or as specified for the <b>-T</b> 28below.</p> 29<p>The options are as follows:</p> 30<br> 31<b>-c</b><ul compact><li>Specify configuration options ignoring any value they may have based on 32the input. The command-line format is <b>name=value</b>. See the 33Supported Keywords section below for a list of keywords supported by 34the <b>-c</b> option.</ul> 35<b>-f</b><ul compact><li>Read from the specified <b>input</b> file instead of from the standard 36input.</ul> 37<b>-h</b><ul compact><li>Specify a home directory for the database environment. 38<p>If a home directory is specified, the database environment is opened 39using the <a href="../api_c/env_open.html#DB_INIT_LOCK">DB_INIT_LOCK</a>, <a href="../api_c/env_open.html#DB_INIT_LOG">DB_INIT_LOG</a>, 40<a href="../api_c/env_open.html#DB_INIT_MPOOL">DB_INIT_MPOOL</a>, <a href="../api_c/env_open.html#DB_INIT_TXN">DB_INIT_TXN</a>, and <a href="../api_c/env_open.html#DB_USE_ENVIRON">DB_USE_ENVIRON</a> 41flags to <a href="../api_c/env_open.html">DB_ENV->open</a>. (This means that db_load can be 42used to load data into databases while they are in use by other 43processes.) If the <a href="../api_c/env_open.html">DB_ENV->open</a> call fails, or if no home 44directory is specified, the database is still updated, but the 45environment is ignored; for example, no locking is done.</p></ul> 46<b>-n</b><ul compact><li>Do not overwrite existing keys in the database when loading into an 47already existing database. If a key/data pair cannot be loaded into the 48database for this reason, a warning message is displayed on the standard 49error output, and the key/data pair are skipped.</ul> 50<b>-P</b><ul compact><li>Specify an environment password. Although Berkeley DB utilities overwrite 51password strings as soon as possible, be aware there may be a window of 52vulnerability on systems where unprivileged users can see command-line 53arguments or where utilities are not able to overwrite the memory 54containing the command-line arguments.</ul> 55<b>-r</b><ul compact><li>Reset the database's file ID or log sequence numbers (LSNs). 56<p>All database pages in transactional environments contain references to 57the environment's log records. In order to copy a database into a 58different database environment, database page references to the old 59environment's log records must be reset, otherwise data corruption can 60occur when the database is modified in the new environment. The 61<b>-r</b> <b>lsn</b> option resets a database's log sequence 62numbers.</p> 63<p>All databases contain an ID string used to identify the database in the 64database environment cache. If a database is copied, and used in the 65same environment as another file with the same ID string, corruption can 66occur. The <b>-r</b> <b>fileid</b> option resets a database's file 67ID to a new value.</p> 68<p><b>In both cases, the physical file specified by the <b>file</b> argument 69is modified in-place.</b></p></ul> 70<b>-T</b><ul compact><li>The <b>-T</b> option allows non-Berkeley DB applications to easily load text 71files into databases. 72<p>If the database to be created is of type Btree or Hash, or the keyword 73<b>keys</b> is specified as set, the input must be paired lines of text, 74where the first line of the pair is the key item, and the second line of 75the pair is its corresponding data item. If the database to be created 76is of type Queue or Recno and the keywork <b>keys</b> is not set, the 77input must be lines of text, where each line is a new data item for the 78database.</p> 79<p>A simple escape mechanism, where newline and backslash (\) 80characters are special, is applied to the text input. Newline characters 81are interpreted as record separators. Backslash characters in the text 82will be interpreted in one of two ways: If the backslash character 83precedes another backslash character, the pair will be interpreted as a 84literal backslash. If the backslash character precedes any other 85character, the two characters following the backslash will be interpreted 86as a hexadecimal specification of a single character; for example, 87\0a is a newline character in the ASCII character set.</p> 88<p>For this reason, any backslash or newline characters that naturally 89occur in the text input must be escaped to avoid misinterpretation by 90db_load.</p> 91<p>If the <b>-T</b> option is specified, the underlying access method type 92must be specified using the <b>-t</b> option.</p></ul> 93<b>-t</b><ul compact><li>Specify the underlying access method. If no <b>-t</b> option is 94specified, the database will be loaded into a database of the same type 95as was dumped; for example, a Hash database will be created if a Hash 96database was dumped. 97<p>Btree and Hash databases may be converted from one to the other. Queue 98and Recno databases may be converted from one to the other. If the 99<b>-k</b> option was specified on the call to <a href="../utility/db_dump.html">db_dump</a> then Queue 100and Recno databases may be converted to Btree or Hash, with the key being 101the integer record number.</p></ul> 102<b>-V</b><ul compact><li>Write the library version number to the standard output, and exit.</ul> 103<br> 104<p>The db_load utility may be used with a Berkeley DB environment (as described for the 105<b>-h</b> option, the environment variable <b>DB_HOME</b>, or 106because the utility was run in a directory containing a Berkeley DB 107environment). In order to avoid environment corruption when using a 108Berkeley DB environment, db_load should always be given the chance to 109detach from the environment and exit gracefully. To cause db_load 110to release all environment resources and exit cleanly, send it an 111interrupt signal (SIGINT).</p> 112<p>The db_load utility exits 0 on success, 1 if one or more key/data 113pairs were not loaded into the database because the key already existed, 114and >1 if an error occurs.</p> 115<b>Examples</b> 116<p>The db_load utility can be used to load text files into databases. 117For example, the following command loads the standard UNIX 118<i>/etc/passwd</i> file into a database, with the login name as the 119key item and the entire password entry as the data item:</p> 120<blockquote><pre>awk -F: '{print $1; print $0}' < /etc/passwd | 121 sed 's/\\/\\\\/g' | db_load -T -t hash passwd.db</pre></blockquote> 122<p>Note that backslash characters naturally occurring in the text are escaped 123to avoid interpretation as escape characters by db_load.</p> 124<br><b>Environment Variables</b> 125<br> 126<b>DB_HOME</b><ul compact><li>If the <b>-h</b> option is not specified and the environment variable 127DB_HOME is set, it is used as the path of the database home, as described 128in <a href="../api_c/env_open.html">DB_ENV->open</a>.</ul> 129<br> 130<b>Supported Keywords</b> 131The following keywords are supported for the <b>-c</b> command-line 132option to the db_load utility. See <a href="../api_c/db_open.html">DB->open</a> for further 133discussion of these keywords and what values should be specified. 134<p>The parenthetical listing specifies how the value part of the 135<b>name=value</b> pair is interpreted. Items listed as (boolean) 136expect value to be <b>1</b> (set) or <b>0</b> (unset). Items listed 137as (number) convert value to a number. Items listed as (string) use 138the string value without modification.</p> 139<br> 140<b>bt_minkey (number)</b><ul compact><li>The minimum number of keys per page.</ul> 141<b>chksum (boolean)</b><ul compact><li>Enable page checksums.</ul> 142<b>database (string)</b><ul compact><li>The database to load.</ul> 143<b>db_lorder (number)</b><ul compact><li>The byte order for integers in the stored database metadata.</ul> 144<b>db_pagesize (number)</b><ul compact><li>The size of database pages, in bytes.</ul> 145<b>duplicates (boolean)</b><ul compact><li>The value of the <a href="../api_c/db_set_flags.html#DB_DUP">DB_DUP</a> flag.</ul> 146<b>dupsort (boolean)</b><ul compact><li>The value of the <a href="../api_c/db_set_flags.html#DB_DUPSORT">DB_DUPSORT</a> flag.</ul> 147<b>extentsize (number)</b><ul compact><li>The size of database extents, in pages, for Queue databases configured 148to use extents.</ul> 149<b>h_ffactor (number)</b><ul compact><li>The density within the Hash database.</ul> 150<b>h_nelem (number)</b><ul compact><li>The size of the Hash database.</ul> 151<b>keys (boolean)</b><ul compact><li>Specify whether keys are present for Queue or Recno databases.</ul> 152<b>re_len (number)</b><ul compact><li>Specify fixed-length records of the specified length.</ul> 153<b>re_pad (string)</b><ul compact><li>Specify the fixed-length record pad character.</ul> 154<b>recnum (boolean)</b><ul compact><li>The value of the <a href="../api_c/db_set_flags.html#DB_RECNUM">DB_RECNUM</a> flag.</ul> 155<b>renumber (boolean)</b><ul compact><li>The value of the <a href="../api_c/db_set_flags.html#DB_RENUMBER">DB_RENUMBER</a> flag.</ul> 156<b>subdatabase (string)</b><ul compact><li>The subdatabase to load.</ul> 157<br> 158</tt> 159<p><font size=1>Copyright (c) 1996,2008 Oracle. All rights reserved.</font> 160</body> 161</html> 162