SQLite

Book description

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.

Table of contents

  1. Copyright
  2. Foreword
  3. About the Author
  4. We Want to Hear from You!
  5. Reader Services
  6. Introduction Welcome to SQLite
    1. Why Use SQLite?
    2. Who This Book Is For
    3. How the Book Is Organized
      1. Part I—General SQLite Use
      2. Part II—Using SQLite Programming Interfaces
      3. Part III—SQLite Administration
    4. Versions of Software Covered
    5. Additional Resources
  7. I. General SQLite Use
    1. 1. Getting Started
      1. Introduction
      2. Features and Limitations
        1. Speed
        2. Portability
        3. Security
        4. SQL Implementation
        5. Customization
        6. Supported APIs
          1. C/C++
          2. PHP
          3. Perl
          4. Tcl
          5. Other Programming Languages
        7. Scalability
      3. When Not to Choose SQLite
        1. When SQLite Is Probably Wrong
          1. Network or Client/Server Applications
          2. High-Volume Websites
          3. High Concurrency
        2. When SQLite Is Probably Right
          1. Websites
          2. Embedded Devices
          3. Ad-hoc File Storage
          4. Internal Data Manipulation
      4. Looking at SQLite Databases
        1. The sqlite Tool
        2. SQLite Database Browser
      5. Help and Support
    2. 2. Working with Data
      1. SQLite Basics
        1. Prerequisites
        2. Obtaining the Sample Database
        3. Creating and Connecting to a Database
        4. Executing SQL from a File
        5. The Sample Database
        6. Typeless Data Types
        7. The INTEGER PRIMARY KEY
        8. Working with Dates
        9. Inserting the Sample Data
        10. BLOBs and Binary Data
      2. Querying and Updating the Database
        1. The SELECT Statement
        2. The WHERE Clause
        3. String Comparisons
        4. NULL Values
        5. Arithmetic Functions
        6. String Operators and Functions
        7. Joins
        8. Aggregate Functions
        9. Ordering Data
        10. Limiting Data
        11. Updating and Deleting Records
        12. Left Joins
        13. Nested Subqueries
        14. Cartesian Joins
        15. Transactions
        16. The sqlite_master Table
    3. 3. SQLite Syntax and Use
      1. Naming Conventions
        1. Valid Characters
        2. Name Length
        3. Reserved Keywords
        4. Case Sensitivity
      2. Creating and Dropping Tables
        1. Table Column Definitions
        2. Resolving Conflicts
        3. The CHECK Clause
        4. Using Temporary Tables
      3. Anatomy of a SELECT Statement
        1. The WHERE Clause
        2. GROUP BY and Aggregate Functions
        3. HAVING Clause
        4. Column Aliases
      4. Attaching to Another Database
      5. Manipulating Data
        1. Transactions
        2. Inserting Data
          1. INSERT Using VALUES
          2. INSERT Using SELECT
        3. Updating Data
        4. Deleting Data
        5. Altering a Table Schema
        6. Loading Data from a File
      6. Indexes
        1. Creating and Dropping Indexes
        2. UNIQUE Indexes
      7. Views
        1. Creating and Dropping Views
        2. Using Views
      8. Triggers
        1. Creating and Dropping Triggers
        2. Using Triggers
        3. Interrupting a Trigger
        4. Creating a Trigger on a View
      9. Working with Dates and Times
        1. Valid Timestring Formats
        2. Displaying a Formatted Date and Time
        3. Date and Time Modifiers
        4. Handling Different Time Zones
      10. SQL92 Features Not Supported
    4. 4. Query Optimization
      1. Keys and Indexes
        1. What an Index Does
        2. How Indexes Work in SQLite
        3. Indexing Multiple Columns
        4. Unique Indexes
        5. When to Create an Index
        6. When Indexes Can Be Used
        7. Tweaking the Table List
        8. Benchmarking
        9. Some Examples
      2. The EXPLAIN Statement
        1. Using Transactions
        2. The VACUUM Statement
        3. Tuning the Database Itself
  8. II. Using SQLite Programming Interfaces
    1. 5. The PHP Interface
      1. Configuring PHP for SQLite Support
        1. Configuring PHP for Linux/Unix
        2. Configuring PHP for Windows
        3. Checking for SQLite Support
        4. Getting Information About the SQLite Extension
      2. Using the PHP SQLite Extension
        1. Opening a Database
        2. Passing Queries and Commands to SQLite
        3. Using Commands That Change the Database
        4. Working with Retrieved Data
      3. Working with User-Defined Functions
        1. The php() Function
        2. Creating Aggregating Functions
        3. Working with Binary Data in UDFs
      4. Using the PEAR Database Class
    2. 6. The C/C++ Interface
      1. Preparing to Use the C/C++ Interface
      2. Using the C Language Interface
        1. Opening and Closing a Database
        2. Getting Information About the SQLite Library
        3. Executing SQL Statements
        4. Using Commands That Change the Database
        5. Callback Functions for SELECT Queries
        6. Executing SQL Without a Callback Function
        7. Fetching a Whole Dataset with sqlite_get_table()
      3. Adding New SQL Functions
        1. Creating Aggregating Functions
    3. 7. The Perl Interface
      1. Preparing to Use the SQLite Interface
      2. About the Perl DBI
        1. Getting Information About the DBI
        2. Using DBD Drivers
      3. Using the SQLite DBD
        1. Opening and Closing the Database
        2. Executing SQL Statements
        3. Using Bind Variables
        4. Using Commands That Change the Database
        5. Transactions
        6. Fetching Records from the Database
        7. Error Checking
        8. Tracing
      4. Adding New SQL Functions
        1. Creating Functions
        2. Creating Aggregating Functions
    4. 8. The Tcl Interface
      1. Preparing to Use the Tcl Interface
      2. Using the Tcl Interface
        1. Opening and Closing a Database
        2. Executing SQL Statements
        3. Using Commands That Change the Database
        4. Fetching Records from the Database
        5. The onecolumn Database Method
        6. Validating an SQL Statement
        7. Adjusting the Database Timeout Action
        8. Adding New SQL Functions
    5. 9. The Python Interface
      1. Preparing to Use the Python Interface
      2. Using the Python Interface
        1. Opening and Closing a Database
        2. Executing SQL Commands
        3. Error Handling
        4. Connection Parameters
        5. Using Commands That Change the Database
        6. Transactions
        7. Fetching Records from the Database
        8. Working with Data Types
        9. Adding New SQL Functions
        10. Adding Aggregating Functions
  9. III. SQLite Administration
    1. 10. General Database Administration
      1. The PRAGMA Command
        1. Fetching Database Information
        2. Altering Database Parameters
        3. Altering Database Parameters Permanently
        4. Altering Query Parameters
        5. Analyzing the Database
      2. Backing Up and Restoring Data
        1. The .dump Command
      3. Exploring the SQLite Virtual Database Engine
        1. SQLite Architecture
          1. Interface
          2. Tokenizer
          3. Parser
          4. Code Generator
          5. Virtual Machine
          6. Backend
          7. B-Tree
          8. Pager
          9. OS Interface
          10. Red/Black Tree
        2. Virtual Machine Opcodes
      4. Access to the Database File
        1. File Permissions
        2. Locking and Timeouts
        3. Multithreaded Database Access
  10. IV. Appendixes
    1. A. Downloading and Installing SQLite
      1. Obtaining SQLite
        1. RPM Installation for Linux
        2. Binary Installation for Linux
        3. Binary Installation for Windows
        4. Installing from Source Code
    2. B. Command Reference for the sqlite Tool
      1. Dot Commands
        1. Obtaining a List of Dot Commands
        2. Changing the Output Format
        3. Reading SQL Commands from a File
        4. Sending Output to a File
        5. Getting Information about the Database Schema
        6. Changing the sqlite Prompts
        7. Setting the Database Timeout
        8. Exiting the sqlite Tool
    3. C. SQL Syntax Reference
      1. Naming Conventions
        1. Reserved Keywords
      2. SQL Command Syntax
        1. Creating and Dropping Database Objects
          1. CREATE TABLE
          2. Column Constraints
          3. CREATE INDEX
          4. CREATE VIEW
          5. CREATE TRIGGER
        2. The SELECT Statement
        3. The INSERT Statement
        4. The UPDATE Statement
        5. The DELETE Statement
        6. The COPY Statement
        7. Resolving Conflicts
        8. Transactions
        9. Attaching to Other Databases
        10. Performance Tuning
        11. Comments
      3. ANSI SQL Commands and Features Not Supported
        1. ALTER TABLE
        2. COUNT(DISTINCT column-name)
        3. GRANT and REVOKE
        4. INSERT, UPDATE, and DELETE on Views
        5. RIGHT OUTER JOIN
        6. CHECK and FOREIGN KEY Constraints
        7. Trigger Limitations
        8. Nested Transactions
        9. Variable Subqueries
    4. D. PHP Interface Reference
      1. Predefined Constants
      2. Runtime Configuration
      3. Function Reference
        1. Opening and Closing a Database
        2. Executing a Query
        3. Error Reporting
        4. Finding Information About a Query
        5. Processing a Result Set
        6. Random Data Access Functions
        7. Convenience Functions
        8. Finding Information About SQLite
        9. Custom Functions (UDF)
    5. E. C Interface Reference
      1. The Core API
        1. Opening and Closing a Database
        2. Executing a Query
        3. Error Codes
      2. The Non-Callback API
        1. Creating a Virtual Machine
        2. Step-by-Step Execution of an SQL Statement
        3. Return Codes
      3. The Extended API
        1. Finding Information About the SQLite Library
        2. Finding Information About Changes to the Database
        3. Checking SQL Statements
        4. Interrupting an SQL Statement
        5. Convenience Functions
        6. The _printf() Wrapper Functions
        7. Memory Management
        8. Dealing with Locked Database Files
        9. Performing Background Jobs During Large Queries
      4. Adding New SQL Functions
        1. Registering Functions
        2. Setting Return Values
        3. Referencing Arbitrary Data
    6. F. Perl Interface Reference
      1. The Perl DBI
        1. Opening and Closing a Database
        2. Executing SQL Statements
        3. Using Bind Values
        4. Making Data Safe
        5. Getting Information About a Query
        6. Transactions
        7. Fetching Rows from a Query
        8. Error Reporting
        9. Creating User-Defined Functions
    7. G. Tcl Interface Reference
      1. The Tcl Library
        1. Opening and Closing a Database
        2. Executing a Query
        3. Convenience Functions
        4. Finding Information About a Query
        5. Checking SQL Statements
        6. Dealing with Locked Database Files
        7. Error Reporting
        8. Finding Information About SQLite
        9. Custom Functions (UDF)
    8. H. Python Interface Reference
      1. Opening and Closing a Database
        1. Executing SQL Statements
        2. Setting Data Type Mappings
      2. Creating User-Defined Functions
      3. Error Handling
    9. I. The Future of SQLite
      1. SQLite Version 3.0
        1. Naming Changes
        2. File Format Changes
        3. Data Typing
        4. User-Defined Collating Sequences
        5. Improved Concurrency

Product information

  • Title: SQLite
  • Author(s):
  • Release date: November 2004
  • Publisher(s): Sams
  • ISBN: 9780672326851