What Is New in SQLite 2
SQLite 2 introduced a major architectural overhaul, moving from a text-based storage model to a more efficient binary format. This version laid the groundwork for the modern SQLite we know today.
| Category | Key Changes |
|---|---|
| Core Architecture | Switched from text-based tables to a B-tree based backend with manifest typing. |
| API | Introduced the core C API functions (sqlite_open, sqlite_exec, etc.) that are still central today. |
| Features | Added support for transactions, indices, and triggers. |
| Compatibility | Included a utility for converting version 1.x databases to the new version 2 format. |
How did the storage engine change in version 2?
The most significant change was the move from a text-only storage engine to a B-tree backend. Version 1 stored everything, including integers and floats, as ASCII text. Version 2 introduced a binary format where each value is stored with a header indicating its datatype (integer, float, text, etc.). This shift dramatically improved performance for numerical operations and overall storage efficiency.
What new database features were introduced?
SQLite 2 added fundamental database features that were absent in the first version. This included full transaction support with COMMIT and ROLLBACK, allowing for atomic, consistent, isolated, and durable (ACID) operations. It also introduced support for creating indices to speed up queries and triggers to automate actions based on database events.
Was the API different from modern SQLite?
The core API introduced in version 2 is remarkably similar to the one used today. Key functions like sqlite_open, sqlite_close, sqlite_exec, and the callback-based approach for retrieving query results were all established in this release. The main difference is the "v2" suffix on the core functions in the modern API (e.g., sqlite_open_v2).
FAQ
Could SQLite 2 read version 1 database files?
No, the file formats were completely incompatible. However, SQLite 2 included a command-line utility to convert version 1 databases to the new version 2 format.
Did SQLite 2 support foreign key constraints?
No, foreign key constraints were not supported until a much later version. Version 2 focused on core features like transactions and indices.
What is manifest typing in SQLite 2?
It means the datatype is associated with the value itself, not the column it's stored in. This is different from static typing in traditional SQL databases and is a core concept that persists in SQLite today.
Was the database file format stable in version 2?
Yes, the version 2 file format was stable for the entire life of the 2.x series, unlike the experimental format used in version 1.
Why was the move to a B-tree backend so important?
It was a critical performance optimization. B-trees provide efficient O(log N) lookup, insertion, and deletion times, which was a massive improvement over the linear scans often required in the text-based version 1.