SQLite sql命令


准备将它加入到TopicLive支持的数据库类型中.因此将一些资料放在这里备查. 主页:SQLite

ATTACH DATABASE

_sql-statement_ ::=

ATTACH [DATABASE] database-filename AS database-name

BEGIN TRANSACTION

_sql-statement_ ::=

BEGIN [ DEFERRED | IMMEDIATE | EXCLUSIVE ] [TRANSACTION [name]]

_sql-statement_ ::=

END [TRANSACTION [name]]

_sql-statement_ ::=

COMMIT [TRANSACTION [name]]

_sql-statement_ ::=

ROLLBACK [TRANSACTION [name]]

comment

_comment_ ::=

SQL-comment | C-comment

_SQL-comment_ ::=

-- single-line

_C-comment_ ::=

/* multiple-lines [*/]

COPY

_sql-statement_ ::=

COPY [ OR conflict-algorithm ] [database-name .] table-name FROM filename[ USING DELIMITERS delim ]

CREATE INDEX

_sql-statement_ ::=

CREATE [UNIQUE] INDEX index-nameON [database-name .] table-name ( column-name [, column-name]* )[ ON CONFLICT conflict-algorithm ]

_column-name_ ::=

name [ COLLATE collation-name] [ ASC | DESC ]

CREATE TABLE

_sql-command_ ::=

CREATE [TEMP | TEMPORARY] TABLE table-name (column-def [, column-def]*[, constraint]***
)**

_sql-command_ ::=

CREATE [TEMP | TEMPORARY] TABLE [database-name.] table-name AS select-statement

_column-def_ ::=

name [type] [[CONSTRAINT name] column-constraint]*

_type_ ::=

typename |typename ( number ) |typename ( number , number )

_column-constraint_ ::=

NOT NULL [ conflict-clause ] |PRIMARY KEY [sort-order] [ conflict-clause ] |UNIQUE [ conflict-clause ] |CHECK ( expr ) [ conflict-clause ] |DEFAULT value |COLLATE collation-name

_constraint_ ::=

PRIMARY KEY ( column-list ) [ conflict-clause ] |UNIQUE ( column-list ) [ conflict-clause ] |CHECK ( expr ) [ conflict-clause ]

_conflict-clause_ ::=

ON CONFLICT conflict-algorithm

CREATE TRIGGER

_sql-statement_ ::=

CREATE [TEMP | TEMPORARY] TRIGGER trigger-name [ BEFORE | AFTER ]database-event ON [database-name .] _table-name_trigger-action

_sql-statement_ ::=

CREATE [TEMP | TEMPORARY] TRIGGER trigger-name INSTEAD OFdatabase-event ON [database-name .] _view-name_trigger-action

_database-event_ ::=

DELETE |INSERT |UPDATE |UPDATE OF column-list

_trigger-action_ ::=

[ FOR EACH ROW | FOR EACH STATEMENT ] [ WHEN expression ]**
BEGIN
    **trigger-step ; [ trigger-step ; ]***
END**

_trigger-step_ ::=

update-statement | insert-statement |delete-statement | select-statement

CREATE VIEW

_sql-command_ ::=

CREATE [TEMP | TEMPORARY] VIEW [database-name.] view-name AS select-statement

DELETE

_sql-statement_ ::=

DELETE FROM [database-name .] table-name [WHERE expr]

DETACH DATABASE

_sql-command_ ::=

DETACH [DATABASE] database-name

DROP INDEX

_sql-command_ ::=

DROP INDEX [database-name .] index-name

DROP TABLE

_sql-command_ ::=

DROP TABLE [database-name.] table-name

DROP TRIGGER

_sql-statement_ ::=

DROP TRIGGER [database-name .] trigger-name

DROP VIEW

_sql-command_ ::=

DROP VIEW view-name

EXPLAIN

_sql-statement_ ::=

EXPLAIN sql-statement

expression

_expr_ ::=

expr binary-op expr |expr like-op expr |unary-op expr |( expr ) |column-name |table-name . column-name |database-name . table-name . column-name |literal-value |function-name ( expr-list | *** )** |expr ISNULL |expr NOTNULL |expr [NOT] BETWEEN expr AND expr |expr [NOT] IN ( value-list ) |expr [NOT] IN ( select-statement ) |expr [NOT] IN [database-name .] table-name |( select-statement ) |CASE [expr] ( WHEN expr THEN expr )+ [ELSE expr] END

_like-op_ ::=

LIKE | GLOB | NOT LIKE | NOT GLOB

INSERT

_sql-statement_ ::=

INSERT [OR conflict-algorithm] INTO [database-name .] table-name [(column-list)] VALUES(value-list) |INSERT [OR conflict-algorithm] INTO [database-name .] table-name [(column-list)] select-statement

ON CONFLICT clause

_conflict-clause_ ::=

ON CONFLICT conflict-algorithm

_conflict-algorithm_ ::=

ROLLBACK | ABORT | FAIL | IGNORE | REPLACE

REPLACE

_sql-statement_ ::=

REPLACE INTO [database-name .] table-name [( column-list )] VALUES ( value-list ) |REPLACE INTO [database-name .] table-name [( column-list )] select-statement

SELECT

_sql-statement_ ::=

SELECT [ALL | DISTINCT] result [FROM table-list][WHERE expr][GROUP BY expr-list][HAVING expr][compound-op select]*[ORDER BY sort-expr-list][LIMIT integer [( OFFSET | , ) integer]]

_result_ ::=

result-column [, result-column]*

_result-column_ ::=

***** | table-name **. *** | expr [ [AS] string ]

_table-list_ ::=

table [join-op table join-args]*

_table_ ::=

table-name [AS alias] |( select ) [AS alias]

_join-op_ ::=

, | [NATURAL] [LEFT | RIGHT | FULL] [OUTER | INNER | CROSS] JOIN

_join-args_ ::=

[ON expr] [USING ( id-list )]

_sort-expr-list_ ::=

expr [sort-order] [, expr [sort-order]]*

_sort-order_ ::=

[ COLLATE collation-name ] [ ASC | DESC ]

_compound_op_ ::=

UNION | UNION ALL | INTERSECT | EXCEPT

UPDATE

_sql-statement_ ::=

UPDATE [ OR conflict-algorithm ] [database-name .] table-nameSET assignment [, assignment]*[WHERE expr]

_assignment_ ::=

column-name = expr

VACUUM

_sql-statement_ ::=

VACUUM [index-or-table-name]

comments powered by Disqus