Berkeley DB Reference Guide: Access Methods
Полезная информация

Berkeley DB Reference Guide: Access Methods

Duplicate data items (DB_DUP)

The Hash access method supports the creation of multiple data items for a single key item. By default, multiple data items are not supported, and each database store operation will overwrite any previous data item for that key. To configure Berkeley DB for duplicate data items, set the DB_DUP flag in the DB_INFO structure.

When stepping through the database sequentially, duplicate data items will be returned individually, as a key/data pair, where the key item only changes when the last duplicate data item has been returned. For this reason, duplicate data items cannot be accessed using the DB->get function, as it always returns the first of the duplicate data items. Duplicate data items should be retrieved using the Berkeley DB cursor function, DBcursor->c_get.