SQLite 3.9 Supports JSON, Indexes on Expressions and More

| by Sergio De Simone Follow 14 Followers on Oct 20, 2015. Estimated reading time: 1 minute |

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 the dbstat 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); 
    Once you have an FTS5 virtual table, you can search a term in it in three different ways:
    SELECT * FROM email WHERE email MATCH 'fts5'; SELECT * FROM email WHERE email = 'fts5'; SELECT * FROM email('fts5'); 
    This feature is still considered experimental.

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.

Rate this Article

Adoption Stage

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread


Login to InfoQ to interact with what matters most to you.

Recover your password...


Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.


More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.


Stay up-to-date

Set up your notifications and don't miss out on content that matters to you