1<!--$Id: recno.so,v 11.11 2003/10/18 19:15: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 Reference Guide: Managing record-based databases</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<a name="2"><!--meow--></a> 12<table width="100%"><tr valign=top> 13<td><b><dl><dt>Berkeley DB Reference Guide:<dd>Access Methods</dl></b></td> 14<td align=right><a href="/am_conf/h_nelem.html"><img src="/images/prev.gif" alt="Prev"></a><a href="/toc.html"><img src="/images/ref.gif" alt="Ref"></a><a href="/am_conf/extentsize.html"><img src="/images/next.gif" alt="Next"></a> 15</td></tr></table> 16<p align=center><b>Managing record-based databases</b></p> 17<p>When using fixed- or variable-length record-based databases, particularly 18with flat-text backing files, there are several items that the user can 19control. The Recno access method can be used to store either variable- 20or fixed-length data items. By default, the Recno access method stores 21variable-length data items. The Queue access method can only store 22fixed-length data items.</p> 23<b>Record Delimiters</b> 24<p>When using the Recno access method to store variable-length records, 25records read from any backing source file are separated by a specific 26byte value which marks the end of one record and the beginning of the 27next. This delimiting value is ignored except when reading records from 28a backing source file, that is, records may be stored into the database 29that include the delimiter byte. However, if such records are written 30out to the backing source file and the backing source file is 31subsequently read into a database, the records will be split where 32delimiting bytes were found.</p> 33<p>For example, UNIX text files can usually be interpreted as a sequence of 34variable-length records separated by ASCII newline characters. This byte 35value (ASCII 0x0a) is the default delimiter. Applications may specify a 36different delimiting byte using the <a href="/api_c/db_set_re_delim.html">DB->set_re_delim</a> method. If no 37backing source file is being used, there is no reason to set the 38delimiting byte value.</p> 39<b>Record Length</b> 40<p>When using the Recno or Queue access methods to store fixed-length 41records, the record length must be specified. Since the Queue access 42method always uses fixed-length records, the user must always set the 43record length prior to creating the database. Setting the record length 44is what causes the Recno access method to store fixed-length, not 45variable-length, records.</p> 46<p>The length of the records is specified by calling the 47<a href="/api_c/db_set_re_len.html">DB->set_re_len</a> method. The default length of the records is 0 bytes. 48Any record read from a backing source file or otherwise stored in the 49database that is shorter than the declared length will automatically be 50padded as described for the <a href="/api_c/db_set_re_pad.html">DB->set_re_pad</a> method. Any record stored 51that is longer than the declared length results in an error. For 52further information on backing source files, see 53<a href="/ref/am_conf/re_source.html">Flat-text backing files</a>.</p> 54<b>Record Padding Byte Value</b> 55<p>When storing fixed-length records in a Queue or Recno database, a pad 56character may be specified by calling the <a href="/api_c/db_set_re_pad.html">DB->set_re_pad</a> method. Any 57record read from the backing source file or otherwise stored in the 58database that is shorter than the expected length will automatically be 59padded with this byte value. If fixed-length records are specified but 60no pad value is specified, a space character (0x20 in the ASCII 61character set) will be used. For further information on backing source 62files, see <a href="/ref/am_conf/re_source.html">Flat-text backing 63files</a>.</p> 64<table width="100%"><tr><td><br></td><td align=right><a href="/am_conf/h_nelem.html"><img src="/images/prev.gif" alt="Prev"></a><a href="/toc.html"><img src="/images/ref.gif" alt="Ref"></a><a href="/am_conf/extentsize.html"><img src="/images/next.gif" alt="Next"></a> 65</td></tr></table> 66<p><font size=1>Copyright (c) 1996,2008 Oracle. All rights reserved.</font> 67</body> 68</html> 69