Index: Doc/Extra/Core/lang.html ================================================================== --- Doc/Extra/Core/lang.html +++ Doc/Extra/Core/lang.html @@ -1,142 +1,80 @@ + + Query Language Understood by SQLite - - -
- +
- -
-
Small. Fast. Reliable.
Choose any three.
- - - - -
- +

SQL As Understood By SQLite

SQLite understands most of the standard SQL @@ -151,28 +89,102 @@

The following syntax documentation topics are available:

  • ON CONFLICT clause
  • PRAGMA
  • REINDEX
  • RELEASE SAVEPOINT
  • REPLACE
  • ROLLBACK TRANSACTION
  • SAVEPOINT
  • SELECT
  • UPDATE
  • VACUUM
  • WITH clause
  • + +
    + +

The routines sqlite3_prepare_v2(), sqlite3_prepare(), sqlite3_prepare16(), sqlite3_prepare16_v2(), sqlite3_exec(), and sqlite3_get_table() accept an SQL statement list (sql-stmt-list) which is a semicolon-separated list of statements.

-

sql-stmt-list:

+

sql-stmt-list:

syntax diagram sql-stmt-list -
+

Each SQL statement in the statement list is an instance of the following:

-

sql-stmt:

+

sql-stmt:

syntax diagram sql-stmt -
+ Index: Doc/Extra/Core/lang_aggfunc.html ================================================================== --- Doc/Extra/Core/lang_aggfunc.html +++ Doc/Extra/Core/lang_aggfunc.html @@ -1,143 +1,82 @@ + + SQLite Query Language: Aggregate Functions - - -
- +
- -
-
Small. Fast. Reliable.
Choose any three.
- - - - -
- -

SQL As Understood By SQLite

[Top]

Aggregate Functions

+
+

SQL As Understood By SQLite

[Top]

Aggregate Functions

+

The aggregate functions shown below are available by default. Additional aggregate functions written in C may be added using the sqlite3_create_function() @@ -150,53 +89,105 @@ For example, the function "count(distinct X)" will return the number of distinct values of column X instead of the total number of non-null values in column X.

- - -
-avg(X) + +
+ +
+
+ +

avg(X)

The avg() function returns the average value of all non-NULL X within a group. String and BLOB values that do not look like numbers are interpreted as 0. The result of avg() is always a floating point value as long as at there is at least one non-NULL input even if all inputs are integers. The result of avg() is NULL if and only if there are no non-NULL inputs. -

-count(X)
count(*)
+ + +

count(X)
count(*)

The count(X) function returns a count of the number of times that X is not NULL in a group. The count(*) function (with no arguments) returns the total number of rows in the group. -

-group_concat(X)
group_concat(X,Y)
+ + +

group_concat(X)
group_concat(X,Y)

The group_concat() function returns a string which is the concatenation of all non-NULL values of X. If parameter Y is present then it is used as the separator between instances of X. A comma (",") is used as the separator if Y is omitted. The order of the concatenated elements is arbitrary. -

-max(X) + + +

max(X)

The max() aggregate function returns the maximum value of all values in the group. The maximum value is the value that would be returned last in an ORDER BY on the same column. Aggregate max() returns NULL if and only if there are no non-NULL values in the group. -

-min(X) + + +

min(X)

The min() aggregate function returns the minimum non-NULL value of all values in the group. The minimum value is the first non-NULL value that would appear in an ORDER BY of the column. Aggregate min() returns NULL if and only if there are no non-NULL values in the group. -

-sum(X)
total(X)
+ + +

sum(X)
total(X)

The sum() and total() aggregate functions return sum of all non-NULL values in the group. If there are no non-NULL input rows then sum() returns NULL but total() returns 0.0. NULL is not normally a helpful result for the sum of no rows @@ -214,9 +205,8 @@

Sum() will throw an "integer overflow" exception if all inputs are integers or NULL and an integer overflow occurs at any point during the computation. Total() never throws an integer overflow. -

- + + Index: Doc/Extra/Core/lang_altertable.html ================================================================== --- Doc/Extra/Core/lang_altertable.html +++ Doc/Extra/Core/lang_altertable.html @@ -1,242 +1,180 @@ + + SQLite Query Language: ALTER TABLE - - -
- +
- -
-
Small. Fast. Reliable.
Choose any three.
- - - - -
- -

SQL As Understood By SQLite

[Top]

ALTER TABLE

alter-table-stmt: +

+

SQL As Understood By SQLite

[Top]

ALTER TABLE

alter-table-stmt:

-
+
syntax diagram alter-table-stmt

column-def:

-
+

ordering-term:

- +

result-column:

- +

table-or-subquery:

- - - + + +

foreign-key-clause:

- +

literal-value:

- +

signed-number:

- - + +

type-name:

- - - + + + +

SQLite supports a limited subset of ALTER TABLE. The ALTER TABLE command in SQLite allows the user to rename a table or to add a new column to an existing table. Index: Doc/Extra/Core/lang_analyze.html ================================================================== --- Doc/Extra/Core/lang_analyze.html +++ Doc/Extra/Core/lang_analyze.html @@ -1,147 +1,85 @@ + + SQLite Query Language: ANALYZE - - -

- +
- -
-
Small. Fast. Reliable.
Choose any three.
- - - - -
- -

SQL As Understood By SQLite

[Top]

ANALYZE

analyze-stmt: +

+

SQL As Understood By SQLite

[Top]

ANALYZE

analyze-stmt:

-
+
syntax diagram analyze-stmt -
+

The ANALYZE command gathers statistics about tables and indices and stores the collected information in internal tables of the database where the query optimizer can Index: Doc/Extra/Core/lang_attach.html ================================================================== --- Doc/Extra/Core/lang_attach.html +++ Doc/Extra/Core/lang_attach.html @@ -1,217 +1,155 @@ + + SQLite Query Language: ATTACH DATABASE - - -

- +
- -
-
Small. Fast. Reliable.
Choose any three.
- - - - -
- -

SQL As Understood By SQLite

[Top]

ATTACH DATABASE

attach-stmt: +

+

SQL As Understood By SQLite

[Top]

ATTACH DATABASE

attach-stmt:

-
+
syntax diagram attach-stmt

expr:

-

select-stmt:

-

join-clause:

- + +

ordering-term:

- +

result-column:

- +

table-or-subquery:

- - + +

type-name:

- - - + + + +

The ATTACH DATABASE statement adds another database file to the current database connection. Database files that were previously attached can be removed using Index: Doc/Extra/Core/lang_comment.html ================================================================== --- Doc/Extra/Core/lang_comment.html +++ Doc/Extra/Core/lang_comment.html @@ -1,147 +1,85 @@ + + SQLite Query Language: comment - - -

- +
- -
-
Small. Fast. Reliable.
Choose any three.
- - - - -
- -

SQL As Understood By SQLite

[Top]

comment

comment-syntax: +

+

SQL As Understood By SQLite

[Top]

comment

comment-syntax:

-
+
syntax diagram comment-syntax -
+

Comments are not SQL commands, but can occur within the text of SQL queries passed to sqlite3_prepare_v2() and related interfaces. Comments are treated as whitespace by the parser. Index: Doc/Extra/Core/lang_conflict.html ================================================================== --- Doc/Extra/Core/lang_conflict.html +++ Doc/Extra/Core/lang_conflict.html @@ -1,147 +1,85 @@ + + SQLite Query Language: ON CONFLICT clause - - -

- +
- -
-
Small. Fast. Reliable.
Choose any three.
- - - - -
- -

SQL As Understood By SQLite

[Top]

ON CONFLICT clause

conflict-clause: +

+

SQL As Understood By SQLite

[Top]

ON CONFLICT clause

conflict-clause:

-
+
syntax diagram conflict-clause -
+

The ON CONFLICT clause is not a separate SQL command. It is a non-standard clause that can appear in many other SQL commands. It is given its own section in this document because it is not Index: Doc/Extra/Core/lang_corefunc.html ================================================================== --- Doc/Extra/Core/lang_corefunc.html +++ Doc/Extra/Core/lang_corefunc.html @@ -1,226 +1,258 @@ + + SQLite Query Language: Core Functions - - -

- +
- -
-
Small. Fast. Reliable.
Choose any three.
- - - - -
- -

SQL As Understood By SQLite

[Top]

Core Functions

+
+

SQL As Understood By SQLite

[Top]

Core Functions

The core functions shown below are available by default. Date & Time functions, aggregate functions, and JSON functions are documented separately. An application may define additional functions written in C and added to the database engine using the sqlite3_create_function() API.

- - -
-abs(X) + +
+ +
+
+ +

abs(X)

The abs(X) function returns the absolute value of the numeric argument X. Abs(X) returns NULL if X is NULL. Abs(X) returns 0.0 if X is a string or blob that cannot be converted to a numeric value. If X is the integer -9223372036854775808 then abs(X) throws an integer overflow error since there is no equivalent positive 64-bit two complement value. -

-changes() + + +

changes()

The changes() function returns the number of database rows that were changed or inserted or deleted by the most recently completed INSERT, DELETE, or UPDATE statement, exclusive of statements in lower-level triggers. The changes() SQL function is a wrapper around the sqlite3_changes() C/C++ function and hence follows the same rules for counting changes. -

-char(X1,X2,...,XN) + + +

char(X1,X2,...,XN)

The char(X1,X2,...,XN) function returns a string composed of characters having the unicode code point values of integers X1 through XN, respectively. -

-coalesce(X,Y,...) + + +

coalesce(X,Y,...)

The coalesce() function returns a copy of its first non-NULL argument, or NULL if all arguments are NULL. Coalesce() must have at least 2 arguments. -

-glob(X,Y) + + +

glob(X,Y)

The glob(X,Y) function is equivalent to the expression "Y GLOB X". Note that the X and Y arguments are reversed in the glob() function relative to the infix GLOB operator. If the sqlite3_create_function() interface is used to override the glob(X,Y) function with an alternative implementation then the GLOB operator will invoke the alternative implementation. -

-ifnull(X,Y) + + +

hex(X)

+ The hex() function interprets its argument as a BLOB and returns + a string which is the upper-case hexadecimal rendering of the content of + that blob. +

+ +

ifnull(X,Y)

The ifnull() function returns a copy of its first non-NULL argument, or NULL if both arguments are NULL. Ifnull() must have exactly 2 arguments. The ifnull() function is equivalent to coalesce() with two arguments. -

-instr(X,Y) + + +

instr(X,Y)

The instr(X,Y) function finds the first occurrence of string Y within string X and returns the number of prior characters plus 1, or 0 if Y is nowhere found within X. Or, if X and Y are both BLOBs, then instr(X,Y) returns one more than the number bytes prior to the first occurrence of Y, or 0 if Y does not occur anywhere within X. If both arguments X and Y to instr(X,Y) are non-NULL and are not BLOBs then both are interpreted as strings. If either X or Y are NULL in instr(X,Y) then the result is NULL. -

-hex(X) - The hex() function interprets its argument as a BLOB and returns - a string which is the upper-case hexadecimal rendering of the content of - that blob. -
-last_insert_rowid() + + +

last_insert_rowid()

The last_insert_rowid() function returns the ROWID of the last row insert from the database connection which invoked the function. The last_insert_rowid() SQL function is a wrapper around the sqlite3_last_insert_rowid() C/C++ interface function. -

-length(X) + + +

length(X)

For a string value X, the length(X) function returns the number of characters (not bytes) in X prior to the first NUL character. Since SQLite strings do not normally contain NUL characters, the length(X) function will usually return the total number of characters in the string X. For a blob value X, length(X) returns the number of bytes in the blob. If X is NULL then length(X) is NULL. If X is numeric then length(X) returns the length of a string representation of X. -

-like(X,Y)
like(X,Y,Z)
+ + +

like(X,Y)
like(X,Y,Z)

The like() function is used to implement the "Y LIKE X [ESCAPE Z]" expression. If the optional ESCAPE clause is present, then the like() function is invoked with three arguments. Otherwise, it is invoked with two arguments only. Note that the X and Y parameters are @@ -230,12 +262,13 @@ LIKE operator. When overriding the like() function, it may be important to override both the two and three argument versions of the like() function. Otherwise, different code may be called to implement the LIKE operator depending on whether or not an ESCAPE clause was specified. -

-likelihood(X,Y) + + +

likelihood(X,Y)

The likelihood(X,Y) function returns argument X unchanged. The value Y in likelihood(X,Y) must be a floating point constant between 0.0 and 1.0, inclusive. The likelihood(X) function is a no-op that the code generator optimizes away so that it consumes no CPU cycles during run-time @@ -243,22 +276,24 @@ The purpose of the likelihood(X,Y) function is to provide a hint to the query planner that the argument X is a boolean that is true with a probability of approximately Y. The unlikely(X) function is short-hand for likelihood(X,0.0625). The likely(X) function is short-hand for likelihood(X,0.9375). -

-likely(X) + + +

likely(X)

The likely(X) function returns the argument X unchanged. The likely(X) function is a no-op that the code generator optimizes away so that it consumes no CPU cycles at run-time (that is, during calls to sqlite3_step()). The purpose of the likely(X) function is to provide a hint to the query planner that the argument X is a boolean value that is usually true. The likely(X) function is equivalent to likelihood(X,0.9375). See also: unlikely(X). -

-load_extension(X)
load_extension(X,Y)
+ + +

load_extension(X)
load_extension(X,Y)

The load_extension(X,Y) function loads SQLite extensions out of the shared library file named X using the entry point Y. The result of load_extension() is always a NULL. If Y is omitted then the default entry point name is used. The load_extension() function raises an exception if the extension fails to load or initialize correctly. @@ -272,35 +307,39 @@ changes or deletes functions or collating sequences, use the sqlite3_load_extension() C-language API.

For security reasons, extension loaded is turned off by default and must be enabled by a prior call to sqlite3_enable_load_extension().

-
-lower(X) + + +

lower(X)

The lower(X) function returns a copy of string X with all ASCII characters converted to lower case. The default built-in lower() function works for ASCII characters only. To do case conversions on non-ASCII characters, load the ICU extension. -

-ltrim(X)
ltrim(X,Y)
+ + +

ltrim(X)
ltrim(X,Y)

The ltrim(X,Y) function returns a string formed by removing any and all characters that appear in Y from the left side of X. If the Y argument is omitted, ltrim(X) removes spaces from the left side of X. -

-max(X,Y,...) + + +

max(X,Y,...)

The multi-argument max() function returns the argument with the maximum value, or return NULL if any argument is NULL. The multi-argument max() function searches its arguments from left to right for an argument that defines a collating function and uses that collating function for all string comparisons. If none of the arguments to max() define a collating function, then the BINARY collating function is used. Note that max() is a simple function when it has 2 or more arguments but operates as an aggregate function if given only a single argument. -

-min(X,Y,...) + + +

min(X,Y,...)

The multi-argument min() function returns the argument with the minimum value. The multi-argument min() function searches its arguments from left to right for an argument that defines a collating function and uses that collating function for all string comparisons. If none of the arguments to min() @@ -307,44 +346,49 @@ define a collating function, then the BINARY collating function is used. Note that min() is a simple function when it has 2 or more arguments but operates as an aggregate function if given only a single argument. -

-nullif(X,Y) + + +

nullif(X,Y)

The nullif(X,Y) function returns its first argument if the arguments are different and NULL if the arguments are the same. The nullif(X,Y) function searches its arguments from left to right for an argument that defines a collating function and uses that collating function for all string comparisons. If neither argument to nullif() defines a collating function then the BINARY is used. -

-printf(FORMAT,...) + + +

printf(FORMAT,...)

The printf(FORMAT,...) SQL function works like the sqlite3_mprintf() C-language function and the printf() function from the standard C library. The first argument is a format string that specifies how to construct the output string using values taken from subsequent arguments. If the FORMAT argument is missing or NULL then the result is NULL. The %n format is silently ignored and does not consume an argument. The %p format is an alias for %X. The %z format is interchangeable with %s. If there are too few arguments in the argument list, missing arguments are assumed to have a NULL value, which is translated into 0 or 0.0 for numeric formats or an empty string for %s. -

-quote(X) + + +

quote(X)

The quote(X) function returns the text of an SQL literal which is the value of its argument suitable for inclusion into an SQL statement. Strings are surrounded by single-quotes with escapes on interior quotes as needed. BLOBs are encoded as hexadecimal literals. Strings with embedded NUL characters cannot be represented as string literals in SQL and hence the returned string literal is truncated prior to the first NUL. -

-random() + + +

random()

The random() function returns a pseudo-random integer between -9223372036854775808 and +9223372036854775807. -

-randomblob(N) + + +

randomblob(N)

The randomblob(N) function return an N-byte blob containing pseudo-random bytes. If N is less than 1 then a 1-byte random blob is returned.

Hint: applications can generate globally unique identifiers using this function together with hex() and/or @@ -352,66 +396,75 @@

hex(randomblob(16))

lower(hex(randomblob(16)))
-
-replace(X,Y,Z) + + +

replace(X,Y,Z)

The replace(X,Y,Z) function returns a string formed by substituting string Z for every occurrence of string Y in string X. The BINARY collating sequence is used for comparisons. If Y is an empty string then return X unchanged. If Z is not initially a string, it is cast to a UTF-8 string prior to processing. -

-round(X)
round(X,Y)
+ + +

round(X)
round(X,Y)

The round(X,Y) function returns a floating-point value X rounded to Y digits to the right of the decimal point. If the Y argument is omitted, it is assumed to be 0. -

-rtrim(X)
rtrim(X,Y)
+ + +

rtrim(X)
rtrim(X,Y)

The rtrim(X,Y) function returns a string formed by removing any and all characters that appear in Y from the right side of X. If the Y argument is omitted, rtrim(X) removes spaces from the right side of X. -

-soundex(X) + + +

soundex(X)

The soundex(X) function returns a string that is the soundex encoding of the string X. The string "?000" is returned if the argument is NULL or contains no ASCII alphabetic characters. This function is omitted from SQLite by default. It is only available if the SQLITE_SOUNDEX compile-time option is used when SQLite is built. -

-sqlite_compileoption_get(N) + + +

sqlite_compileoption_get(N)

The sqlite_compileoption_get() SQL function is a wrapper around the sqlite3_compileoption_get() C/C++ function. This routine returns the N-th compile-time option used to build SQLite or NULL if N is out of range. See also the compile_options pragma. -

-sqlite_compileoption_used(X) + + +

sqlite_compileoption_used(X)

The sqlite_compileoption_used() SQL function is a wrapper around the sqlite3_compileoption_used() C/C++ function. When the argument X to sqlite_compileoption_used(X) is a string which is the name of a compile-time option, this routine returns true (1) or false (0) depending on whether or not that option was used during the build. -

-sqlite_source_id() + + +

sqlite_source_id()

The sqlite_source_id() function returns a string that identifies the specific version of the source code that was used to build the SQLite library. The string returned by sqlite_source_id() is the date and time that the source code was checked in followed by the SHA1 hash for that check-in. This function is an SQL wrapper around the sqlite3_sourceid() C interface. -

-sqlite_version() + + +

sqlite_version()

The sqlite_version() function returns the version string for the SQLite library that is running. This function is an SQL wrapper around the sqlite3_libversion() C-interface. -

-substr(X,Y,Z)
substr(X,Y)
+ + +

substr(X,Y,Z)
substr(X,Y)

The substr(X,Y,Z) function returns a substring of input string X that begins with the Y-th character and which is Z characters long. If Z is omitted then substr(X,Y) returns all characters through the end of the string X beginning with the Y-th. The left-most character of X is number 1. If Y is negative @@ -418,52 +471,58 @@ then the first character of the substring is found by counting from the right rather than the left. If Z is negative then the abs(Z) characters preceding the Y-th character are returned. If X is a string then characters indices refer to actual UTF-8 characters. If X is a BLOB then the indices refer to bytes. -

-total_changes() + + +

total_changes()

The total_changes() function returns the number of row changes caused by INSERT, UPDATE or DELETE statements since the current database connection was opened. This function is a wrapper around the sqlite3_total_changes() C/C++ interface. -

-trim(X)
trim(X,Y)
+ + +

trim(X)
trim(X,Y)

The trim(X,Y) function returns a string formed by removing any and all characters that appear in Y from both ends of X. If the Y argument is omitted, trim(X) removes spaces from both ends of X. -

-typeof(X) + + +

typeof(X)

The typeof(X) function returns a string that indicates the datatype of the expression X: "null", "integer", "real", "text", or "blob". -

-unlikely(X) + + +

unicode(X)

+ The unicode(X) function returns the numeric unicode code point corresponding to + the first character of the string X. If the argument to unicode(X) is not a string + then the result is undefined. +

+ +

unlikely(X)

The unlikely(X) function returns the argument X unchanged. The unlikely(X) function is a no-op that the code generator optimizes away so that it consumes no CPU cycles at run-time (that is, during calls to sqlite3_step()). The purpose of the unlikely(X) function is to provide a hint to the query planner that the argument X is a boolean value that is usually not true. The unlikely(X) function is equivalent to likelihood(X, 0.0625). -

-unicode(X) - The unicode(X) function returns the numeric unicode code point corresponding to - the first character of the string X. If the argument to unicode(X) is not a string - then the result is undefined. -
-upper(X) + + +

upper(X)

The upper(X) function returns a copy of input string X in which all lower-case ASCII characters are converted to their upper-case equivalent. -

-zeroblob(N) + + +

zeroblob(N)

The zeroblob(N) function returns a BLOB consisting of N bytes of 0x00. SQLite manages these zeroblobs very efficiently. Zeroblobs can be used to reserve space for a BLOB that is later written using incremental BLOB I/O. This SQL function is implemented using the sqlite3_result_zeroblob() routine from the C/C++ interface. -

- + + Index: Doc/Extra/Core/lang_createindex.html ================================================================== --- Doc/Extra/Core/lang_createindex.html +++ Doc/Extra/Core/lang_createindex.html @@ -1,222 +1,160 @@ + + SQLite Query Language: CREATE INDEX - - -
- +
- -
-
Small. Fast. Reliable.
Choose any three.
- - - - -
- -

SQL As Understood By SQLite

[Top]

CREATE INDEX

create-index-stmt: +

+

SQL As Understood By SQLite

[Top]

CREATE INDEX

create-index-stmt:

-
+
syntax diagram create-index-stmt

expr:

-

select-stmt:

-

join-clause:

- +
+

ordering-term:

- +

result-column:

- +

table-or-subquery:

- - + +

type-name:

- - + + +

indexed-column:

- - + +

The CREATE INDEX command consists of the keywords "CREATE INDEX" followed by the name of the new index, the keyword "ON", the name of a previously created table that is to be indexed, and a parenthesized list of table column Index: Doc/Extra/Core/lang_createtable.html ================================================================== --- Doc/Extra/Core/lang_createtable.html +++ Doc/Extra/Core/lang_createtable.html @@ -1,312 +1,250 @@ + + SQLite Query Language: CREATE TABLE - - -

- +
- -
-
Small. Fast. Reliable.
Choose any three.
- - - - -
- -

SQL As Understood By SQLite

[Top]

CREATE TABLE

create-table-stmt: +

+

SQL As Understood By SQLite

[Top]

CREATE TABLE

create-table-stmt:

-
+
syntax diagram create-table-stmt

column-def:

-

foreign-key-clause:

- +

literal-value:

- +

signed-number:

- - + +

type-name:

- - + + +

select-stmt:

- + +

table-constraint:

- - + + +

The "CREATE TABLE" command is used to create a new table in an SQLite database. A CREATE TABLE command specifies the following attributes of the new table: Index: Doc/Extra/Core/lang_createtrigger.html ================================================================== --- Doc/Extra/Core/lang_createtrigger.html +++ Doc/Extra/Core/lang_createtrigger.html @@ -1,272 +1,210 @@ + + SQLite Query Language: CREATE TRIGGER - - -

- +
- -
-
Small. Fast. Reliable.
Choose any three.
- - - - -
- -

SQL As Understood By SQLite

[Top]

CREATE TRIGGER

create-trigger-stmt: +

+

SQL As Understood By SQLite

[Top]

CREATE TRIGGER

create-trigger-stmt:

-
+
syntax diagram create-trigger-stmt

delete-stmt:

- +
+
+

expr:

- + + +

insert-stmt:

- + + +

select-stmt:

- + +

update-stmt:

- - + + + +

The CREATE TRIGGER statement is used to add triggers to the database schema. Triggers are database operations that are automatically performed when a specified database event @@ -468,13 +406,13 @@

The RAISE() function

A special SQL function RAISE() may be used within a trigger-program, with the following syntax

-

raise-function:

+

raise-function:

syntax diagram raise-function -
+

When one of RAISE(ROLLBACK,...), RAISE(ABORT,...) or RAISE(FAIL,...) is called during trigger-program execution, the specified ON CONFLICT processing is performed Index: Doc/Extra/Core/lang_createview.html ================================================================== --- Doc/Extra/Core/lang_createview.html +++ Doc/Extra/Core/lang_createview.html @@ -1,217 +1,155 @@ + + SQLite Query Language: CREATE VIEW - - -

- +
- -
-
Small. Fast. Reliable.
Choose any three.
- - - - -
- -

SQL As Understood By SQLite

[Top]

CREATE VIEW

create-view-stmt: +

+

SQL As Understood By SQLite

[Top]

CREATE VIEW

create-view-stmt:

-
+
syntax diagram create-view-stmt

select-stmt:

-

expr:

-

type-name:

- - + + +

join-clause:

- + +

ordering-term:

- +

result-column:

- +

table-or-subquery:

- - - + + +

The CREATE VIEW command assigns a name to a pre-packaged SELECT statement. Once the view is created, it can be used in the FROM clause Index: Doc/Extra/Core/lang_createvtab.html ================================================================== --- Doc/Extra/Core/lang_createvtab.html +++ Doc/Extra/Core/lang_createvtab.html @@ -1,147 +1,85 @@ + + SQLite Query Language: CREATE VIRTUAL TABLE - - -

- +
- -
-
Small. Fast. Reliable.
Choose any three.
- - - - -
- -

SQL As Understood By SQLite

[Top]

CREATE VIRTUAL TABLE

create-virtual-table-stmt: +

+

SQL As Understood By SQLite

[Top]

CREATE VIRTUAL TABLE

create-virtual-table-stmt:

-
+
syntax diagram create-virtual-table-stmt -
+

A virtual table is an interface to an external storage or computation engine that appears to be a table but does not actually store information in the database file.

Index: Doc/Extra/Core/lang_datefunc.html ================================================================== --- Doc/Extra/Core/lang_datefunc.html +++ Doc/Extra/Core/lang_datefunc.html @@ -1,143 +1,81 @@ + + SQLite Query Language: Date And Time Functions - - -
- +
- -
-
Small. Fast. Reliable.
Choose any three.
- - - - -
- -

SQL As Understood By SQLite

[Top]

Date And Time Functions

+
+

SQL As Understood By SQLite

[Top]

Date And Time Functions

SQLite supports five date and time functions as follows:

Index: Doc/Extra/Core/lang_delete.html ================================================================== --- Doc/Extra/Core/lang_delete.html +++ Doc/Extra/Core/lang_delete.html @@ -1,277 +1,215 @@ + + SQLite Query Language: DELETE - - -
- +
- -
-
Small. Fast. Reliable.
Choose any three.
- - - - -
- -

SQL As Understood By SQLite

[Top]

DELETE

delete-stmt: +

+

SQL As Understood By SQLite

[Top]

DELETE

delete-stmt:

-
+
syntax diagram delete-stmt

expr:

-

select-stmt:

-

join-clause:

- +
+

ordering-term:

- +

result-column:

- +

table-or-subquery:

- - + +

type-name:

- - + + +

qualified-table-name:

- +

with-clause:

- - + + + +

The DELETE command removes records from the table identified by the qualified-table-name. @@ -310,13 +248,13 @@

If SQLite is compiled with the SQLITE_ENABLE_UPDATE_DELETE_LIMIT compile-time option, then the syntax of the DELETE statement is extended by the addition of optional ORDER BY and LIMIT clauses:

-

delete-stmt-limited:

+

delete-stmt-limited:

syntax diagram delete-stmt-limited -
+

If a DELETE statement has a LIMIT clause, the maximum number of rows that will be deleted is found by evaluating the accompanying expression and casting it to an integer value. If the result of the evaluating the LIMIT clause Index: Doc/Extra/Core/lang_detach.html ================================================================== --- Doc/Extra/Core/lang_detach.html +++ Doc/Extra/Core/lang_detach.html @@ -1,147 +1,85 @@ + + SQLite Query Language: DETACH DATABASE - - -

- +
- -
-
Small. Fast. Reliable.
Choose any three.
- - - - -
- -

SQL As Understood By SQLite

[Top]

DETACH DATABASE

detach-stmt: +

+

SQL As Understood By SQLite

[Top]

DETACH DATABASE

detach-stmt:

-
+
syntax diagram detach-stmt -
+

This statement detaches an additional database connection previously attached using the ATTACH statement. When not in shared cache mode, Index: Doc/Extra/Core/lang_dropindex.html ================================================================== --- Doc/Extra/Core/lang_dropindex.html +++ Doc/Extra/Core/lang_dropindex.html @@ -1,147 +1,85 @@ + + SQLite Query Language: DROP INDEX - - -

- +
- -
-
Small. Fast. Reliable.
Choose any three.
- - - - -
- -

SQL As Understood By SQLite

[Top]

DROP INDEX

drop-index-stmt: +

+

SQL As Understood By SQLite

[Top]

DROP INDEX

drop-index-stmt:

-
+
syntax diagram drop-index-stmt -
+

The DROP INDEX statement removes an index added with the CREATE INDEX statement. The index is completely removed from the disk. The only way to recover the index is to reenter the Index: Doc/Extra/Core/lang_droptable.html ================================================================== --- Doc/Extra/Core/lang_droptable.html +++ Doc/Extra/Core/lang_droptable.html @@ -1,147 +1,85 @@ + + SQLite Query Language: DROP TABLE - - -

- +
- -
-
Small. Fast. Reliable.
Choose any three.
- - - - -
- -

SQL As Understood By SQLite

[Top]

DROP TABLE

drop-table-stmt: +

+

SQL As Understood By SQLite

[Top]

DROP TABLE

drop-table-stmt:

-
+
syntax diagram drop-table-stmt -
+

The DROP TABLE statement removes a table added with the CREATE TABLE statement. The name specified is the table name. The dropped table is completely removed from the database Index: Doc/Extra/Core/lang_droptrigger.html ================================================================== --- Doc/Extra/Core/lang_droptrigger.html +++ Doc/Extra/Core/lang_droptrigger.html @@ -1,147 +1,85 @@ + + SQLite Query Language: DROP TRIGGER - - -

- +
- -
-
Small. Fast. Reliable.
Choose any three.
- - - - -
- -

SQL As Understood By SQLite

[Top]

DROP TRIGGER

drop-trigger-stmt: +

+

SQL As Understood By SQLite

[Top]

DROP TRIGGER

drop-trigger-stmt:

-
+
syntax diagram drop-trigger-stmt -
+

The DROP TRIGGER statement removes a trigger created by the CREATE TRIGGER statement. Once removed, the trigger definition is no longer present in the sqlite_master (or sqlite_temp_master) table and is Index: Doc/Extra/Core/lang_dropview.html ================================================================== --- Doc/Extra/Core/lang_dropview.html +++ Doc/Extra/Core/lang_dropview.html @@ -1,147 +1,85 @@ + + SQLite Query Language: DROP VIEW - - -

- +
- -
-
Small. Fast. Reliable.
Choose any three.
- - - - -
- -

SQL As Understood By SQLite

[Top]

DROP VIEW

drop-view-stmt: +

+

SQL As Understood By SQLite

[Top]

DROP VIEW

drop-view-stmt:

-
+
syntax diagram drop-view-stmt -
+

The DROP VIEW statement removes a view created by the CREATE VIEW statement. The view definition is removed from the database schema, but no actual data in the underlying base tables is modified. Index: Doc/Extra/Core/lang_explain.html ================================================================== --- Doc/Extra/Core/lang_explain.html +++ Doc/Extra/Core/lang_explain.html @@ -1,145 +1,83 @@ + + SQLite Query Language: EXPLAIN - - -

- +
- -
-
Small. Fast. Reliable.
Choose any three.
- - - - -
- -

SQL As Understood By SQLite

[Top]

EXPLAIN

sql-stmt:

+
+

SQL As Understood By SQLite

[Top]

EXPLAIN

sql-stmt:

syntax diagram sql-stmt - +

An SQL statement can be preceded by the keyword "EXPLAIN" or by the phrase "EXPLAIN QUERY PLAN". Either modification causes the SQL statement to behave as a query and to return information about Index: Doc/Extra/Core/lang_expr.html ================================================================== --- Doc/Extra/Core/lang_expr.html +++ Doc/Extra/Core/lang_expr.html @@ -1,212 +1,150 @@ + + SQLite Query Language: expression - - -

- +
- -
-
Small. Fast. Reliable.
Choose any three.
- - - - -
- -

SQL As Understood By SQLite

[Top]

expression

expr: +

+

SQL As Understood By SQLite

[Top]

expression

expr:

-
+
syntax diagram expr

literal-value:

- +

raise-function:

- +

select-stmt:

-

join-clause:

- + +

ordering-term:

- +

result-column:

- +

table-or-subquery:

- - + +

type-name:

- - + + +

This section is different from the others. Most other sections of this document talks about a particular SQL command. This section does not talk about a standalone command but about "expressions" which are @@ -285,13 +223,13 @@ BLOBs, or NULLs.

The syntax for integer and floating point literals (collectively "numeric literals") is shown by the following diagram:

-

numeric-literal:

+

numeric-literal:

syntax diagram numeric-literal -
+

If a numeric literal has a decimal point or an exponentiation clause or if its magnitude is less than -9223372036854775808 or Index: Doc/Extra/Core/lang_indexedby.html ================================================================== --- Doc/Extra/Core/lang_indexedby.html +++ Doc/Extra/Core/lang_indexedby.html @@ -1,153 +1,91 @@ + + SQLite Query Language: INDEXED BY - - -

- +
- -
-
Small. Fast. Reliable.
Choose any three.
- - - - -
- -

SQL As Understood By SQLite

[Top]

INDEXED BY

+
+

SQL As Understood By SQLite

[Top]

INDEXED BY

The INDEXED BY phrase forces the SQLite query planner to use a particular named index on a DELETE, SELECT, or UPDATE statement. The INDEXED BY phrase is an SQLite extension and is not portable to other SQL database engines.

qualified-table-name:

-
+
syntax diagram qualified-table-name -
+

The "INDEXED BY index-name" phrase specifies that the named index must be used in order to look up values on the preceding table. Index: Doc/Extra/Core/lang_insert.html ================================================================== --- Doc/Extra/Core/lang_insert.html +++ Doc/Extra/Core/lang_insert.html @@ -1,227 +1,165 @@ + + SQLite Query Language: INSERT - - -

- +
- -
-
Small. Fast. Reliable.
Choose any three.
- - - - -
- -

SQL As Understood By SQLite

[Top]

INSERT

insert-stmt: +

+

SQL As Understood By SQLite

[Top]

INSERT

insert-stmt:

-
+
syntax diagram insert-stmt

expr:

-

type-name:

- -
+
+ +

select-stmt:

- + +

with-clause:

- - + + +

The INSERT statement comes in three basic forms.