1、- 1 - 外文原文 The Extension C API This chapter is about teaching SQLite new tricks. The previous chapter dealt with generic database work; this chapter is about being creative. The latter half of the APIthe Extension APIoffers three basic ways to extend (or customize) SQLite, through the creation of us
2、er-defined functions, aggregates, and collation sequences. User-defined functions are SQL functions that map to some implementation that you write. They are callable from within SQL. For example, you could create a function hello_newman() that returns the string Hello Jerry and, once it is registere
3、d, call it from SQL as follows: sqlite select hello_newman() as reply; reply - Hello Jerry This is a special version of the SQLite command-line program I customized myself that includes hello_newman(). When I get bored, I call it occasionally. Aggregates are a special form of function and work in mu
4、ch the same way except that they operate on sets of records and return aggregated values or expressions computed over a partic-ular column in the set. Or they may be computed from multiple columns. Standard aggregates that are built into SQLite include SUM(), COUNT(), and AVG(), for example. Collations are methods of comparing and sorting text. That is, given two strings, a Collation would decide which one is greater, or whether the two are equal. The default Collation in