*** DRAFT ***

Syntax Diagrams For SQLite

aggregate-function-invocation:

aggregate-func ( DISTINCT expr ) filter-clause , *


References:   expr   filter-clause

See also:   lang_aggfunc.html   lang_expr.html#booleanexpr

alter-table-stmt:

ALTER TABLE schema-name . table-name RENAME TO new-table-name RENAME COLUMN column-name TO new-column-name ADD COLUMN column-def
Used by:   sql-stmt

References:   column-def

See also:   lang_altertable.html

analyze-stmt:

ANALYZE schema-name . table-or-index-name schema-name index-or-table-name
Used by:   sql-stmt

See also:   lang_analyze.html

attach-stmt:

ATTACH DATABASE expr AS schema-name
Used by:   sql-stmt

References:   expr

See also:   lang_attach.html

begin-stmt:

BEGIN EXCLUSIVE TRANSACTION DEFERRED IMMEDIATE
Used by:   sql-stmt

See also:   lang_transaction.html

column-constraint:

CONSTRAINT name PRIMARY KEY DESC conflict-clause AUTOINCREMENT ASC NOT NULL conflict-clause UNIQUE conflict-clause CHECK ( expr ) DEFAULT ( expr ) literal-value signed-number COLLATE collation-name foreign-key-clause GENERATED ALWAYS AS ( expr ) VIRTUAL STORED
Used by:   column-def

References:   conflict-clause   expr   foreign-key-clause   literal-value   signed-number

See also:   gencol.html   lang_altertable.html   lang_createtable.html   lang_createtable.html#tablecoldef

column-def:

column-name type-name column-constraint
Used by:   alter-table-stmt   create-table-stmt

References:   column-constraint   type-name

See also:   lang_altertable.html   lang_altertable.html#altertabaddcol   lang_createtable.html   lang_createtable.html#tablecoldef

column-name-list:

( column-name ) ,
Used by:   update-stmt   update-stmt-limited   upsert-clause

See also:   lang_createtrigger.html   lang_insert.html   lang_update.html   lang_upsert.html

comment-syntax:

-- anything-except-newline newline end-of-input /* anything-except-*/ */


See also:   lang_comment.html

commit-stmt:

COMMIT TRANSACTION END
Used by:   sql-stmt

See also:   lang_transaction.html

common-table-expression:

table-name ( column-name ) AS ( select-stmt ) ,
Used by:   compound-select-stmt   delete-stmt   delete-stmt-limited   factored-select-stmt   insert-stmt   select-stmt   simple-select-stmt   update-stmt   update-stmt-limited

References:   select-stmt

See also:   lang_aggfunc.html   lang_altertable.html   lang_attach.html   lang_createindex.html   lang_createtable.html   lang_createtrigger.html   lang_createview.html   lang_delete.html   lang_expr.html   lang_insert.html   lang_select.html   lang_select.html#compound   lang_select.html#simpleselect   lang_update.html   lang_upsert.html   lang_with.html   partialindex.html

compound-operator:

UNION UNION INTERSECT EXCEPT ALL
Used by:   factored-select-stmt   select-stmt

See also:   lang_aggfunc.html   lang_altertable.html   lang_attach.html   lang_createindex.html   lang_createtable.html   lang_createtrigger.html   lang_createview.html   lang_delete.html   lang_expr.html   lang_insert.html   lang_select.html   lang_select.html#compound   lang_select.html#simpleselect   lang_update.html   lang_upsert.html   lang_with.html   partialindex.html

compound-select-stmt:

WITH RECURSIVE common-table-expression , select-core ORDER BY LIMIT expr UNION UNION ALL select-core INTERSECT EXCEPT ordering-term , OFFSET expr , expr


References:   common-table-expression   expr   ordering-term   select-core

See also:   lang_select.html#compound

conflict-clause:

ON CONFLICT ROLLBACK ABORT FAIL IGNORE REPLACE
Used by:   column-constraint   table-constraint

See also:   lang_altertable.html   lang_conflict.html   lang_createtable.html   lang_createtable.html#notnullconst

create-index-stmt:

CREATE UNIQUE INDEX IF NOT EXISTS schema-name . index-name ON table-name ( indexed-column ) , WHERE expr
Used by:   sql-stmt

References:   expr   indexed-column

See also:   lang_createindex.html   partialindex.html

create-table-stmt:

CREATE TEMP TEMPORARY TABLE IF NOT EXISTS schema-name . table-name ( column-def table-constraint , ) WITHOUT ROWID , AS select-stmt
Used by:   sql-stmt

References:   column-def   select-stmt   table-constraint

See also:   lang_createtable.html

create-trigger-stmt:

CREATE TEMP TEMPORARY TRIGGER IF NOT EXISTS schema-name . trigger-name BEFORE AFTER INSTEAD OF DELETE INSERT UPDATE OF column-name , ON table-name FOR EACH ROW WHEN expr BEGIN update-stmt ; END insert-stmt delete-stmt select-stmt
Used by:   sql-stmt

References:   delete-stmt   expr   insert-stmt   select-stmt   update-stmt

See also:   lang_createtrigger.html

create-view-stmt:

CREATE TEMP TEMPORARY VIEW IF NOT EXISTS schema-name . view-name ( column-name ) AS select-stmt ,
Used by:   sql-stmt

References:   select-stmt

See also:   lang_createview.html

create-virtual-table-stmt:

CREATE VIRTUAL TABLE IF NOT EXISTS schema-name . table-name USING module-name ( module-argument ) ,
Used by:   sql-stmt

See also:   lang_createvtab.html

cte-table-name:

table-name ( column-name ) ,
Used by:   recursive-cte   with-clause

See also:   lang_with.html   lang_with.html#recursivecte

delete-stmt:

WITH RECURSIVE common-table-expression , DELETE FROM qualified-table-name WHERE expr
Used by:   create-trigger-stmt   sql-stmt

References:   common-table-expression   expr   qualified-table-name

See also:   lang_createtrigger.html   lang_delete.html

delete-stmt-limited:

WITH RECURSIVE common-table-expression , DELETE FROM qualified-table-name WHERE expr ORDER BY ordering-term , LIMIT expr OFFSET expr , expr
Used by:   sql-stmt

References:   common-table-expression   expr   ordering-term   qualified-table-name

See also:   lang_delete.html

detach-stmt:

DETACH DATABASE schema-name
Used by:   sql-stmt

See also:   lang_detach.html

drop-index-stmt:

DROP INDEX IF EXISTS schema-name . index-name
Used by:   sql-stmt

See also:   lang_dropindex.html

drop-table-stmt:

DROP TABLE IF EXISTS schema-name . table-name
Used by:   sql-stmt

See also:   lang_droptable.html

drop-trigger-stmt:

DROP TRIGGER IF EXISTS schema-name . trigger-name
Used by:   sql-stmt

See also:   lang_droptrigger.html

drop-view-stmt:

DROP VIEW IF EXISTS schema-name . view-name
Used by:   sql-stmt

See also:   lang_dropview.html

expr:

literal-value bind-parameter schema-name . table-name . column-name unary-operator expr binary-operator expr function-name ( DISTINCT expr ) filter-clause over-clause , * ( expr ) , CAST ( expr AS type-name ) expr COLLATE collation-name expr NOT LIKE GLOB REGEXP MATCH expr ESCAPE expr expr ISNULL NOTNULL NOT NULL expr IS NOT expr expr NOT BETWEEN expr AND expr expr NOT IN ( select-stmt ) expr , schema-name . table-function ( expr ) table-name , NOT EXISTS ( select-stmt ) CASE expr WHEN expr THEN expr ELSE expr END raise-function
Used by:   aggregate-function-invocation   attach-stmt   column-constraint   compound-select-stmt   create-index-stmt   create-trigger-stmt   delete-stmt   delete-stmt-limited   factored-select-stmt   filter-clause   frame-spec   indexed-column   insert-stmt   join-constraint   ordering-term   over-clause   result-column   select-core   select-stmt   simple-function-invocation   simple-select-stmt   table-constraint   table-or-subquery   update-stmt   update-stmt-limited   upsert-clause   window-defn   window-function-invocation

References:   filter-clause   literal-value   over-clause   raise-function   select-stmt   type-name

See also:   lang_aggfunc.html   lang_altertable.html   lang_attach.html   lang_createindex.html   lang_createtable.html   lang_createtrigger.html   lang_createview.html   lang_delete.html   lang_expr.html   lang_insert.html   lang_select.html   lang_select.html#compound   lang_select.html#simpleselect   lang_update.html   lang_upsert.html   lang_with.html   partialindex.html

factored-select-stmt:

WITH RECURSIVE common-table-expression , select-core ORDER BY LIMIT expr compound-operator ordering-term , OFFSET expr , expr


References:   common-table-expression   compound-operator   expr   ordering-term   select-core

See also:   lang_select.html

filter-clause:

FILTER ( WHERE expr )
Used by:   aggregate-function-invocation   expr   window-function-invocation

References:   expr

See also:   lang_aggfunc.html   lang_altertable.html   lang_attach.html   lang_createindex.html   lang_createtable.html   lang_createtrigger.html   lang_createview.html   lang_delete.html   lang_expr.html   lang_insert.html   lang_select.html   lang_select.html#compound   lang_select.html#simpleselect   lang_update.html   lang_upsert.html   lang_with.html   partialindex.html

foreign-key-clause:

REFERENCES foreign-table ( column-name ) , ON DELETE SET NULL UPDATE SET DEFAULT CASCADE RESTRICT NO ACTION MATCH name NOT DEFERRABLE INITIALLY DEFERRED INITIALLY IMMEDIATE
Used by:   column-constraint   table-constraint

See also:   lang_altertable.html   lang_altertable.html#altertabaddcol   lang_createtable.html

frame-spec:

GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING RANGE ROWS UNBOUNDED PRECEDING expr PRECEDING CURRENT ROW expr PRECEDING CURRENT ROW expr FOLLOWING expr PRECEDING CURRENT ROW expr FOLLOWING EXCLUDE CURRENT ROW EXCLUDE GROUP EXCLUDE TIES EXCLUDE NOT OTHERS
Used by:   over-clause   window-defn

References:   expr

See also:   lang_aggfunc.html   lang_altertable.html   lang_attach.html   lang_createindex.html   lang_createtable.html   lang_createtrigger.html   lang_createview.html   lang_delete.html   lang_expr.html   lang_insert.html   lang_select.html   lang_select.html#compound   lang_select.html#simpleselect   lang_update.html   lang_upsert.html   lang_with.html   partialindex.html

indexed-column:

column-name COLLATE collation-name DESC expr ASC
Used by:   create-index-stmt   table-constraint   upsert-clause

References:   expr

See also:   lang_createindex.html   lang_createtable.html   lang_createtable.html#primkeyconst   lang_createtable.html#uniqueconst   lang_createtrigger.html   lang_insert.html   lang_upsert.html   partialindex.html

insert-stmt:

WITH RECURSIVE common-table-expression , REPLACE INSERT OR ROLLBACK INTO ABORT FAIL IGNORE REPLACE schema-name . table-name AS alias ( column-name ) , VALUES ( expr ) , , upsert-clause select-stmt upsert-clause DEFAULT VALUES
Used by:   create-trigger-stmt   sql-stmt

References:   common-table-expression   expr   select-stmt   upsert-clause

See also:   lang_createtrigger.html   lang_insert.html

join-clause:

table-or-subquery join-operator table-or-subquery join-constraint
Used by:   table-or-subquery   update-stmt   update-stmt-limited

References:   join-constraint   join-operator   table-or-subquery

See also:   lang_aggfunc.html   lang_altertable.html   lang_attach.html   lang_createindex.html   lang_createtable.html   lang_createtrigger.html   lang_createview.html   lang_delete.html   lang_expr.html   lang_insert.html   lang_select.html   lang_select.html#compound   lang_select.html#simpleselect   lang_update.html   lang_upsert.html   lang_with.html   partialindex.html

join-constraint:

USING ( column-name ) , ON expr
Used by:   join-clause

References:   expr

See also:   lang_aggfunc.html   lang_altertable.html   lang_attach.html   lang_createindex.html   lang_createtable.html   lang_createtrigger.html   lang_createview.html   lang_delete.html   lang_expr.html   lang_insert.html   lang_select.html   lang_select.html#compound   lang_select.html#fromclause   lang_select.html#simpleselect   lang_update.html   lang_upsert.html   lang_with.html   partialindex.html

join-operator:

NATURAL LEFT OUTER JOIN , INNER CROSS
Used by:   join-clause

See also:   lang_aggfunc.html   lang_altertable.html   lang_attach.html   lang_createindex.html   lang_createtable.html   lang_createtrigger.html   lang_createview.html   lang_delete.html   lang_expr.html   lang_insert.html   lang_select.html   lang_select.html#compound   lang_select.html#fromclause   lang_select.html#simpleselect   lang_update.html   lang_upsert.html   lang_with.html   partialindex.html

literal-value:

CURRENT_TIMESTAMP numeric-literal string-literal blob-literal NULL TRUE FALSE CURRENT_TIME CURRENT_DATE
Used by:   column-constraint   expr

See also:   lang_aggfunc.html   lang_altertable.html   lang_attach.html   lang_createindex.html   lang_createtable.html   lang_createtrigger.html   lang_createview.html   lang_delete.html   lang_expr.html   lang_insert.html   lang_select.html   lang_select.html#compound   lang_select.html#simpleselect   lang_update.html   lang_upsert.html   lang_with.html   partialindex.html

numeric-literal:

digit . E e digit . digit - digit + 0x hexdigit


See also:   lang_expr.html#litvalue

ordering-term:

expr COLLATE collation-name DESC ASC NULLS FIRST NULLS LAST
Used by:   compound-select-stmt   delete-stmt-limited   factored-select-stmt   over-clause   select-stmt   simple-select-stmt   update-stmt-limited   window-defn

References:   expr

See also:   lang_aggfunc.html   lang_altertable.html   lang_attach.html   lang_createindex.html   lang_createtable.html   lang_createtrigger.html   lang_createview.html   lang_delete.html   lang_expr.html   lang_insert.html   lang_select.html   lang_select.html#compound   lang_select.html#simpleselect   lang_update.html   lang_upsert.html   lang_with.html   partialindex.html

over-clause:

OVER window-name ( base-window-name PARTITION BY expr , ORDER BY ordering-term , frame-spec )
Used by:   expr

References:   expr   frame-spec   ordering-term

See also:   lang_aggfunc.html   lang_altertable.html   lang_attach.html   lang_createindex.html   lang_createtable.html   lang_createtrigger.html   lang_createview.html   lang_delete.html   lang_expr.html   lang_insert.html   lang_select.html   lang_select.html#compound   lang_select.html#simpleselect   lang_update.html   lang_upsert.html   lang_with.html   partialindex.html

pragma-stmt:

PRAGMA schema-name . pragma-name ( pragma-value ) = pragma-value
Used by:   sql-stmt

References:   pragma-value

See also:   pragma.html#syntax

pragma-value:

signed-number name signed-literal
Used by:   pragma-stmt

References:   signed-number

See also:   pragma.html#syntax

qualified-table-name:

schema-name . table-name AS alias INDEXED BY index-name NOT INDEXED
Used by:   delete-stmt   delete-stmt-limited   update-stmt   update-stmt-limited

See also:   lang_createtrigger.html   lang_delete.html   lang_indexedby.html   lang_update.html

raise-function:

RAISE ( ROLLBACK , error-message ) IGNORE ABORT FAIL
Used by:   expr

See also:   lang_aggfunc.html   lang_altertable.html   lang_attach.html   lang_createindex.html   lang_createtable.html   lang_createtrigger.html   lang_createtrigger.html#raise   lang_createview.html   lang_delete.html   lang_expr.html   lang_insert.html   lang_select.html   lang_select.html#compound   lang_select.html#simpleselect   lang_update.html   lang_upsert.html   lang_with.html   partialindex.html

recursive-cte:

cte-table-name AS ( initial-select UNION ALL recursive-select ) UNION


References:   cte-table-name

See also:   lang_with.html#recursivecte

reindex-stmt:

REINDEX schema-name . index-name table-name collation-name
Used by:   sql-stmt

See also:   lang_reindex.html

release-stmt:

RELEASE SAVEPOINT savepoint-name
Used by:   sql-stmt

See also:   lang_savepoint.html

result-column:

expr AS column-alias * table-name . *
Used by:   select-core   select-stmt

References:   expr

See also:   lang_aggfunc.html   lang_altertable.html   lang_attach.html   lang_createindex.html   lang_createtable.html   lang_createtrigger.html   lang_createview.html   lang_delete.html   lang_expr.html   lang_insert.html   lang_select.html   lang_select.html#compound   lang_select.html#simpleselect   lang_update.html   lang_upsert.html   lang_with.html   partialindex.html

rollback-stmt:

ROLLBACK TRANSACTION TO SAVEPOINT savepoint-name
Used by:   sql-stmt

See also:   lang_savepoint.html   lang_transaction.html

savepoint-stmt:

SAVEPOINT savepoint-name
Used by:   sql-stmt

See also:   lang_savepoint.html

select-core:

SELECT DISTINCT result-column , ALL FROM table-or-subquery , WHERE expr GROUP BY expr HAVING expr , WINDOW window-name AS window-defn , VALUES ( expr ) , ,
Used by:   compound-select-stmt   factored-select-stmt   simple-select-stmt

References:   expr   result-column   table-or-subquery

See also:   lang_select.html   lang_select.html#compound   lang_select.html#simpleselect

select-stmt:

WITH RECURSIVE common-table-expression , SELECT DISTINCT result-column , ALL FROM table-or-subquery , WHERE expr GROUP BY expr HAVING expr , WINDOW window-name AS window-defn , VALUES ( expr ) , , compound-operator select-core ORDER BY LIMIT expr ordering-term , OFFSET expr , expr
Used by:   common-table-expression   create-table-stmt   create-trigger-stmt   create-view-stmt   expr   insert-stmt   sql-stmt   table-or-subquery   with-clause

References:   common-table-expression   compound-operator   expr   ordering-term   result-column   table-or-subquery

See also:   lang_aggfunc.html   lang_altertable.html   lang_attach.html   lang_createindex.html   lang_createtable.html   lang_createtrigger.html   lang_createview.html   lang_delete.html   lang_expr.html   lang_insert.html   lang_select.html   lang_select.html#compound   lang_select.html#simpleselect   lang_update.html   lang_upsert.html   lang_with.html   lang_with.html#recursivecte   partialindex.html

signed-number:

+ numeric-literal -
Used by:   column-constraint   pragma-value   type-name

See also:   lang_aggfunc.html   lang_altertable.html   lang_attach.html   lang_createindex.html   lang_createtable.html   lang_createtrigger.html   lang_createview.html   lang_delete.html   lang_expr.html   lang_insert.html   lang_select.html   lang_select.html#compound   lang_select.html#simpleselect   lang_update.html   lang_upsert.html   lang_with.html   partialindex.html   pragma.html#syntax

simple-function-invocation:

simple-func ( expr ) , *


References:   expr

See also:   lang_expr.html#booleanexpr

simple-select-stmt:

WITH RECURSIVE common-table-expression , select-core ORDER BY LIMIT expr ordering-term , OFFSET expr , expr


References:   common-table-expression   expr   ordering-term   select-core

See also:   lang_select.html#simpleselect

sql-stmt:

EXPLAIN QUERY PLAN alter-table-stmt analyze-stmt attach-stmt begin-stmt commit-stmt create-index-stmt create-table-stmt create-trigger-stmt create-view-stmt create-virtual-table-stmt delete-stmt delete-stmt-limited detach-stmt drop-index-stmt drop-table-stmt drop-trigger-stmt drop-view-stmt insert-stmt pragma-stmt reindex-stmt release-stmt rollback-stmt savepoint-stmt select-stmt update-stmt update-stmt-limited vacuum-stmt
Used by:   sql-stmt-list

References:   alter-table-stmt   analyze-stmt   attach-stmt   begin-stmt   commit-stmt   create-index-stmt   create-table-stmt   create-trigger-stmt   create-view-stmt   create-virtual-table-stmt   delete-stmt   delete-stmt-limited   detach-stmt   drop-index-stmt   drop-table-stmt   drop-trigger-stmt   drop-view-stmt   insert-stmt   pragma-stmt   reindex-stmt   release-stmt   rollback-stmt   savepoint-stmt   select-stmt   update-stmt   update-stmt-limited   vacuum-stmt

See also:   lang.html   lang_explain.html

sql-stmt-list:

sql-stmt ;


References:   sql-stmt

See also:   lang.html

table-constraint:

CONSTRAINT name PRIMARY KEY ( indexed-column ) conflict-clause , UNIQUE CHECK ( expr ) FOREIGN KEY ( column-name ) foreign-key-clause ,
Used by:   create-table-stmt

References:   conflict-clause   expr   foreign-key-clause   indexed-column

See also:   lang_createtable.html   lang_createtable.html#primkeyconst   lang_createtable.html#tablecoldef   lang_createtable.html#uniqueconst

table-or-subquery:

schema-name . table-name AS table-alias INDEXED BY index-name NOT INDEXED table-function-name ( expr ) , AS table-alias ( select-stmt ) ( table-or-subquery ) , join-clause
Used by:   join-clause   select-core   select-stmt   update-stmt   update-stmt-limited

References:   expr   join-clause   select-stmt

See also:   lang_aggfunc.html   lang_altertable.html   lang_attach.html   lang_createindex.html   lang_createtable.html   lang_createtrigger.html   lang_createview.html   lang_delete.html   lang_expr.html   lang_insert.html   lang_select.html   lang_select.html#compound   lang_select.html#simpleselect   lang_update.html   lang_upsert.html   lang_with.html   partialindex.html

type-name:

name ( signed-number , signed-number ) ( signed-number )
Used by:   column-def   expr

References:   signed-number

See also:   lang_aggfunc.html   lang_altertable.html   lang_attach.html   lang_createindex.html   lang_createtable.html   lang_createtrigger.html   lang_createview.html   lang_delete.html   lang_expr.html   lang_insert.html   lang_select.html   lang_select.html#compound   lang_select.html#simpleselect   lang_update.html   lang_upsert.html   lang_with.html   partialindex.html

update-stmt:

WITH RECURSIVE common-table-expression , UPDATE OR ROLLBACK qualified-table-name OR REPLACE OR IGNORE OR FAIL OR ABORT SET column-name-list = expr column-name , FROM table-or-subquery , join-clause WHERE expr
Used by:   create-trigger-stmt   sql-stmt

References:   column-name-list   common-table-expression   expr   join-clause   qualified-table-name   table-or-subquery

See also:   lang_createtrigger.html   lang_update.html

update-stmt-limited:

WITH RECURSIVE common-table-expression , UPDATE OR ROLLBACK qualified-table-name OR REPLACE OR IGNORE OR FAIL OR ABORT SET column-name-list = expr column-name , FROM table-or-subquery , join-clause WHERE expr ORDER BY ordering-term , LIMIT expr OFFSET expr , expr
Used by:   sql-stmt

References:   column-name-list   common-table-expression   expr   join-clause   ordering-term   qualified-table-name   table-or-subquery

See also:   lang_update.html#upfrom

upsert-clause:

ON CONFLICT ( indexed-column ) WHERE expr DO , UPDATE SET column-name-list = expr WHERE expr NOTHING , column-name
Used by:   insert-stmt

References:   column-name-list   expr   indexed-column

See also:   lang_createtrigger.html   lang_insert.html   lang_upsert.html

vacuum-stmt:

VACUUM schema-name INTO filename
Used by:   sql-stmt

See also:   lang_vacuum.html

window-defn:

( base-window-name PARTITION BY expr , ORDER BY ordering-term , frame-spec )
Used by:   window-function-invocation

References:   expr   frame-spec   ordering-term

window-function-invocation:

window-func ( expr ) filter-clause OVER window-name window-defn , *


References:   expr   filter-clause   window-defn

See also:   lang_expr.html#booleanexpr

with-clause:

WITH RECURSIVE cte-table-name AS ( select-stmt ) ,


References:   cte-table-name   select-stmt

See also:   lang_with.html

*** DRAFT ***