Getting Started with Berkeley DB

Legal Notice

This documentation is distributed under the terms of the Sleepycat public license. You may review the terms of this license at:

Sleepycat Software, Berkeley DB, Berkeley DB XML and the Sleepycat logo are trademarks or service marks of Sleepycat Software, Inc. All rights to these marks are reserved. No third-party use is permitted without the express prior written consent of Sleepycat Software, Inc.

To obtain a copy of this document's original source code, please write to .


Table of Contents

Conventions Used in this Book
1. Introduction to Berkeley DB
About This Manual
Berkeley DB Concepts
Access Methods
Selecting Access Methods
Choosing between BTree and Hash
Choosing between Queue and Recno
Database Limits and Portability
Error Returns
Getting and Using DB
2. Databases
Opening Databases
Closing Databases
Database Open Flags
Administrative Methods
Error Reporting Functions
Managing Databases in Environments
Database Example
3. Database Records
Using Database Records
Reading and Writing Database Records
Writing Records to the Database
Getting Records from the Database
Deleting Records
Data Persistence
Using C Structures with DB
C Structures with Pointers
Database Usage Example
4. Using Cursors
Opening and Closing Cursors
Getting Records Using the Cursor
Searching for Records
Working with Duplicate Records
Putting Records Using Cursors
Deleting Records Using Cursors
Replacing Records Using Cursors
Cursor Example
5. Secondary Databases
Opening and Closing Secondary Databases
Implementing Key Extractors
Reading Secondary Databases
Deleting Secondary Database Records
Using Cursors with Secondary Databases
Database Joins
Using Join Cursors
Secondary Database Example
Secondary Databases with example_database_load
Secondary Databases with example_database_read
6. Database Configuration
Setting the Page Size
Overflow Pages
IO Efficiency
Page Sizing Advice
Selecting the Cache Size
BTree Configuration
Allowing Duplicate Records
Setting Comparison Functions

List of Examples

2.1. The stock_db Structure
2.2. The stock_db Utility Functions
2.3. open_database() Function
2.4. The databases_setup() Function
2.5. The databases_close() Function
3.1. VENDOR Structure
3.2. example_database_load
4.1. example_database_read