没有合适的资源?快使用搜索试试~ 我知道了~
首页Inside SQLite
Inside SQLite
需积分: 32 99 下载量 196 浏览量
更新于2023-07-25
2
收藏 1.06MB PDF 举报
《Inside SQLite 》的E文版,原来是chm的,我将它改为了pdf的<br>主要内容是关于SQLite 3.0.0及以上版本的一些基础实现的梗概
资源详情
资源推荐
Table of Contents
Inside SQLite
by Sibsankar Haldar
Publisher: O'Reilly
Pub Date: April 15, 2007
Print ISBN-10: 0-596-55006-5
Print ISBN-13: 978-0-59-655006-6
Pages: 76
Copyright
Chapter 1. Overview
Section 1.1. Sample Applications
Section 1.2. SQLite Architecture
Section 1.3. SQLite Limitations
Chapter 2. Database File Format
Section 2.1. Database Naming Conventions
Section 2.2. Database File Structure
Chapter 3. Page Cache Management
Section 3.1. Pager Responsibilities
Section 3.2. Pager Interface Structure
Section 3.3. Cache Management
Chapter 4. Transaction Management
Section 4.1. Transaction Types
Section 4.2. Lock Management
Section 4.3. Journal Management
Section 4.4. Transactional Operations
Chapter 5. Table and Index Management
Section 5.1. B+-Tree Structure
Section 5.2. B+-tree in SQLite
Section 5.3. Page Structure
Section 5.4. Module Functionality
Chapter 6. SQLite Engine
Section 6.1. Bytecode Programming Language
Section 6.2. Record Format
Section 6.3. Data Type Management
Chapter 7. Further Information
file:///C|/Documents%20and%20Settings/Administrator/My%20Documents/3182066d9525e23c4ef089ec00a46ad7/000.toc.html2008-3-1 21:08:54
Copyright
Copyright
Copyright © 2007, O'Reilly Media, Inc.. All rights reserved.
Published by O'Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472.
O'Reilly books may be purchased for educational, business, or sales promotional use. Online
editions are also available for most titles (). For more information, contact our corporate/
institutional sales department: (800) 998-9938 or corporate@oreilly.com.
Nutshell Handbook, the Nutshell Handbook logo, and the O'Reilly logo are registered
trademarks of O'Reilly Media, Inc. The vulpine phalanger and related trade dress are
trademarks of O'Reilly Media, Inc.
Many of the designations uses by manufacturers and sellers to distinguish their products are
claimed as trademarks. Where those designations appear in this book, and O'Reilly Media,
Inc. was aware of a trademark claim, the designations have been printed in caps or initial
caps.
While every precaution has been taken in the preparation of this book, the publisher and
authors assume no responsibility for errors or omissions, or for damages resulting from the
use of the information contained herein.
file:///C|/Documents%20and%20Settings/Administrator/My%20Documents/3182066d9525e23c4ef089ec00a46ad7/001.copy.html2008-3-1 21:08:54
Chapter 1. Overview
Overview > Sample Applications
Chapter 1. Overview
Many database management systems (DBMSs) have been developed over the past several decades. DB-2,
Informix, Ingres, MySQL, Oracle, SQL Server, Sybase are a few that are commercially successful. SQLite is a
recent addition to the DBMS family, and it is also quite successful commercially. It has made a long journey
since its debut on May 29, 2000.
[*]
It is an SQL-based relational DBMS (RDBMS) with the following
characteristics:
[*]
SQLite received the 2005 OSCON Google and O'Reilly Integrator category award.
Zero configuration
There is no separate install or set up procedure to initialize SQLite before using it. There is no
configuration file. Databases need minimal or no administration. You can download the SQLite
source code from its homepage http://www.sqlite.org, compile it using your favorite C compiler,
and start using the compiled library.
Embeddable
There is no need to maintain a separate server process dedicated to SQLite. The library is
embeddable in your own applications.
Application interface
SQLite provides an SQL environment for C applications to manipulate databases. It is a call-level
interface library for dynamic SQL; users can assemble SQL statements on the fly and pass them
on to the interface for execution. (There are no other means, except by SQL, to manipulate
databases.) There are no special preprocessing and compilation requirements for applications; a
normal C compiler will do the work.
Transactional support
SQLite supports the core transactional properties, namely atomicity, consistency, isolation, and
durability (ACID). No actions are required from database administrators upon a system crash or
power failure to recover databases. When SQLite reads a database, it automatically performs
necessary recovery actions on the database in a user-transparent manner.
Thread-safe
SQLite is a thread-safe library, and many threads in an application process can access the same
or different databases concurrently. SQLite takes care of database-level thread concurrency.
Lightweight
SQLite has a small footprint of about 250 KB, and the footprint can be reduced further by
disabling some advanced features when you compile it from the source code. SQLite runs on
Linux, Windows, Mac OS X, OpenBSD, and a few other operating systems.
Customizable
file:///C|/Documents%20and%20Settings/Administrator/My...nts/3182066d9525e23c4ef089ec00a46ad7/002.overview.html(第 1/11 页)2008-3-1 21:08:56
Chapter 1. Overview
SQLite provides a good framework in which you can define and use custom-made SQL functions,
aggregate functions, and collating sequences. It also supports UTF-8 and UTF-16 standards-based
encoding for Unicode text.
Cross-platform
SQLite lets you move database files between platforms. For example, you can create a database
on a Linux x86 machine, and use the same database (by making a copy) on an ARM platform
without any alterations. The database behaves identically on all supported platforms.
SQLite is different from most other modern SQL databases in the sense that its primary design goal is to be
simple. SQLite strives to be simple, even if it leads to occasional inefficient implementations of some
features. It is simple to maintain, customize, operate, administer, and embed in C applications. It uses simple
techniques to implement ACID properties.
SQLite supports a large subset of SQL-92 data definition and manipulation features, and some SQLite specific
commands. You can create tables, indexes, triggers, and views using standard data definition SQL constructs.
You can manipulate stored information using INSERT, DELETE, UPDATE, and SELECT SQL constructs. The
following is a list of additional features supported as of the SQLite 3.3.6 release (the latest set of supported
features can be obtained from the SQLite homepage):
● Partial support for ALTER TABLE (rename table, add column)
● UNIQUE, NOT NULL, CHECK constraints
● Subqueries, including correlated subqueries, INNER JOIN, LEFT OUTER JOIN, NATURAL JOIN, UNION,
UNION ALL, INTERSECT, EXCEPT
● Transactional commands: BEGIN, COMMIT, ROLLBACK
● SQLite commands, including reindex, attach, detach, pragma
The following SQL-92 features are not yet supported as of the SQLite 3.3.6 release:
● Foreign key constraints (parsed but not enforced)
● Many ALTER TABLE features
● Some TRIGGER-related features
● RIGHT and FULL OUTER JOIN
● Updating a VIEW
● GRANT and REVOKE
SQLite stores an entire database in a single, ordinary native file that can reside anywhere in a directory of the
native filesystem. Any user who has permission to read the file can read anything from the database. A user
who has write permission on the file and the container directory can change anything in the database. SQLite
uses a separate journal file to save transaction recovery information that is used in the event of transaction
aborts or system failures. The SQLite attach command helps a transaction work on multiple databases
simultaneously. Such transactions are also ACID-compliant. Pragma commands let you alter the behavior of
the SQLite library.
SQLite allows multiple applications to access the same database concurrently. However, it supports a limited
form of concurrency among transactions. It allows any number of concurrent read-transactions on a
database, but only one exclusive write-transaction.
SQLite is a successful RDBMS. It has been widely used in low-to-medium tier database applications such as
web site services (SQLite works fine with up to 100,000 evenly distributed hits a day; the SQLite
development team has demonstrated that SQLite may even withstand 1,000,000 hits a day), cell phones,
PDAs, set-top boxes, standalone appliances. You could even use it in teaching SQL to students in a beginner
database course. The source code itself is well documented and commented, and you can use it in advanced
database management courses, or in projects as a reference technology. It is available freely, and has no
licensing complications because it is in the public domain.
file:///C|/Documents%20and%20Settings/Administrator/My...nts/3182066d9525e23c4ef089ec00a46ad7/002.overview.html(第 2/11 页)2008-3-1 21:08:56
Chapter 1. Overview
1.1. Sample Applications
In this section I will present some simple applications illustrating various features of SQLite. The applications
are presented in the following subsections.
1.1.1. A simple SQLite application
Let's begin our exploration of SQLite land by studying a very simple application. The following example
presents a typical SQLite application. It is a C program that invokes SQLite APIs to work with an SQLite
database file:
Here is a typical SQLite application:
Code View: Scroll / Show All
#include <stdio.h>
#include "sqlite3.h"
int main(void)
{
sqlite3* db = 0;
sqlite3_stmt* stmt = 0;
int retcode;
retcode = sqlite3_open("MyDB", &db); /* Open a database named MyDB */
if (retcode != SQLITE_OK){
sqlite3_close(db);
fprintf(stderr, "Could not open MyDB\n");
return retcode;
}
retcode = sqlite3_prepare(db, "select SID from Students order by SID",
-1, &stmt, 0);
if (retcode != SQLITE_OK){
sqlite3_close(db);
fprintf(stderr, "Could not execute SELECT\n");
return retcode;
}
while (sqlite3_step(stmt) == SQLITE_ROW){
int i = sqlite3_column_int(stmt, 0);
printf("SID = %d\n", i);
}
sqlite3_finalize(stmt);
sqlite3_close(db);
return SQLITE_OK;
}
You may compile the above example application and execute it. The sample output shown throughout this
document was generated on a Linux machine, but these examples will work on other platforms that SQLite
runs on.
These examples assume that you have already prepared the sqlite3 executable, the libsqlite3.so (sqlite3.dll
on Windows and libsqlite3.dylib for Mac OS X) shared library, and the sqlite3.h interface definition file. You
can obtain these in source or binary form from http://www.sqlite.org. You may find it easier to work with
these examples if you put all three (sqlite3, the shared library, and sqlite3.h) in the same directory as the
examples.
file:///C|/Documents%20and%20Settings/Administrator/My...nts/3182066d9525e23c4ef089ec00a46ad7/002.overview.html(第 3/11 页)2008-3-1 21:08:56
剩余104页未读,继续阅读
zeloas
- 粉丝: 3458
- 资源: 14
上传资源 快速赚钱
- 我的内容管理 收起
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
会员权益专享
最新资源
- zigbee-cluster-library-specification
- JSBSim Reference Manual
- c++校园超市商品信息管理系统课程设计说明书(含源代码) (2).pdf
- 建筑供配电系统相关课件.pptx
- 企业管理规章制度及管理模式.doc
- vb打开摄像头.doc
- 云计算-可信计算中认证协议改进方案.pdf
- [详细完整版]单片机编程4.ppt
- c语言常用算法.pdf
- c++经典程序代码大全.pdf
- 单片机数字时钟资料.doc
- 11项目管理前沿1.0.pptx
- 基于ssm的“魅力”繁峙宣传网站的设计与实现论文.doc
- 智慧交通综合解决方案.pptx
- 建筑防潮设计-PowerPointPresentati.pptx
- SPC统计过程控制程序.pptx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功