POP Article V2.0 设为主页
收藏本站
首 页交流论坛留 言
您现在的位置:首 页 >> 热门开源项目 >> Berkeley DB >> 查看文章
Berkeley DB入门
作者:韩羽的专栏  来源:www.sqlite.com.cn  时间:2007-10-17  【 字体: 】 〖 双击滚屏 〗

Berkeley DB是一款开源软件,现在在Oracle旗下。本文是我初步阅读DB相关文档的笔记。以后会涉及更多细节。

Berkeley DB是由美国Sleepycat Software公司开发的一套开放源码的嵌入式数据库的程序库(database library),它为应用程序提供可伸缩的、高性能的、有事务保护功能的数据管理服务。

Berkeley DB不是关系型数据库,不是面向对象数据库,不是网络数据库,不是数据库服务器。

1.Secondary DB

相对Primary DB,用处是当想通过一些非keyItem进行检索时,激活。

 

2.Access Method

1Balanced Tree

2Hash

3Queue

4Recno

 

3.选择

1BTreeHash是类关联式容器,QueueRecno是类序列式容器。

2)对关联式来说,如果存在复杂数据集或者Disk I/O,请选择Hash;否则选择Btree.

3)对自己不生成KeyRecord来说,序列式更加适合。Queue适合定长记录,并发性更好(Record Locking)Recno适合变长Record.

 

4.限制

总容量256TB,单条容量4GB;对网络支持能力不佳。

 

5.Environment

1Multi-databases files

在一个物理文件中,支持多个数据库

2)多线程和多进程

3Transactional processing

4High availability (replication) support

5Logging subsystem

 

6.Exception

DB_CXX_NO_EXCEPTIONS 取消DB Exception

DbExceptionstd::exception子类

 

7.Open DB

// Open the database

db.open(

NULL, // Transaction pointer

"my_db.db", // Database file name

NULL, // Optional logical database name

DB_BTREE, // Database access method

oFlags, // Open flags

0); // File mode (using defaults)

 

8.Close DB

// Close the database

db.close(0);

 

9.DB Open Flag

DB_CREATE

If the database does not currently exist, create it. By default, the database open fails if the database does not already exist.

DB_EXCL

Exclusive database creation. Causes the database open to fail if the database already exists. This flag is only meaningful when used with DB_CREATE.DB_CREATE并用。

DB_RDONLY

Open the database for read operations only. Causes any subsequent database write operations to fail.

DB_TRUNCATE

Physically truncate (empty) the on-disk file that contains the database. Causes DB to delete all databases physically contained in that file.

 

10.Administrative Method

1Db::get_open_flags()

2Db::remove()

不要remove已经打开的数据库,不要remove包含打开数据库的文件。

// Database open and subsequent operations omitted for clarity

db.remove(

"mydb.db", // Database file to remove

NULL, // Database to remove. This is NULL so the entire file is removed.

0); // Flags. None used.

3Db::rename()

db.rename(

"mydb.db", // Database file to rename

NULL, // Database to rename. This is NULL so the entire file is renamed.

"newdb.db", // New database file name

0); // Flags. None used.

 

11.Error Reporting Functions

(1) set_error_stream()

(2) set_errcall()

(3) set_errfile()

(4) set_errpfx()

(5) err()

(6) errx()

 

Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=1815439

浏览次数:   【 打 印 】【 关 闭
上一篇:sqlite-3.3.6编译安装与交叉编译全过程详细记录
下一篇:Python正则表达式操作指南(1)
 论坛登陆
用户名:
密  码:
验证码: 
Cookie 选项:
正常登陆 隐身登陆
   
没有注册?
 文章搜索
 推荐文章
 酷站推荐
 热门文章
 网站统计
关于我们 | 网站地图 | 联系我们 | 网站历史 | 友情链接 | TOP
Copyright© 2006 Sqlite中文社区  程序开发: mistletoe  站长: 林轩 陈文成