Always Learning

Advanced Search

SQLite

SQLite

Chris Newman

Nov 2004, Paperback, 336 pages
ISBN13: 9780672326851
ISBN10: 067232685X
This title is no longer available.
24.99

This title cannot be purchased online
  • Print pagePrint page
  • Email this pageEmail page
  • Write a reviewWrite a review
  • Share

SQLite is a small, fast, embeddable database. What makes it popular is the combination of the database engine and interface into a single library as well as the ability to store all the data in a single file. Its functionality lies between MySQL and PostgreSQL, however it is faster than both databases.

In SQLite, author Chris Newman provides a thorough, practical guide to using, administering and programming this up-and-coming database. If you want to learn about SQLite or about its use in conjunction with PHP this is the book for you.

SQLite is a small, fast, embeddable database. What makes it popular is the combination of the database engine and interface into a single library as well as the ability to store all the data in a single file. Its functionality lies between MySQL and PostgreSQL, however it is faster than both databases.

In SQLite, author Chris Newman provides a thorough, practical guide to using, administering and programming this up-and-coming database. If you want to learn about SQLite or about its use in conjunction with PHP this is the book for you.

Introduction.

I. GENERAL SQLITE USE.

1. Getting Started.

Introduction.

Features and Limitations.

Speed.

Portability.

Security.

SQL Implementation.

Customization.

Supported APIs.

Scalability.

When Not to Choose SQLite.

When SQLite Is Probably Wrong.

When SQLite Is Probably Right.

Looking at SQLite Databases.

The sqlite Tool.

SQLite Database Browser.

Help and Support.

2. Working with Data.

SQLite Basics.

Prerequisites.

Obtaining the Sample Database.

Creating and Connecting to a Database.

Executing SQL from a File.

The Sample Database.

Typeless Data Types.

The INTEGER PRIMARY KEY.

Working with Dates.

Inserting the Sample Data.

BLOBs and Binary Data.

Querying and Updating the Database.

The SELECT Statement.

The WHERE Clause.

String Comparisons.

NULL Values.

Arithmetic Functions.

String Operators and Functions.

Joins.

Aggregate Functions.

Ordering Data.

Limiting Data.

Updating and Deleting Records.

Left Joins.

Nested Subqueries.

Cartesian Joins.

Transactions.

The sqlite_master Table.

3. SQLite Syntax and Use.

Naming Conventions.

Valid Characters.

Name Length.

Reserved Keywords.

Case Sensitivity.

Creating and Dropping Tables.

Table Column Definitions.

Resolving Conflicts.

The CHECK Clause.

Using Temporary Tables.

Anatomy of a SELECT Statement.

The WHERE Clause.

GROUP BY and Aggregate Functions.

HAVING Clause.

Column Aliases.

Attaching to Another Database.

Manipulating Data.

Transactions.

Inserting Data.

Updating Data.

Deleting Data.

Altering a Table Schema.

Loading Data from a File.

Indexes.

Creating and Dropping Indexes.

UNIQUE Indexes.

Views.

Creating and Dropping Views.

Using Views.

Triggers.

Creating and Dropping Triggers.

Using Triggers.

Interrupting a Trigger.

Creating a Trigger on a View.

Working with Dates and Times.

Valid Timestring Formats.

Displaying a Formatted Date and Time.

Date and Time Modifiers.

Handling Different Time Zones.

SQL92 Features Not Supported.

4. Query Optimization.

Keys and Indexes.

What an Index Does.

How Indexes Work in SQLite.

Indexing Multiple Columns.

Unique Indexes.

When to Create an Index.

When Indexes Can Be Used.

Tweaking the Table List.

Benchmarking.

Some Examples.

The EXPLAIN Statement.

Using Transactions.

The VACUUM Statement.

Tuning the Database Itself.

II. USING SQLITE PROGRAMMING INTERFACES.

5. The PHP Interface.

Configuring PHP for SQLite Support.

Configuring PHP for Linux/Unix.

Configuring PHP for Windows.

Checking for SQLite Support.

Getting Information About the SQLite Extension.

Using the PHP SQLite Extension.

Opening a Database.

Passing Queries and Commands to SQLite.

Using Commands That Change the Database.

Working with Retrieved Data.

Working with User-Defined Functions.

The php() Function.

Creating Aggregating Functions.

Working with Binary Data in UDFs.

Using the PEAR Database Class.

6. The C/C++ Interface.

Preparing to Use the C/C++ Interface.

Using the C Language Interface.

Opening and Closing a Database.

Getting Information About the SQLite Library.

Executing SQL Statements.

Using Commands That Change the Database.

Callback Functions for SELECT Queries.

Executing SQL Without a Callback Function.

Fetching a Whole Dataset with sqlite_get_table().

Adding New SQL Functions.

Creating Aggregating Functions.

7. The Perl Interface.

Preparing to Use the SQLite Interface.

About the Perl DBI.

Getting Information About the DBI.

Using DBD Drivers.

Using the SQLite DBD.

Opening and Closing the Database.

Executing SQL Statements.

Using Bind Variables.

Using Commands That Change the Database.

Transactions.

Fetching Records from the Database.

Error Checking.

Tracing.

Adding New SQL Functions.

Creating Functions.

Creating Aggregating Functions.

8. The Tcl Interface.

Preparing to Use the Tcl Interface.

Using the Tcl Interface.

Opening and Closing a Database.

Executing SQL Statements.

Using Commands That Change the Database.

Fetching Records from the Database.

The onecolumn Database Method.

Validating an SQL Statement.

Adjusting the Database Timeout Action.

Adding New SQL Functions.

9. The Python Interface.

Preparing to Use the Python Interface.

Using the Python Interface.

Opening and Closing a Database.

Executing SQL Commands.

Error Handling.

Connection Parameters.

Using Commands That Change the Database.

Transactions.

Fetching Records from the Database.

Working with Data Types.

Adding New SQL Functions.

Adding Aggregating Functions.

III. SQLITE ADMINISTRATION.

10. General Database Administration.

The PRAGMA Command.

Fetching Database Information.

Altering Database Parameters.

Altering Database Parameters Permanently.

Altering Query Parameters.

Analyzing the Database.

Backing Up and Restoring Data.

The .dump Command.

Exploring the SQLite Virtual Database Engine.

SQLite Architecture.

Virtual Machine Opcodes.

Access to the Database File.

File Permissions.

Locking and Timeouts.

Multithreaded Database Access.

IV. APPENDIXES.

Appendix A. Downloading and Installing SQLite.

Obtaining SQLite.

RPM Installation for Linux.

Binary Installation for Linux.

Binary Installation for Windows.

Installing from Source Code.

Appendix B. Command Reference for the sqlite Tool.

Dot Commands.

Obtaining a List of Dot Commands.

Changing the Output Format.

Reading SQL Commands from a File.

Sending Output to a File.

Getting Information about the Database Schema.

Changing the sqlite Prompts.

Setting the Database Timeout.

Exiting the sqlite Tool.

Appendix C. SQL Syntax Reference.

Naming Conventions.

Reserved Keywords.

SQL Command Syntax.

Creating and Dropping Database Objects.

The SELECT Statement.

The INSERT Statement.

The UPDATE Statement.

The DELETE Statement.

The COPY Statement.

Resolving Conflicts.

Transactions.

Attaching to Other Databases.

Performance Tuning.

Comments.

ANSI SQL Commands and Features Not Supported.

ALTER TABLE.

COUNT(DISTINCT column-name).

GRANT and REVOKE.

INSERT, UPDATE, and DELETE on Views.

RIGHT OUTER JOIN.

CHECK and FOREIGN KEY Constraints.

Trigger Limitations.

Nested Transactions.

Variable Subqueries.

Appendix D. PHP Interface Reference.

Predefined Constants.

Runtime Configuration.

Function Reference.

Opening and Closing a Database.

Executing a Query.

Error Reporting.

Finding Information About a Query.

Processing a Result Set.

Random Data Access Functions.

Convenience Functions.

Finding Information About SQLite.

Custom Functions (UDF).

Appendix E. C Interface Reference.

The Core API.

Opening and Closing a Database.

Executing a Query.

Error Codes.

The Non-Callback API.

Creating a Virtual Machine.

Step-by-Step Execution of an SQL Statement.

Return Codes.

The Extended API.

Finding Information About the SQLite Library.

Finding Information About Changes to the Database.

Checking SQL Statements.

Interrupting an SQL Statement.

Convenience Functions.

The _printf() Wrapper Functions.

Memory Management.

Dealing with Locked Database Files.

Performing Background Jobs During Large Queries.

Adding New SQL Functions.

Registering Functions.

Setting Return Values.

Referencing Arbitrary Data.

Appendix F. Perl Interface Reference.

The Perl DBI.

Opening and Closing a Database.

Executing SQL Statements.

Using Bind Values.

Making Data Safe.

Getting Information About a Query.

Transactions.

Fetching Rows from a Query.

Error Reporting.

Creating User-Defined Functions.

Appendix G. Tcl Interface Reference.

The Tcl Library.

Opening and Closing a Database.

Executing a Query.

Convenience Functions.

Finding Information About a Query.

Checking SQL Statements.

Dealing with Locked Database Files.

Error Reporting.

Finding Information About SQLite.

Custom Functions (UDF).

Appendix H. Python Interface Reference.

Opening and Closing a Database.

Executing SQL Statements.

Setting Data Type Mappings.

Creating User-Defined Functions.

Error Handling.

Appendix I. The Future of SQLite.

SQLite Version 3.0.

Naming Changes.

File Format Changes.

Data Typing.

User-Defined Collating Sequences.

Improved Concurrency.

Index.

Chris Newman is a consultant programmer specializing in the development of custom web-based database applications to a loyal international client base.

A graduate of Keele University, Chris lives in Stoke-on-Trent, England, where he runs Lightwood Consultancy Ltd, the company he founded in 1999 to further his interest in Internet technology. Lightwood operates web hosting services under the DataSnake brand and is proud to be one of the first hosting companies to offer and support SQLite as a standard feature on all accounts.

More information on Lightwood Consultancy Ltd can be found at http://www.lightwood.net, and Chris can be contacted at chris@lightwood.net.

Your opinions count

Be the first to review this product. Write your review now.