### Berkeley DB Reference Guide: Access Methods |

# Managing Record-based databases

When using fixed or variable length record-based databases, particularly with flat-text backing files, there are several areas that the user can control. The Recno access method can be used to store both variable and fixed-length data items. By default, the data items are variable-length. The Queue access method is used to store fixed-length data items.

### Record Delimiters

In the case of variable length records, the records are assumed to be separated by a specific character, to mark the end of one record and the beginning of the next. For example, standard UNIX byte stream files can be interpreted as a sequence of variable length records separated by ASCII newline characters. This character (ASCII 0x0a) is the default delimiter. The user may specify a different delimiting character as described for the DB->set_re_delim function interface.

### Record Length

The Recno access method can be used to store both variable and fixed-length data items. By default, Recno data items are variable-length. Setting a length of the records changes the Recno database to use fixed-length records. Since the Queue access method always uses fixed-length records, the user must always set the record length prior to creating the database.

The length of the records is specified by calling the DB->set_re_len function. The default length of the records is 0 bytes. Any record read from a backing source file or otherwise stored in the database that is shorter than the declared length will automatically be padded as described for the DB->set_re_pad function. Any record stored that is that is longer than the declared length results in an error.

### Record Padding Byte Value

When storing fixed-length records in a Queue or Recno database, a pad character may be specified by calling the DB->set_re_pad function. Any record read from the backing source file or otherwise stored in the database that is shorter than the expected length will automatically be padded with this byte value. If fixed-length records are specified but no pad value is specified, a space character (0x20 in the ASCII character set) will be used.

Copyright Sleepycat Software