ASP源码.NET源码PHP源码JSP源码JAVA源码DELPHI源码PB源码VC源码VB源码Android源码
当前位置:首页 >> 低调看直播体育app软件下载 >> Android开发 >> SQLite 存储模型1

SQLite 存储模型1(4/7)

来源:网络整理     时间:2016-04-11     关键词:sqlite

本篇文章主要介绍了"SQLite 存储模型1",主要涉及到sqlite方面的内容,对于Android开发感兴趣的同学可以参考一下: 写在前面:SQLite作为嵌入式数据库,通常针对的应用的数据量相对于通常DBMS的数据量是较小的。所以它的存储模型设计得非常简单,总的来说,SQLite把一个数...

 ** Meta values are as follows:

 **    meta[0]   Schema cookie. Changes with each schema change.

 **    meta[1]   File format of schema layer.

 **    meta[2]   Size of the page cache.

 **    meta[3]   Use freelist if 0. Autovacuum if greater than zero.

 **    meta[4]   Db text encoding. 1:UTF-8 2:UTF-16LE 3:UTF-16BE

 **    meta[5]   The user cookie. Used by the application.

 **    meta[6]  

 **    meta[7]

 **    meta[8]

 **    meta[9] 

1.2.4、读取文件头
当应用程序调用API sqlite3_open打开数据库文件时,SQLite就会读取文件头进行数据库的初始化。

int sqlite3BtreeOpen(
  
const char *zFilename,  /* Name of the file containing the BTree database */
  sqlite3 
*pSqlite,       /* Associated database handle */
  Btree 
**ppBtree,        /* Pointer to new Btree object written here */
  
int flags               /* Options */
){
//读取文件头  sqlite3pager_read_fileheader(pBt->pPager, sizeof(zDbHeader), zDbHeader);
  
//设置页面大小pBt->pageSize = get2byte(&zDbHeader[16]);
//}sqlite3,sqlite下载,sqlite 工具,android sqlite,sqlite expert,sqlitejrs看球网直播吧_低调看直播体育app软件下载_低调看体育直播,sqlite数据库,sqlite语法,sqlite 可视化工具

3、页面结构(page structure)

数据库文件分成固定大小的页面。SQLite通过B+tree模型来管理所有的页面。页面(page)分三种类型:要么是tree page,或者是overflow page,或者是free page。

3.1、Tree page structure
每个tree page分成许多单元(cell),一个单元包含一个(或部分)payload。Cell是tree page进行分配或回收的基本单位。
一个tree page分成四个部分:

 (1)The page header
(2)The cell content area
(3)The cell pointer array
(4)Unallocated space
Cell 指针数组与cell content相向增长。一个page header仅包含用来管理页面的信息,它通常位于页面的开始处(但是对于数据库文件的第一个页面,它开始第100个字节处,前100个字节包含文件头信息(file header))。
               Structure of tree page header

Offset

Size

Description

相关图片

相关文章