Chinaunix首页 | 论坛 | 博客
  • 博客访问: 227817
  • 博文数量: 27
  • 博客积分: 719
  • 博客等级: 上士
  • 技术积分: 386
  • 用 户 组: 普通用户
  • 注册时间: 2012-03-20 21:04
文章分类

全部博文(27)

文章存档

2012年(27)

分类: SQLite/嵌入式数据库

2012-04-15 20:53:10

A Template For SELECT Programs

The first two query examples illustrate a kind of template that every SELECT program will follow. Basically, we have:

SELECT程序的模板

前两个查询的例子说明SELECT程序遵从的模板,基本上,我们需要做的:

1. Initialize the azColumnName[] array for the callback.

为回调函数初始化azColumnName

2. Open a cursor into the table to be queried.

为要查询的表打开游标

3. For each record in the table, do:

对于表中每条记录,要做到:

a. If the WHERE clause evaluates to FALSE, then skip the steps that follow and continue to the next record.

如果where子语句判断为FALSE,跳过该记录,然后处理下一条记录

b. Compute all columns for the current row of the result.

计算当前结果行的所有列

c. Invoke the callback function for the current row of the result.

为当前结果的行调用回调函数

4. Close the cursor.

关闭游标

This template will be expanded considerably as we consider additional complications such as joins, compound selects, using indices to speed the search, sorting, and aggregate functions with and without GROUP BY and HAVING clauses. But the same basic ideas will continue to apply.

当我们考虑其他操作,如连接,复合选择,使用索引加快搜索,排序,使用或者不适用GROUPBY和HAVING子语句等都会使这个模板大大扩展。但是基本的思路不变。

阅读(2039) | 评论(0) | 转发(0) |
0

上一篇:SSD中FTL含义

下一篇:UPDATE和DELETE实例(5)

给主人留下些什么吧!~~