SQLite explained

Logo Size:220px
Developer:D. Richard Hipp
Programming Language:C
Operating System:Cross-platform
Size:699 KiB
Genre:RDBMS (embedded)
License:Public domain[1]
SQLite Database File Format
Extension:.sqlite, .sqlite3, .db, .db3, .s3db, .sl3
Nomimecode:yes
Mime:application/vnd.sqlite3[2]
Magic:53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 (zero-terminated ASCII "SQLite format 3")
Released:2004-06-18
Open:yes (Public Domain)

SQLite ("S-Q-L-ite",[3] [4] "sequel-ite"[5]) is a free and open-source relational database engine written in the C programming language. It is not a standalone application; rather, it is a library that software developers embed in their applications. As such, it belongs to the family of embedded databases. According to its developers, SQLite is the most widely deployed database engine, as it is used by several of the top web browsers, operating systems, mobile phones, and other embedded systems.[6]

Many programming languages have bindings to the SQLite library. It generally follows PostgreSQL syntax, but does not enforce type checking by default.[7] [8] This means that one can, for example, insert a string into a column defined as an integer. Although it is a lightweight embedded database, SQLite implements most of the SQL standard and the relational model, including transactions and ACID guarantees.[9] However, it omits many features implemented by other databases, such as materialized views and complete support for triggers and ALTER TABLE statements.[10]

History

D. Richard Hipp designed SQLite in the spring of 2000 while working for General Dynamics on contract with the United States Navy.[11] Hipp was designing software used for a damage-control system aboard guided-missile destroyers; the damage-control system originally used HP-UX with an Informix database back-end. SQLite began as a Tcl extension.

In August 2000, version 1.0 of SQLite was released, with storage based on gdbm (GNU Database Manager). In September 2001, SQLite 2.0 replaced gdbm with a custom B-tree implementation, adding transaction capability. In June 2004, SQLite 3.0 added internationalization, manifest typing, and other major improvements, partially funded by America Online. In 2011, Hipp announced his plans to add a NoSQL interface to SQLite, as well as announcing UnQL, a functional superset of SQL designed for document-oriented databases.[12]

SQLite is one of four formats recommended for long-term storage of datasets approved for use by the Library of Congress.[13] [14] [15]

Design

SQLite was designed to allow the program to be operated without installing a database management system or requiring a database administrator. Unlike client–server database management systems, the SQLite engine has no standalone processes with which the application program communicates. Instead, a linker integrates the SQLite librarystatically or dynamicallyinto an application program which uses SQLite's functionality through simple function calls, reducing latency in database operations; for simple queries with little concurrency, SQLite performance profits from avoiding the overhead of inter-process communication.

Due to the serverless design, SQLite applications require less configuration than client–server databases. SQLite is called zero-configuration[16] because configuration tasks such as service management, startup scripts, and password- or GRANT-based access control are unnecessary. Access control is handled through the file-system permissions of the database file.[17] Databases in client–server systems use file-system permissions that give access to the database files only to the daemon process, which handles its locks internally, allowing concurrent writes from several processes.

SQLite stores the entire database, consisting of definitions, tables, indices, and data, as a single cross-platform file, allowing several processes or threads to access the same database concurrently. It implements this simple design by locking the database file during writing. Write access may fail with an error code, or it can be retried until a configurable timeout expires. SQLite read operations can be multitasked, though due to the serverless design, writes can only be performed sequentially. This concurrent access restriction does not apply to temporary tables, and it is relaxed in version 3.7 as write-ahead logging (WAL) enables concurrent reads and writes.[18] Since SQLite has to rely on file-system locks, it is not the preferred choice for write-intensive deployments.[19]

SQLite uses PostgreSQL as a reference platform. "What would PostgreSQL do" is used to make sense of the SQL standard.[20] [21] One major deviation is that, with the exception of primary keys, SQLite does not enforce type checking; the type of a value is dynamic and not strictly constrained by the schema (although the schema will trigger a conversion when storing, if such a conversion is potentially reversible). SQLite strives to follow Postel's rule.[22]

Features

SQLite implements most of the SQL-92 standard for SQL, but lacks some features. For example, it only partially provides triggers and cannot write to views (however, it provides INSTEAD OF triggers that provide this functionality). Its support of ALTER TABLE statements is limited.[23]

SQLite uses an unusual type system for an SQL-compatible DBMS: instead of assigning a type to a column as in most SQL database systems, types are assigned to individual values; in language terms it is dynamically typed. Moreover, it is weakly typed in some of the same ways that Perl is: one can insert a string into an integer column (although SQLite will try to convert the string to an integer first, if the column's preferred type is integer). This adds flexibility to columns, especially when bound to a dynamically typed scripting language. However, the technique is not portable to other SQL products. A common criticism is that SQLite's type system lacks the data integrity mechanism provided by statically typed columns, although it can be emulated with constraints like . In 2021, support for static typing was added through STRICT tables, which enforce datatype constraints for columns.[24]

Tables normally include a hidden rowid index column, which provides faster access.[25] If a table includes an INTEGER PRIMARY KEY column, SQLite will typically optimize it by treating it as an alias for the rowid, causing the contents to be stored as a strictly typed 64-bit signed integer and changing its behavior to be somewhat like an auto-incrementing column. SQLite includes an option to create a table without a rowid column, which can save disk space and improve lookup speed. WITHOUT ROWID tables are required to have a primary key.[26]

SQLite supports foreign key constraints,[27] [28] although they are disabled by default and must be manually enabled with a PRAGMA statement.[29]

Stored procedures are not supported; this is an explicit choice by the developers to favor simplicity, as the typical use case of SQLite is to be embedded inside a host application that can define its own procedures around the database.[30]

SQLite does not have full Unicode support by default for backwards compatibility and due to the size of the Unicode tables, which are larger than the SQLite library.[31] Full support for Unicode case-conversions can be enabled through an optional extension.[32]

SQLite supports full-text search through its FTS5 loadable extension, which allows users to efficiently search for a keyword in a large number of documents similar to how search engines search webpages.[33]

SQLite includes support for working with JSON through its json1 extension, which is enabled by default since 2021. SQLite's JSON functions can handle JSON5 syntax since 2023. In 2024, SQLite added support for JSONB, a binary serialization of SQLite's internal representation of JSON. Using JSONB allows applications to avoid having to parse the JSON text each time it is processed and saves a small amount of disk space.[34]

In May 2025, the 25th‑anniversary release SQLite 3.50.0 introduced additional features, including new Unicode functions (and), a new API for setting lock timeouts, improved command‑line tools and rsync utility enhancements, and optimized JSONB.[35]

The maximum supported size for an SQLite database file is 281 terabytes.[36]

Development and distribution

SQLite's code is hosted with Fossil, a distributed version control system that uses SQLite as a local cache for its non-relational database format, and SQLite's SQL as an implementation language.[37] [38]

SQLite is public domain, but not "open-contribution", with the website stating "the project does not accept patches from people who have not submitted an affidavit dedicating their contribution into the public domain."[39] Instead of a code of conduct, the founders have adopted a code of ethics based on the Rule of St. Benedict.[40]

A standalone command-line shell program called sqlite3[41] is provided in SQLite's distribution. It can be used to create a database, define tables, insert and change rows, run queries and manage an SQLite database file. It also serves as an example for writing applications that use the SQLite library.

SQLite uses automated regression testing prior to each release. Over 2 million tests are run as part of a release's verification. The SQLite library has 156,000 lines of source code, while all the test suites combined add up to 92 million lines of test code. SQLite's tests simulate a number of exceptional scenarios, such as power loss and I/O errors, in addition to testing the library's functionality. Starting with the August 10, 2009 release of SQLite 3.6.17, SQLite releases have 100% branch test coverage, one of the components of code coverage. SQLite has four different test harnesses: the original public-domain TCL tests, the proprietary C-language TH3 test suite, the SQL Logic Tests, which check SQLite against other SQL databases, and the dbsqlfuzz proprietary fuzzing engine.[42]

Notable uses

Operating systems

SQLite is included by default in:

Middleware

Web browsers

Web application frameworks

Others

See also

References

Sources

Further reading

External links

Notes and References

  1. Web site: SQLite Copyright . sqlite.org . May 17, 2010 .
  2. Web site: SQLite database file format media type at IANA . . . 2019-03-08 .
  3. The Changelog . 201 . Why SQLite succeeded as a database — Richard Hipp, creator of SQLite . 00:16:00 . How do I pronounce the name of the product? I say S-Q-L-ite, like a mineral. . 2025-04-11 . 2022-07-07 . https://web.archive.org/web/20220707033506/https://changelog.com/podcast/201 . live .
  4. D. Richard Hipp (presenter) . May 31, 2006 . An Introduction to SQLite . video . Google Inc. . March 23, 2010 . 00:01:14 . pronounced as /[ˌɛsˌkjuˌwəlˈaɪt̚]/.
  5. D. Richard Hipp (presenter) . May 31, 2006 . An Introduction to SQLite . . Google Inc. . March 23, 2010 . 00:48:15 . pronounced as /[ˈsikwəˌlaɪt̚]/ .
  6. Web site: Most Widely Deployed SQL Database Estimates . SQLite.org . May 11, 2011.
  7. Book: Owens, Michael . 2006 . Chapter 4: SQL . Gilmore . Jason . Thomas . Keir . Keir Thomas . The Definitive Guide to SQLite . https://books.google.com/books?id=VsZ5bUh0XAkC&pg=PA133 . D. Richard Hipp (foreword), Preston Hagar (technical reviewer) . . 133 . 978-1-59059-673-9 . 30 December 2014 . 24 November 2020 . https://web.archive.org/web/20201124002058/https://books.google.com/books?id=VsZ5bUh0XAkC&pg=PA133 . live .
  8. Web site: STRICT Tables . 2022-08-11 . 2022-08-07 . https://web.archive.org/web/20220807204905/https://sqlite.org/stricttables.html . live .
  9. Web site: Full-Featured SQL . January 24, 2025 . SQLite.
  10. Web site: SQL Features That SQLite Does Not Implement . January 24, 2025 . SQLite.
  11. Book: Owens, Michael . The Definitive Guide to SQLite . Introducing SQLite . 2006 . 1–16 . . 978-1-59059-673-9 . 10.1007/978-1-4302-0172-4_1.
  12. Web site: Interview: Richard Hipp on UnQL, a New Query Language for Document Databases . InfoQ . August 4, 2011 . October 5, 2011 . April 8, 2014 . https://web.archive.org/web/20140408215240/http://www.infoq.com/news/2011/08/UnQL . live .
  13. Web site: LoC Recommended Storage Format . sqlite.org . 2020-04-09 . 2020-04-23 . https://web.archive.org/web/20200423212849/https://sqlite.org/locrsf.html . live .
  14. Web site: SQLite, Version 3 . 2017-03-28 . www.loc.gov . 2020-04-09 . 2020-05-11 . https://web.archive.org/web/20200511194518/https://www.loc.gov/preservation/digital/formats/fdd/fdd000461.shtml . live .
  15. Web site: Recommended Formats Statement – datasets/databases . Library of Congress . 2020-04-09 . 2018-08-22 . https://web.archive.org/web/20180822113435/https://www.loc.gov/preservation/resources/rfs/data.html . live .
  16. Web site: SQLite Is A Zero-Configuration Database . August 3, 2015 . SQLite.org . May 2, 2024 . https://web.archive.org/web/20240502210736/https://sqlite.org/zeroconf.html . live .
  17. Web site: SQLite . January 25, 2025 . ClickHouse Docs.
  18. Web site: Write Ahead Logging in SQLite 3.7 . SQLite.org . September 3, 2011 . WAL provides more concurrency as readers do not block writers and a writer does not block readers. Reading and writing can proceed concurrently. . May 2, 2024 . https://web.archive.org/web/20240502210711/https://sqlite.org/wal.html . live .
  19. Web site: Appropriate Uses For SQLite . 2015-09-03 . SQLite.org . 2024-05-02 . https://web.archive.org/web/20240502210713/https://sqlite.org/whentouse.html . live .
  20. Web site: Berkus . Josh . PGCon 2014: Clustering and VODKA . Lwn.net . 4 June 2014 . 2017-01-06 . 2015-06-29 . https://web.archive.org/web/20150629195442/https://lwn.net/Articles/601144/ . live .
  21. Web site: PGCon2014: SQLite: Protégé of PostgreSQL . Pgcon.org . 20 September 2015 . 2017-01-06 . 2014-12-30 . https://web.archive.org/web/20141230193958/http://www.pgcon.org/2014/schedule/events/736.en.html . live .
  22. Web site: SQLite: StrictMode . live . https://web.archive.org/web/20160304115940/https://sqlite.org/src/wiki?name=StrictMode . March 4, 2016 . September 3, 2015 . Sqlite.org.
  23. Web site: Release History of SQLite. 2021-03-22. 2021-03-16. https://web.archive.org/web/20210316043517/https://sqlite.org/changes.html. live.
  24. Web site: STRICT Tables . January 24, 2025 . SQLite.
  25. Web site: SQL As Understood By SQLite . SQLite . 21 May 2018 . Searching for a record with a specific rowid, or for all records with rowids within a specified range is around twice as fast as a similar search made by specifying any other PRIMARY KEY or indexed value. . 21 May 2018 . https://web.archive.org/web/20180521104530/https://sqlite.org/lang_createtable.html#rowid . live .
  26. Web site: Clustered Indexes and the WITHOUT ROWID Optimization . January 24, 2025 . SQLite.
  27. Book: Karwin, Bill . Carter . Jacquelyn . May 2010 . SQL Antipatterns: Avoiding the Pitfalls of Database Programming . The Pragmatic Bookshelf . 978-1-934356-55-5 . 70 . Sometimes you're forced to use a database brand that doesn't support foreign key constraints (for example MySQL's MyISAM storage engine or SQLite prior to version 3.6.19)..
  28. Web site: SQLite Release 3.6.19 On 2009-10-14. sqlite.org. 2020-10-15. 2020-10-29. https://web.archive.org/web/20201029060401/http://sqlite.org/releaselog/3_6_19.html. live.
  29. Web site: SQLite Foreign Key Support . January 24, 2025 . SQLite.
  30. Source: developers' comments on SQLite forum
  31. Web site: Quirks, Caveats, and Gotchas In SQLite . January 24, 2025 . SQLite.
  32. Web site: Case-insensitive matching of Unicode characters does not work . SQLite Frequently Asked Questions . 2015-09-03 . 2015-09-05 . https://web.archive.org/web/20150905054749/https://sqlite.org/faq.html#q18 . live .
  33. Web site: SQLite FTS5 Extension . January 24, 2025 . SQLite.
  34. Web site: JSON Functions And Operators . January 24, 2025 . SQLite.
  35. Web site: SQLite Release 3.50.0 On 2025-05-29 . November 3, 2025 . SQLite.
  36. Web site: Limits In SQLite. SQLite.org. 2022-09-19. 2021-11-07. https://web.archive.org/web/20211107064937/https://sqlite.org/limits.html. live.
  37. Web site: Thoughts On The Design Of The Fossil DVCS. Fossil-scm.org. July 12, 2017. October 14, 2022. October 13, 2022. https://web.archive.org/web/20221013234319/https://www.fossil-scm.org/home/doc/trunk/www/theory1.wiki. live.
  38. Web site: Fossil: Fossil Performance. Fossil-scm.org. August 23, 2009. September 12, 2009. October 9, 2009. https://web.archive.org/web/20091009054952/http://www.fossil-scm.org/index.html/doc/tip/www/stats.wiki. live.
  39. Web site: SQLite Copyright . 2024-03-06 . sqlite.org . 2024-03-15 . https://web.archive.org/web/20240315172355/https://sqlite.org/copyright.html . live .
  40. Web site: Code Of Ethics . 2024-03-06 . sqlite.org . 2024-02-19 . https://web.archive.org/web/20240219225117/https://sqlite.org/codeofethics.html . live .
  41. Web site: Command Line Shell For SQLite. Sqlite.org. October 14, 2022. October 6, 2022. https://web.archive.org/web/20221006104551/https://sqlite.org/cli.html. live.
  42. Web site: How SQLite Is Tested . live . https://web.archive.org/web/20091006224147/https://sqlite.org/testing.html . October 6, 2009 . September 12, 2009 . SQLite.org.
  43. Web site: To use the version of SQLite that is installed with Windows. 20 October 2022. 31 March 2022. 31 March 2022. https://web.archive.org/web/20220331170828/https://docs.microsoft.com/en-us/windows/uwp/data-access/sqlite-databases#to-use-the-version-of-sqlite-that-is-installed-with-windows. live.
  44. Web site: Home . System.Data.SQLite . 2016-12-30 . 2017-01-06 . 2014-07-13 . https://web.archive.org/web/20140713080835/http://system.data.sqlite.org/index.html/doc/trunk/www/index.wiki . live .
  45. Web site: SQLite ODBC Driver . Ch-werner.de . 2016-12-01 . 2017-01-06 . 2014-06-26 . https://web.archive.org/web/20140626165719/http://www.ch-werner.de/sqliteodbc/ . live .
  46. Web site: Using SQLite Database with OpenOffice.org : Version 2.0 . Documentation.openoffice.org . 2017-01-06 . 2011-09-28 . https://web.archive.org/web/20110928073029/http://documentation.openoffice.org/HOW_TO/data_source/SQLite.pdf . live .
  47. Web site: sqlite â€” Sqlite Wrappers. February 7, 2009. SQLite.org. February 7, 2009. February 5, 2009. https://web.archive.org/web/20090205225756/http://sqlite.org/cvstrac/wiki?p=SqliteWrappers. live.
  48. Web site: sqlite3 WebAssembly & JavaScript Documentation Index. SQLite. 2023-05-08. 2024-05-02. https://web.archive.org/web/20240502210710/https://sqlite.org/wasm/doc/trunk/index.md. live.
  49. Web site: Location of Google Chrome history . www.foxtonforensics.com . 2020-10-06 . 2020-10-06 . 2023-02-28 . https://web.archive.org/web/20230228184524/https://www.foxtonforensics.com/browser-history-examiner/chrome-history-location . live .
  50. Web site: SQLite Manager :: Add-ons for Firefox . Addons.mozilla.org . 2015-02-28 . 2017-01-06 . dead . https://web.archive.org/web/20170102010658/https://addons.mozilla.org/en-US/firefox/addon/sqlite-manager/ . 2017-01-02.
  51. Web site: SQLite Manager – Get this Extension for Firefox (en-US) . Addons.mozilla.org . 2018-07-24 . 2018-10-05 . 2018-10-05 . https://web.archive.org/web/20181005112443/https://addons.mozilla.org/en-US/firefox/addon/sqlite-manager-webext/ . live .
  52. Web site: SQLite Reader – Get this Extension for Firefox (en-US) . Addons.mozilla.org . 2018-09-01 . 2018-10-05 . 2018-10-05 . https://web.archive.org/web/20181005112536/https://addons.mozilla.org/en-US/firefox/addon/sql-reader/ . live .
  53. Web site: Well-Known Users Of SQLite. August 5, 2015. SQLite. July 11, 2015. https://web.archive.org/web/20150711135311/https://sqlite.org/famous.html. live.
  54. Web site: Using SQL to find my best photo of a pelican according to Apple Photo. May 23, 2020. Simon Willison’s Weblog. May 22, 2020. https://web.archive.org/web/20200522181550/https://simonwillison.net/2020/May/21/dogsheep-photos/. live.
  55. Web site: Audacity 3.0.0 Released. March 17, 2021. 17 March 2021. 14 August 2023. https://web.archive.org/web/20230814021313/https://www.audacityteam.org/audacity-3-0-0-released/. dead.
  56. Skype client using SQLite?. https://web.archive.org/web/20071117061133/https://www.mail-archive.com/sqlite-users%40sqlite.org/msg27326.html. 2007-11-17. Jeremy. Hinegardner. sqlite-users. August 28, 2007. June 14, 2010.
  57. Web site: WhatsApp in Plain Sight: Where and How You Can Collect Forensic Artifacts . www.group-ib.com . 29 September 2025 . 7 November 2019.
  58. Web site: Addendum: Project Years of Expenses With Quicken for Mac. The Frugal Vagabond.
  59. Web site: sqlite3 — DB-API 2.0 interface for SQLite databases. The Python Standard Library Documentation.