📄 lang.tcl
字号:
puts {<p>This statement detaches an additional database connection previously attached using the <a href="#attach">ATTACH DATABASE</a> statement. Itis possible to have the same database file attached multiple times using different names, and detaching one connection to a file will leave the others intact.</p><p>This statement will fail if SQLite is in the middle of a transaction.</p>}Section {DROP INDEX} dropindexSyntax {sql-command} {DROP INDEX [<database-name> .] <index-name>}puts {<p>The DROP INDEX statement removes an index added with the <a href="#createindex">CREATE INDEX</a> statement. The index named is completely removed fromthe disk. The only way to recover the index is to reenter theappropriate CREATE INDEX command. Non-temporary indexes on tables in an attached database cannot be dropped.</p><p>The DROP INDEX statement does not reduce the size of the database file. Empty space in the database is retained for later INSERTs. To remove free space in the database, use the <a href="#vacuum">VACUUM</a> command.</p>}Section {DROP TABLE} droptableSyntax {sql-command} {DROP TABLE <table-name>}puts {<p>The DROP TABLE statement removes a table added with the <a href="#createtable">CREATE TABLE</a> statement. The name specified is thetable name. It is completely removed from the database schema and the disk file. The table can not be recovered. All indices associated with the table are also deleted. Non-temporary tables in an attached database cannot be dropped.</p><p>The DROP TABLE statement does not reduce the size of the database file. Empty space in the database is retained for later INSERTs. To remove free space in the database, use the <a href="#vacuum">VACUUM</a> command.</p>}Section {DROP TRIGGER} droptriggerSyntax {sql-statement} {DROP TRIGGER [<database-name> .] <trigger-name>}puts { <p>The DROP TRIGGER statement removes a trigger created by the <a href="#createtrigger">CREATE TRIGGER</a> statement. The trigger is deleted from the database schema. Note that triggers are automatically dropped when the associated table is dropped. Non-temporary triggers cannot be dropped on attached tables.</p>}Section {DROP VIEW} dropviewSyntax {sql-command} {DROP VIEW <view-name>}puts {<p>The DROP VIEW statement removes a view created by the <a href="#createview">CREATE VIEW</a> statement. The name specified is the view name. It is removed from the database schema, but no actual data in the underlying base tables is modified. Non-temporary views in attached databases cannot be dropped.</p>}Section EXPLAIN explainSyntax {sql-statement} {EXPLAIN <sql-statement>}puts {<p>The EXPLAIN command modifier is a non-standard extension. Theidea comes from a similar command found in PostgreSQL, but the operationis completely different.</p><p>If the EXPLAIN keyword appears before any other SQLite SQL commandthen instead of actually executing the command, the SQLite library willreport back the sequence of virtual machine instructions it would haveused to execute the command had the EXPLAIN keyword not been present.For additional information about virtual machine instructions seethe <a href="arch.html">architecture description</a> or the documentationon <a href="opcode.html">available opcodes</a> for the virtual machine.</p>}Section expression exprSyntax {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> | STAR ) |<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>] LP WHEN <expr> THEN <expr> RPPLUS [ELSE <expr>] END} {like-op} {LIKE | GLOB | NOT LIKE | NOT GLOB}puts {<p>This section is different from the others. Most other sections ofthis document talks about a particular SQL command. This section doesnot talk about a standalone command but about "expressions" which are subcomponents of most other commands.</p><p>SQLite understands the following binary operators, in order fromhighest to lowest precedence:</p><blockquote><pre><font color="#2c2cf0"><big>||* / %+ -<< >> & |< <= > >== == != <> </big>INAND OR</font></pre></blockquote><p>Supported unary operaters are these:</p><blockquote><pre><font color="#2c2cf0"><big>- + ! ~</big></font></pre></blockquote><p>Any SQLite value can be used as part of an expression. For arithmetic operations, integers are treated as integers.Strings are first converted to real numbers using <b>atof()</b>.For comparison operators, numbers compare as numbers and stringscompare using the <b>strcmp()</b> function.Note that there are two variations of the equals and not equalsoperators. Equals can be either}puts "[Operator =] or [Operator ==].The non-equals operator can be either[Operator !=] or [Operator {<>}].The [Operator ||] operator is \"concatenate\" - it joins togetherthe two strings of its operands.The operator [Operator %] outputs the remainder of its left operand modulo its right operand.</p>"puts {<a name="like"></a><p>The LIKE operator does a wildcard comparision. The operandto the right contains the wildcards.}puts "A percent symbol [Operator %] in the right operandmatches any sequence of zero or more characters on the left.An underscore [Operator _] on the rightmatches any single character on the left."puts {The LIKE operator isnot case sensitive and will match upper case characters on oneside against lower case characters on the other.(A bug: SQLite only understands upper/lower case for 7-bit Latincharacters. Hence the LIKE operator is case sensitive for8-bit iso8859 characters or UTF-8 characters. For example,the expression <b>'a' LIKE 'A'</b> is TRUE but<b>'æ' LIKE 'Æ'</b> is FALSE.). The infix LIKE operator is identical the user function <a href="#likeFunc">like(<i>X</i>,<i>Y</i>)</a>.</p><a name="glob"></a><p>The GLOB operator is similar to LIKE but uses the Unixfile globbing syntax for its wildcards. Also, GLOB is casesensitive, unlike LIKE. Both GLOB and LIKE may be preceded bythe NOT keyword to invert the sense of the test. The infix GLOB operator is identical the user function <a href="#globFunc">glob(<i>X</i>,<i>Y</i>)</a>.</p><p>A column name can be any of the names defined in the CREATE TABLEstatement or one of the following special identifiers: "<b>ROWID</b>","<b>OID</b>", or "<b>_ROWID_</b>".These special identifiers all describe theunique random integer key (the "row key") associated with every row of every table.The special identifiers only refer to the row key if the CREATE TABLEstatement does not define a real column with the same name. Row keysact like read-only columns. A row key can be used anywhere a regularcolumn can be used, except that you cannot change the valueof a row key in an UPDATE or INSERT statement."SELECT * ..." does not return the row key.</p><p>SELECT statements can appear in expressions as either theright-hand operand of the IN operator or as a scalar quantity.In both cases, the SELECT should have only a single column in itsresult. Compound SELECTs (connected with keywords like UNION orEXCEPT) are allowed.A SELECT in an expression is evaluated once before any other processingis performed, so none of the expressions within the select itself canrefer to quantities in the containing expression.</p><p>When a SELECT is the right operand of the IN operator, the INoperator returns TRUE if the result of the left operand is any ofthe values generated by the select. The IN operator may be precededby the NOT keyword to invert the sense of the test.</p><p>When a SELECT appears within an expression but is not the rightoperand of an IN operator, then the first row of the result of theSELECT becomes the value used in the expression. If the SELECT yieldsmore than one result row, all rows after the first are ignored. Ifthe SELECT yeilds no rows, then the value of the SELECT is NULL.</p><p>Both simple and aggregate functions are supported. A simplefunction can be used in any expression. Simple functions returna result immediately based on their inputs. Aggregate functionsmay only be used in a SELECT statement. Aggregate functions computetheir result across all rows of the result set.</p><p>The functions shown below are available by default. Additionalfunctions may be written in C and added to the database engine usingthe <a href="c_interface.html#cfunc">sqlite_create_function()</a>API.</p><table border=0 cellpadding=10><tr><td valign="top" align="right" width=120>abs(<i>X</i>)</td><td valign="top">Return the absolute value of argument <i>X</i>.</td></tr><tr><td valign="top" align="right">coalesce(<i>X</i>,<i>Y</i>,...)</td><td valign="top">Return a copy of the first non-NULL argument. Ifall arguments are NULL then NULL is returned. There must be at least 2 arguments.</td></tr><tr><a name="globFunc"></a><td valign="top" align="right">glob(<i>X</i>,<i>Y</i>)</td><td valign="top">This function is used to implement the"<b>Y GLOB X</b>" syntax of SQLite. The<a href="c_interface.html#cfunc">sqlite_create_function()</a> interface canbe used to override this function and thereby change the operationof the <a href="#glob">GLOB</a> operator.</td></tr><tr><td valign="top" align="right">ifnull(<i>X</i>,<i>Y</i>)</td><td valign="top">Return a copy of the first non-NULL argument. Ifboth arguments are NULL then NULL is returned. This behaves the same as <b>coalesce()</b> above.</td></tr><tr><td valign="top" align="right">last_insert_rowid()</td><td valign="top">Return the ROWID of the last row insert from thisconnection to the database. This is the same value that would be returnedfrom the <b>sqlite_last_insert_rowid()</b> API function.</td></tr><tr><td valign="top" align="right">length(<i>X</i>)</td><td valign="top">Return the string length of <i>X</i> in characters.If SQLite is configured to support UTF-8, then the number of UTF-8characters is returned, not the number of bytes.</td></tr><tr><a name="likeFunc"></a><td valign="top" align="right">like(<i>X</i>,<i>Y</i>)</td><td valign="top">This function is used to implement the"<b>Y LIKE X</b>" syntax of SQL. The<a href="c_interface.html#cfunc">sqlite_create_function()</a> interface canbe used to override this function and thereby change the operationof the <a href="#like">LIKE</a> operator.</td></tr><tr><td valign="top" align="right">lower(<i>X</i>)</td><td valign="top">Return a copy of string <i>X</i> will all charactersconverted to lower case. The C library <b>tolower()</b> routine is usedfor the conversion, which means that this function might notwork correctly on UTF-8 characters.</td></tr><tr><td valign="top" align="right">max(<i>X</i>,<i>Y</i>,...)</td><td valign="top">Return the argument with the maximum value. Argumentsmay be strings in addition to numbers. The maximum value is determinedby the usual sort order. Note that <b>max()</b> is a simple function whenit has 2 or more arguments but converts to an aggregate function if givenonly a single argument.</td></tr><tr><td valign="top" align="right">min(<i>X</i>,<i>Y</i>,...)</td><td valign="top">Return the argument with the minimum value. Argumentsmay be strings in addition to numbers. The mminimum value is determinedby the usual sort order. Note that <b>min()</b> is a simple function whenit has 2 or more arguments but converts to an aggregate function if givenonly a single argument.</td></tr><tr><td valign="top" align="right">nullif(<i>X</i>,<i>Y</i>)</td><td valign="top">Return the first argument if the arguments are different, otherwise return NULL.</td></tr><tr><td valign="top" align="right">random(*)</td><td valign="top">Return a random integer between -2147483648 and+2147483647.</td>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -