⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lang.tcl

📁 sqlite数据库源码
💻 TCL
📖 第 1 页 / 共 5 页
字号:
</tr><tr><td valign="top" align="right">round(<i>X</i>)<br>round(<i>X</i>,<i>Y</i>)</td><td valign="top">Round off the number <i>X</i> to <i>Y</i> digits to theright of the decimal point.  If the <i>Y</i> argument is omitted, 0 is assumed.</td></tr><tr><td valign="top" align="right">soundex(<i>X</i>)</td><td valign="top">Compute the soundex encoding of the string <i>X</i>.The string "?000" is returned if the argument is NULL.This function is omitted from SQLite by default.It is only available the -DSQLITE_SOUNDEX=1 compiler optionis used when SQLite is built.</td></tr><tr><td valign="top" align="right">sqlite_version(*)</td><td valign="top">Return the version string for the SQLite librarythat is running.  Example:  "2.8.0"</td></tr><tr><td valign="top" align="right">substr(<i>X</i>,<i>Y</i>,<i>Z</i>)</td><td valign="top">Return a substring of input string <i>X</i> that beginswith the <i>Y</i>-th character and which is <i>Z</i> characters long.The left-most character of <i>X</i> is number 1.  If <i>Y</i> is negativethe the first character of the substring is found by counting from theright rather than the left.  If SQLite is configured to support UTF-8,then characters indices refer to actual UTF-8 characters, not bytes.</td></tr><tr><td valign="top" align="right">typeof(<i>X</i>)</td><td valign="top">Return the type of the expression <i>X</i>.  The only return values are "numeric" and "text".  SQLite's type handling is explained in <a href="datatypes.html">Datatypes in SQLite</a>.</td></tr><tr><td valign="top" align="right">upper(<i>X</i>)</td><td valign="top">Return a copy of input string <i>X</i> converted to allupper-case letters.  The implementation of this function uses the C libraryroutine <b>toupper()</b> which means it may not work correctly on UTF-8 strings.</td></tr></table><p>The following aggregate functions are available by default.  Additionalaggregate functions written in C may be added using the <a href="c_interface.html#cfunc">sqlite_create_aggregate()</a> API.</p><table border=0 cellpadding=10><tr><td valign="top" align="right" width=120>avg(<i>X</i>)</td><td valign="top">Return the average value of all <i>X</i> within a group.</td></tr><tr><td valign="top" align="right">count(<i>X</i>)<br>count(*)</td><td valign="top">The first form return a count of the number of timesthat <i>X</i> is not NULL in a group.  The second form (with no argument)returns the total number of rows in the group.</td></tr><tr><td valign="top" align="right">max(<i>X</i>)</td><td valign="top">Return the maximum value of all values in the group.The usual sort order is used to determine the maximum.</td></tr><tr><td valign="top" align="right">min(<i>X</i>)</td><td valign="top">Return the minimum value of all values in the group.The usual sort order is used to determine the minimum.</td></tr><tr><td valign="top" align="right">sum(<i>X</i>)</td><td valign="top">Return the numeric sum of all values in the group.</td></tr></table>}Section INSERT insertSyntax {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>}puts {<p>The INSERT statement comes in two basic forms.  The first form(with the "VALUES" keyword) creates a single new row in an existing table.If no column-list is specified then the number of values mustbe the same as the number of columns in the table.  If a column-listis specified, then the number of values must match the number ofspecified columns.  Columns of the table that do not appear in thecolumn list are filled with the default value, or with NULL if notdefault value is specified.</p><p>The second form of the INSERT statement takes it data from aSELECT statement.  The number of columns in the result of theSELECT must exactly match the number of columns in the table ifno column list is specified, or it must match the number of columnsname in the column list.  A new entry is made in the tablefor every row of the SELECT result.  The SELECT may be simpleor compound.  If the SELECT statement has an ORDER BY clause,the ORDER BY is ignored.</p><p>The optional conflict-clause allows the specification of an alternativeconstraint conflict resolution algorithm to use during this one command.See the section titled<a href="#conflict">ON CONFLICT</a> for additional information.For compatibility with MySQL, the parser allows the use of thesingle keyword <a href="#replace">REPLACE</a> as an alias for "INSERT OR REPLACE".</p>}Section {ON CONFLICT clause} conflictSyntax {conflict-clause} {ON CONFLICT <conflict-algorithm>} {conflict-algorithm} {ROLLBACK | ABORT | FAIL | IGNORE | REPLACE}puts {<p>The ON CONFLICT clause is not a separate SQL command.  It is anon-standard clause that can appear in many other SQL commands.It is given its own section in this document because it is notpart of standard SQL and therefore might not be familiar.</p><p>The syntax for the ON CONFLICT clause is as shown above forthe CREATE TABLE, CREATE INDEX, and BEGIN TRANSACTION commands.For the COPY, INSERT, and UPDATE commands, the keywords"ON CONFLICT" are replaced by "OR", to make the syntax seem morenatural.  But the meaning of the clause is the same either way.</p><p>The ON CONFLICT clause specifies an algorithm used to resolveconstraint conflicts.  There are five choices: ROLLBACK, ABORT,FAIL, IGNORE, and REPLACE. The default algorithm is ABORT.  Thisis what they mean:</p><dl><dt><b>ROLLBACK</b></dt><dd><p>When a constraint violation occurs, an immediate ROLLBACKoccurs, thus ending the current transaction, and the command abortswith a return code of SQLITE_CONSTRAINT.  If no transaction isactive (other than the implied transaction that is created on everycommand) then this algorithm works the same as ABORT.</p></dd><dt><b>ABORT</b></dt><dd><p>When a constraint violation occurs, the command backs outany prior changes it might have made and aborts with a return codeof SQLITE_CONSTRAINT.  But no ROLLBACK is executed so changesfrom prior commands within the same transactionare preserved.  This is the default behavior.</p></dd><dt><b>FAIL</b></dt><dd><p>When a constraint violation occurs, the command aborts with areturn code SQLITE_CONSTRAINT.  But any changes to the database thatthe command made prior to encountering the constraint violationare preserved and are not backed out.  For example, if an UPDATEstatement encountered a constraint violation on the 100th row thatit attempts to update, then the first 99 row changes are preservedbut changes to rows 100 and beyond never occur.</p></dd><dt><b>IGNORE</b></dt><dd><p>When a constraint violation occurs, the one row that containsthe constraint violation is not inserted or changed.  But the commandcontinues executing normally.  Other rows before and after the row thatcontained the constraint violation continue to be inserted or updatednormally.  No error is returned.</p></dd><dt><b>REPLACE</b></dt><dd><p>When a UNIQUE constraint violation occurs, the pre-existing rowsthat are causing the constraint violation are removed prior to insertingor updating the current row.  Thus the insert or update always occurs.The command continues executing normally.  No error is returned.If a NOT NULL constraint violation occurs, the NULL value is replacedby the default value for that column.  If the column has no defaultvalue, then the ABORT algorithm is used.</p><p>When this conflict resolution strategy deletes rows in order tostatisfy a constraint, it does not invoke delete triggers on thoserows.  But that may change in a future release.</p></dd></dl><p>The conflict resolution algorithm can be specified in three places,in order from lowest to highest precedence:</p><ol><li><p>On individual constraints within a CREATE TABLE or CREATE INDEXstatement.</p></li><li><p>On a BEGIN TRANSACTION command.</p></li><li><p>In the OR clause of a COPY, INSERT, or UPDATE command.</p></li></ol><p>The algorithm specified in the OR clause of a COPY, INSERT, or UPDATEoverrides any algorithm specified on the BEGIN TRANSACTION command andthe algorithm specified on the BEGIN TRANSACTION command overrides thealgorithm specified in the a CREATE TABLE or CREATE INDEX.If no algorithm is specified anywhere, the ABORT algorithm is used.</p>}# <p>For additional information, see # <a href="conflict.html">conflict.html</a>.</p>Section PRAGMA pragmaSyntax {sql-statement} {PRAGMA <name> [= <value>] |PRAGMA <function>(<arg>)}puts {<p>The PRAGMA command is used to modify the operation of the SQLite library.The pragma command is experimental and specific pragma statements may beremoved or added in future releases of SQLite.  Use this commandwith caution.</p><p>The pragmas that take an integer <b><i>value</i></b> also accept symbolic names.  The strings "<b>on</b>", "<b>true</b>", and "<b>yes</b>" are equivalent to <b>1</b>.  The strings "<b>off</b>", "<b>false</b>", and "<b>no</b>" are equivalent to <b>0</b>.  These strings are case-insensitive, and do not require quotes.  An unrecognized string will be treated as <b>1</b>, and will not generate an error.  When the <i>value</i> is returned it is as an integer.</p><p>The current implementation supports the following pragmas:</p><ul><a name="pragma_cache_size"></a><li><p><b>PRAGMA cache_size;       <br>PRAGMA cache_size = </b><i>Number-of-pages</i><b>;</b></p>    <p>Query or change the maximum number of database disk pages that SQLite    will hold in memory at once.  Each page uses about 1.5K of memory.    The default cache size is 2000.  If you are doing UPDATEs or DELETEs    that change many rows of a database and you do not mind if SQLite    uses more memory, you can increase the cache size for a possible speed    improvement.</p>    <p>When you change the cache size using the cache_size pragma, the    change only endures for the current session.  The cache size reverts    to the default value when the database is closed and reopened.  Use    the <a href="#pragma_default_cache_size"><b>default_cache_size</b></a>     pragma to check the cache size permanently.</p></li><li><p><b>PRAGMA count_changes = ON; </b>(1)<b>       <br>PRAGMA count_changes = OFF;</b> (0)</p>    <p>When on, the COUNT_CHANGES pragma causes the callback function to    be invoked once for each DELETE, INSERT, or UPDATE operation.  The    argument is the number of rows that were changed.</p>    <p>This pragma may be removed from future versions of SQLite.    Consider using the <b>sqlite_changes()</b> API function instead.</p></li><li><p><b>PRAGMA database_list;</b></p>    <p>For each open database, invoke the callback function once with    information about that database.  Arguments include the index and     the name the datbase was attached with.  The first row will be for     the main database.  The second row will be for the database used to     store temporary tables.</p></li><a name="pragma_default_cache_size"></a><li><p><b>PRAGMA default_cache_size;       <br>PRAGMA default_cache_size = </b><i>Number-of-pages</i><b>;</b></p>    <p>Query or change the maximum number of database disk pages that SQLite    will hold in memory at once.  Each page uses 1K on disk and about 1.5K in memory.    This pragma works like the <a href="#pragma_cache_size"><b>cache_size</b></a>     pragma with the additional    feature that it changes the cache size persistently.  With this pragma,    you can set the cache size once and that setting is retained and reused    everytime you reopen the database.</p></li><a name="pragma_default_synchronous"></a><li><p><b>PRAGMA default_synchronous;       <br>PRAGMA default_synchronous = FULL; </b>(2)<b>       <br>PRAGMA default_synchronous = NORMAL; </b>(1)<b>       <br>PRAGMA default_synchronous = OFF; </b>(0)</p>    <p>Query or change the setting of the "synchronous" flag in    the database.  The first (query) form will return the setting as an     integer.  When synchronous is FULL (2), the SQLite database engine will    pause at critical moments to make sure that data has actually been     written to the disk surface before continuing.  This ensures that if    the operating system crashes or if there is a power failure, the database    will be uncorrupted after rebooting.  FULL synchronous is very     safe, but it is also slow.      When synchronous is NORMAL (1, the default), the SQLite database    engine will still pause at the most critical moments, but less often    than in FULL mode.  There is a very small (though non-zero) chance that    a power failure at just the wrong time could corrupt the database in    NORMAL mode.  But in practice, you are more likely to suffer    a catastrophic disk failure or some other unrecoverable hardware    fault.  So NORMAL is the default mode.    With synchronous OFF (0), SQLite continues without pausing    as soon as it has handed data off to the operating system.    If the application running SQLite crashes, the data will be safe, but    the database might become corrupted if the operating system    crashes or the computer loses power before that data has been written    to the disk surface.  On the other hand, some    operations are as much as 50 or more times faster with synchronous OFF.    </p>    <p>This pragma changes the synchronous mode persistently.  Once changed,    the mode stays as set even if the database is closed and reopened.  The    <a href="#pragma_synchronous"><b>synchronous</b></a> pragma does the same     thing but only applies the setting to the current session.</p></li><a name="pragma_default_temp_store"></a><li><p><b>PRAGMA default_temp_store;       <br>PRAGMA default_temp_store = DEFAULT; </b>(0)<b>       <br>PRAGMA default_temp_store = MEMORY; </b>(2)<b>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -