Recently released SQLite 3.9 provides a number of new features and enhancements, including support for JSON encoding/decoding, full text search version 5, indexes on expressions, eponymous virtual tables and more.
According to the newly adopted semantic versioning standard, SQLite 3.9 is a new version that includes changes that break forward compatibility by introducing new features, while being backward compatible with older versions. Among the new features that SQLite 3.9 introduces:
- JSON support through the
json1
extension that implements a set of functions to validate JSON strings, construct JSON arrays and objects, manipulate JSON strings by updating, inserting, or replacing values, etc. Additionally, two table-valued functions allow to transform a JSON string into a virtual table with each JSON element mapped to a row. - Indexes on expressions, which complement the traditional indexes that reference table columns and allow to define indexes on expressions involving columns. This features would allow to efficiently perform queries, e.g., to list all changes to a given account number that amount to more than a given quantity:
CREATE INDEX account_change_magnitude ON account_change(acct_no, abs(amt)); SELECT * FROM account_change WHERE acct_no=$xyz AND abs(amt)>=10000;
- Eponymous virtual tables, which are virtual tables that can be used by simply referring their module name, i.e., without running
CREATE VIRTUAL TABLE
. An example of this is thedbstat
virtual table, which provides low-level information about btree and overflow pages in a database file. - Full text search version 5 (FTS5), a virtual table module that allows to create a virtual table that can be later full-text searched. This is how you can populate a virtual table through FTS5:
CREATE VIRTUAL TABLE email USING fts5(sender, title, body);
SELECT * FROM email WHERE email MATCH 'fts5'; SELECT * FROM email WHERE email = 'fts5'; SELECT * FROM email('fts5');
Other changes worth mentioning are the addition of an optional list of column names when using CREATE_VIEW
, the possibility of referencing undefined tables when creating a VIEW
and having them checked at query-time.
For more details, check SQLite 3.9.0 and 3.9.1 release notes.