| SQLite | |
|---|---|
Screenshot of sqlite3 command-line shell program | |
| Developer | D. Richard Hipp |
| Initial release | 17 August 2000; 25 years ago (2000-08-17) |
| Stable release | 3.51.0[1] |
| Repository | |
| Written in | C |
| Operating system | Cross-platform |
| Size | 699 KiB |
| Type | RDBMS (embedded) |
| License | Public domain[2] |
| Website | sqlite |
| SQLite Database File Format | |
|---|---|
| Filename extension | .sqlite, .sqlite3, .db, .db3, .s3db, .sl3 |
| Internet media type | application/vnd.sqlite3[3] |
| Magic number | 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 (zero-terminatedASCII "SQLite format 3") |
| Initial release | 2004-06-18 |
| Open format? | yes (Public Domain) |
| Website | sqlite |
SQLite (/ˌɛsˌkjuːˌɛlˈaɪt/ "S-Q-L-ite",[4][5]/ˈsiːkwəˌlaɪt/ "sequel-ite"[6]) is afree and open-sourcerelationaldatabase engine written in theC programming language. It is not a standalone app; rather, it is alibrary thatsoftware developers embed in theirapps. As such, it belongs to the family ofembedded databases. According to its developers, SQLite is the most widely deployed database engine, as it is used by several of the topweb browsers,operating systems,mobile phones, and otherembedded systems.[7]
Manyprogramming languages havebindings to the SQLite library. It generally followsPostgreSQL syntax, but does not enforcetype checking by default.[8][9] This means that one can, for example, insert a string into acolumn defined as an integer. Although it is a lightweight embedded database, SQLite implements most of theSQL standard and therelational model, includingtransactions andACID guarantees.[10] However, it omits many features implemented by other databases, such asmaterialized views and complete support fortriggers andALTER TABLE statements.[11]
D. Richard Hipp designed SQLite in the spring of 2000 while working forGeneral Dynamics on contract with theUnited States Navy.[12] Hipp was designing software used for adamage-control system aboardguided-missile destroyers; the damage-control system originally usedHP-UX with anInformixdatabase back-end. SQLite began as aTcl extension.[13]
In August 2000, version 1.0 of SQLite was released, with storage based ongdbm (GNU Database Manager). In September 2001, SQLite 2.0 replaced gdbm with a customB-tree implementation,[a] addingtransaction capability. In June 2004, SQLite 3.0 addedinternationalization,manifest typing, and other major improvements, partially funded byAmerica Online. In 2011, Hipp announced his plans to add aNoSQL interface to SQLite, as well as announcing UnQL, a functional superset ofSQL designed fordocument-oriented databases.[15]
SQLite is one of four formats recommended for long-term storage ofdatasets approved for use by theLibrary of Congress.[16][17][18]
SQLite was designed to allow the program to be operated without installing a database management system or requiring adatabase administrator. Unlikeclient–server database management systems, the SQLite engine has no standaloneprocesses with which the application program communicates. Instead, alinker integrates the SQLite library—statically ordynamically—into an application program which uses SQLite's functionality through simplefunction calls, reducinglatency in database operations; for simple queries with little concurrency, SQLiteperformance profits from avoiding the overhead ofinter-process communication.
Due to the serverless design, SQLite applications require less configuration than client–server databases. SQLite is calledzero-configuration[19] because configuration tasks such as service management, startup scripts, and password- orGRANT-based access control are unnecessary.Access control is handled through thefile-system permissions of the database file.[20] Databases in client–server systems usefile-system permissions that give access to the database files only to thedaemon process, which handles its locks internally, allowingconcurrent writes from several processes.
SQLite stores the entire database, consisting of definitions,tables, indices, and data, as a singlecross-platform file, allowing several processes orthreads to access the same database concurrently. It implements this simple design bylocking the database file during writing.[20] Write access may fail with anerror code, or it can be retried until a configurable timeout expires. SQLite read operations can bemultitasked, 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 aswrite-ahead logging (WAL) enables concurrent reads and writes.[21] Since SQLite has to rely on file-system locks, it is not the preferred choice for write-intensive deployments.[22]
SQLite usesPostgreSQL as a reference platform. "What would PostgreSQL do" is used to make sense of the SQL standard.[23][24] One major deviation is that, with the exception ofprimary keys, SQLite does not enforcetype checking; the type of a value is dynamic and not strictly constrained by theschema (although the schema will trigger a conversion when storing, if such a conversion is potentially reversible). SQLite strives to followPostel's rule.[25]
SQLite implements most of theSQL-92 standard for SQL, but lacks some features. For example, it only partially providestriggers and cannot write toviews (however, it provides INSTEAD OF triggers that provide this functionality). Its support ofALTER TABLE statements is limited.[26]
SQLite uses an unusualtype system for an SQL-compatible DBMS: instead of assigning atype to a column as in most SQL database systems, types are assigned to individual values; in language terms it isdynamically typed. Moreover, it isweakly typed in some of the same ways thatPerl is: one can insert astring into aninteger 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 thedata integrity mechanism provided by statically typed columns, although it can be emulated with constraints likeCHECK(typeof(x)='integer').[12] In 2021, support for static typing was added through STRICT tables, which enforce datatype constraints for columns.[27]
Tables normally include a hiddenrowid index column, which provides faster access.[28] If a table includes an INTEGER PRIMARY KEY column, SQLite will typically optimize it by treating it as an alias for therowid, causing the contents to be stored as astrictly 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.[29]
SQLite supports foreign key constraints,[30][31] although they are disabled by default and must be manually enabled with a PRAGMA statement.[32]
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.[33]
SQLite does not have fullUnicode support by default for backwards compatibility and due to the size of the Unicode tables, which are larger than the SQLite library.[34] Full support forUnicode case-conversions can be enabled through an optional extension.[35]
SQLite supportsfull-text search through its FTS5 loadable extension, which allows users to efficiently search for a keyword in a large number of documents similar to howsearch engines search webpages.[36]
SQLite includes support for working withJSON through itsjson1 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.[37]
In May 2025, the 25th‑anniversary release SQLite 3.50.0 introduced additional features, including new Unicode functions (unistr() andunistr_quote()), a new API (sqlite3_setlk_timeout()) for setting lock timeouts, improved command‑line tools and rsync utility enhancements, and optimized JSONB.[38]
The maximum supported size for an SQLite database file is 281 terabytes.[39]
SQLite's code is hosted withFossil, adistributed version control system that uses SQLite as a local cache for its non-relational database format, and SQLite's SQL as an implementation language.[40][41]
SQLite ispublic domain, but not "open-contribution", with the website stating "the project does not accept patches from people who have not submitted anaffidavit dedicating their contribution into the public domain."[42] Instead of acode of conduct, the founders have adopted acode of ethics based on theRule of St. Benedict.[43]
A standalonecommand-lineshell program calledsqlite3[44] 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 automatedregression 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 ofcode coverage. SQLite has four differenttest 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 proprietaryfuzzing engine.[45]
SQLite is included by default in:[13]
How do I pronounce the name of the product? I say S-Q-L-ite, like a mineral.
[ˌɛsˌkjuˌwəlˈaɪt̚]
[ˈsikwəˌlaɪt̚]
WAL provides more concurrency as readers do not block writers and a writer does not block readers. Reading and writing can proceed concurrently.
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.
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).
{{cite web}}:Missing or empty|title= (help)