Sqlite China  
首页 | 各种语言的sqlite编程 | sqlite研究 |sqlite应用实例与杂谈 | sqlite相关下载 | SQlite论坛
当前位置 : 主页>sqlite研究>列表
sqlite 的相关调查1
来源:工友 作者:工友 时间:2007-12-21

1 SQLite数据库调查

1.1 SQLite支持的数据类型

1.1.1 Sqlite3支持的数据类型

NULL

INTEGER

REAL

TEXT

BLOB

但实际上,sqlite3也接受如下的数据类型:

smallint          16 位元的整数。

interger          32 位元的整数。

decimal(p,s)   p 精确值和 s 大小的十进位整数,精确值p是指全部有几个数(digits)大小值,s是指小数点後有几位数。如果没有特别指定,则系统会设为 p=5; s=0

float               32位元的实数。

double            64位元的实数。

char(n)           n 长度的字串,n不能超过 254

varchar(n)              长度不固定且其最大长度为 n 的字串,n不能超过 4000

graphic(n)              char(n) 一样,不过其单位是两个字元 double-bytes n不能超过127。这个形态是为
了支援两个字元长度的字体,例如中文字。

vargraphic(n)  可变长度且其最大长度为 n 的双字元字串,n不能超过 2000

date               包含了 年份、月份、日期。

time               包含了 小时、分钟、秒。

timestamp             包含了 年、月、日、时、分、秒、千分之一秒。

1.1.2 Sqlite 3中的数据类型的特点:

Each table column will store any type of data, though columns have an affinity for the format of data defined by their declared datatype.

When data is inserted into a column, that column will make at attempt to convert the data format into the columns declared type.

SQLite 3.0 will still store the data even if a format conversion is not possible.

For example, if you have a table column declared to be of type "INTEGER" and you try to insert a string,

the column will look at the text string and see if it looks like a number.

 If the string does look like a number it is converted into a number and into an integer if the number does not have a fractional part,

and stored that way. But if the string is not a well-formed number it is still stored as a string.

A column with a type of "TEXT" tries to convert numbers into an ASCII-Text representation before storing them.

But BLOBs are stored in TEXT columns as BLOBs because you cannot in general convert a BLOB into text.

1.2 sqlite的多用户操作的支持情况

不可同时写,读写不可同时进行,可以多用户读。

SQLite uses reader/writer locks on the entire database file. That means if any process is reading from any part of the database, all other processes are prevented from writing any other part of the database. Similarly, if any one process is writing to the database, all other processes are prevented from reading any other part of the database. For many situations, this is not a problem. Each application does its database work quickly and moves on, and no lock lasts for more than a few dozen milliseconds. But there are some applications that require more concurrency, and those applications may need to seek a different solution.

1.3 参考文档

sqlite的主页

www.sqlite.org/

SQLite 中文社区

http://www.sqlite.com.cn/

SQLite语法备忘录

http://www.sqlite.com.cn/POParticle/6/11.Html

SQLite Tutorial

http://souptonuts.sourceforge.net/readme_sqlite_tutorial.html

SQLite Optimization FAQ

http://web.utk.edu/~jplyon/sqlite/SQLite_optimization_FAQ.html

Overview (SQLite Java Wrapper)

http://www.ch-werner.de/javasqlite/


2 ePrint系统中应用SQLite调查

2.1 OracleSQLite的映射

2.1.1 数据类型映射

这次移行涉及到的Oracle的数据类型为:NUMBERVARCHAR2CHARDATE;相对应的SQLite数据类型如下表所示:

Oracle 数据类型

SQLite数据类型

NUMBER

NUMBER

VARCHAR2

VARCHAR2

CHAR

CHAR

DATE

DATE

2.1.2 数据库DDL和数据导入导出

参考OPV8A_2_OracleSqlite手順.xls

2.2 现存系统中SQL语句到SQLite的移植

SQLite 支持部分标准sql-92语法,符合标准的sql语句基本不需要修改,下面是需要修改的SQL文的整理。

SQL

class

SQLite

storage process

 

改写成java函数来对应

get_path

copy_object_by_id

get_depth

get_object_id

(custom function)

OracleExpSearchSelectDAO

OracleRealFolderUpdateDAO

OracleRealFolderSelectDAO

对用户自定义函数,sqlite database api提供了create_functioncreate_aggregate,但是我们使用的JDBC封装不支持上述api,所以通过改写成java函数来对应

或者通过在sqlite中增加一张表用来存放depth, path的信息

start with

connect by

取得目录树形结构

OracleExpSearchSelectDAO

OracleRealFolderSelectDAO

改写过程来对应

Sysdate

OracleRealFolderUpdateDAO

datetime('now')

for example: 2006-06-20 13:12:25

.NEXTVAL

 

CREATE时指定INTEGER PRIMARY KEYINSERT时,value指定null

CONCAT(?,'(%)')

OracleRealFolderUpdateDAO

?+('%')

(+)

OracleRealFolderSelectDAO

采用相应的sqlserver DAO的语句

and rownum<2

OracleSearchSelectDAO.java OracleSearchSelectDAO.java

LIMIT

select * from book_detail limit 3;

以下聚集函数完全支持

function

SQLite

count()

count()

max()

max()

lower()

lower()

upper()

upper()

substr()

substr()

2.3 javaSQLite

2.3.1 javaSQLite的数据访问方式比较

javaSQLite封装包提供了两种访问SQLite的接口: JNIJDBC,对两者的性能的测试如下:

l         测试方法:

参看附件的test1test2方法   附件

l         测试结果:

操作

JNI接口(采用transaction)

JDBC接口

Insert 1,000 records

109

32

Insert 10,000 records

547

375

Insert 1,000,000 records

39110

38484

Select 1,000,000 records

java.lang.OutOfMemoryError

2781

      

结论:

JDBC方式具有更高的性能,并且与原系统在接口方面具有更大的相似性。

(阅读次数:
上一篇:Sqlite.net 2.0使用笔记 下一篇:sqlite 的相关调查2
[收藏] [推荐] [评论(0条)] [返回顶部] [打印本页] [关闭窗口]
用户名: 新注册) 密码: 匿名评论
评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
§最新评论
热点文章
·SQLite数据库的体系结构
·SQLite与其他数据库的速度
·SQL 语言参考资料
·SQLite语法备忘录
·sqlite 的相关调查1
·嵌入式数据库SQLite的一份
·SQLite在嵌入式Web服务器
·点评主流开源数据库的技术
·基于ARM-Linux的SQLite嵌
·SQLite与其他数据库的速度
·SQLite数据库编程--创建数
·SQL 语法手册
·SQLite Mode 数据库交互的
·SQLITE3 使用总结(3)
·XXTEA加密算法为SQLite 3.
·SQLite 第三版总览(简介)
·SQLite 第三版中的数据类
·用sqlite 执行标准 sql 语
·System.Data.Sqlite 上手
·SQLite编译安装步骤
相关文章
·SQLite Mode 数据库交互的
·SQL 语言参考资料
·SQLite在嵌入式Web服务器
·SQL 语法手册
·System.Data.Sqlite 上手
·SQLite数据库编程--创建数
·SQLite数据库编程--数据库
·SQLite在TorqueScript中的
·关于sqlite_exec回调函数
·用sqlite 执行标准 sql 语

版权Power by DedeCms   后台登陆
Copyright @ 2007