Getting started with Berkeley DB

Source: Internet
Author: User

1 Introduction

 

2. Download and install 

Install

Environment Variable deployment

Compile

 

3. Common Operations Open Database

int DB->open(DB *db, DB_TXN *txnid, const char *file,                     const char *database, DBTYPE type, u_int32_t flags, int mode); eg:if ((ret = db_create(&dbp, NULL, 0)) != 0) {      fprintf(stderr, "db_create: %s\n",     db_strerror(ret));     exit (1);  }  if ((ret = dbp->open(dbp, NULL, DATABASE, NULL,      DB_BTREE, DB_CREATE, 0664)) != 0) {     dbp->err(dbp, ret, "%s", DATABASE);     exit (1);  } 

Insert

Retrieve Data

Delete

eg:key.data = "sport"; key.size = sizeof("sport"); if ((ret = dbp->del(dbp, NULL, &key, 0)) == 0) printf("db: %s: key was deleted.\n", (char*)key.data); else dbp->err(dbp, ret, "DB->del"); 
Close Database

Refresh cache to Hard Disk

More

 

 

 

 

Posted by: Large CC | 17SEP, 2013

Blog: blog.me115.com

Weibo: Sina Weibo

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.