小型mysql_小型数据库的选择(轻量级数据库)(转)

小型数据库的选择(轻量级数据库)

一直使用Sql Server开发,没有用过Access之外其它的DB。最近正想做个小型工具,这种小东西当然不可能用Sql Server数据库啦,可又不想用Access,于是想起在Blog中看到关于小型数据库的文章,收集如下资料:

据称,在国外,需要使用客户端数据库的情况中,有30%左右的开发者选择Access,有30%的开发者选择MSDE 2000,有30%的开发者选择Embedded Firebird,剩余10%选择其他小型数据库,如SQLite,MySQL 等。

引用

Embedded Firebird DB 简介

最近在学习 Firebird Embeded Database。作为一款单文件型小型数据库,Firebird 具有很多吸引人的特征,比如支持事务、支持存储过程、触发器等,而且 Embeded 版本的 Firebird 在 .NET 开发中只需要拷贝两个文件:一个 fbembed.dll (非托管但不需要注册的动态链接库)和一个 ADO.NET Data Provider 的 FirebirdSql.Data.Firebird.dll。这些特征都非常适合那些需要在客户端存储一些数据,但又不想安装数据库(比如MSDE)软件的情形。

据称,在国外,需要使用客户端数据库的情况中,有30%左右的开发者选择Access,有30%的开发者选择MSDE 2000,有30%的开发者选择Embedded Firebird,剩余10%选择其他小型数据库,如SQLite,MySQL 等。

上面所说的Access,MSDE 2000,Embedded Firebird,SQLite等都是可以免费再分发(free redistributable)的数据库。相比而言,MSDE 2000 显著缺点是需要安装,最大优点是和服务器端的 SQL Server 编程模型一致,开发便利。Access的显著缺点是功能较少,不支持事务等常用功能,最大优点是简单、多数开发者都很熟悉,部署也很方便。SQLite支持事务,也是一款单文件数据库,比较不足的是 .NET Data Provider 还不是很成熟。Firebird则同时具有:单文件、部署简单不需安装(只需 XCOPY 两个文件)、支持事务、存储过程、触发器,.NET Data Provider比较稳定成熟等优点。

Firebird 本身有SuperServer和Embedded版本之分,后者只能本机访问,不接受TCP连接。对于开发者而言,从Embedded数据库切换到SuperServer,只需更改数据库连接串中的ServerType值就行。

但是,在你正式决定使用?Firebird 之前,请你注意下面这个 known issue(已知问题): Firebird 数据库文件不能放置在含有中文等字符的路径中。Firebird 的文件名不可以用中文字符,所在路径的任何部分如果含有中文字符,都将无法访问到数据库。举个例子,中文Windows桌面所在的目录一般是“C:Documents and Settings用户名桌面”,如果数据库文件放置在桌面上,就无法访问到。当然,Firebird 内部是可以存储中文字符的,因为它支持 GB2312 和 UNICODE 等字符集。

我已向 Firebird 开发者报告了这个 BUG,希望能早日解决这个 BUG。

需要注意一点,连接串中的 Database 地址如果使用相对路径,请一定注意这个相对路径是相对于 fbembed.dll 所在目录的。

-------------------------

Sqlite中文资料

介绍

这是嵌入式SQL数据库引擎SQLite(SQLite Embeddable SQL Database Engine)的一个扩展。SQLite是一个实现嵌入式SQL数据库引擎的 C语言库(C library)。用SQLite连接的程序可以使用SQL数据库,但不需要运行一个单独的关系型数据库管理系统进程(separate RDBMS process)。

SQLite不是一个用于连接到大型数据库服务器(big database server)的客户端库(client library)。SQLite是一个服务器。SQLite直接读写(reads and writes directly)在硬盘上的数据库文件。

注:更多关于SQLite的资料请查看SQLite的网站(http://sqlite.org/)。

安装

请阅读在安装包里的 INSTALL 文件。或者使用PEAR installer with "pear install sqlite"。SQLite已经内置了,你不需要安装任何附加的软件(additional software)。

Windows users可以下载SQLite扩展DLL(php_sqlite.dl)。

需求

为了可以使用那些函数,你必须编译带上SQLite支持PHP(compile PHP with SQLite support),或者在你的php.ini加载SQLite扩展。

资源类型

有两个在SQLite界面(the SQLite Interface)可用的资源。第一个是数据库连接(the database connection),第二是计算结果设置(the result set)。

预定义常量

函数sqlite_fetch_array()和sqlite_current()使用一个常量表示不同的返回类型。下面的常量(表格 1.)已经被定义:

表格 1. SQLite 常量

常量名 意义

SQLITE_ASSOC Columns are returned into the array having the fieldname as the array index.

SQLITE_BOTH Columns are returned into the array having both a numerical index and the fieldname as the array index.

SQLITE_NUM Columns are returned into the array having a numerical index to the fields. This index starts with 0, the first field in the result.

运行时配置

这些函数的行为受到全局配置文件 php.ini 的影响。

表格 2. SQLite Configuration Options

Name Default Changeable

sqlite.assoc_case 0 PHP_INI_ALL

For further details and definition of the PHP_INI_* constants see ini_set().

以下是该配置选项的简要解释。

sqlite.assoc_case int

Whether to use mixed case (0), upper case (1) or lower case (2) hash indexes.

This option is primarily useful when you need compatibility with other database systems, where the names of the columns are always returned as uppercase or lowercase, regardless of the case of the actual field names in the database schema.

The SQLite library returns the column names in their natural case (that matches the case you used in your schema). When sqlite.assoc_case is set to 0 the natural case will be preserved. When it is set to 1 or 2, PHP will apply case folding on the hash keys to upper- or lower-case the keys, respectively.

Use of this option incurs a slight performance penalty, but is MUCH faster than performing the case folding yourself using PHP script.

目录

sqlite_array_query —— 发送一条 SQL 查询,并返回一个数组。

sqlite_busy_timeout —— 设置超时时间(busy timeout duration),或者频繁的用户失去权限(disable busy handlers)。

sqlite

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值