Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Comment: | Refresh all included SQLite core library documentation (e.g. SQL syntax). |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
3e112a45045e10f940ddbbeda0357b23 |
User & Date: | mistachkin 2014-02-05 01:39:53 |
2014-02-05
| ||
01:46 | Update table-of-contents topic names. check-in: 837439ff91 user: mistachkin tags: trunk | |
01:39 | Refresh all included SQLite core library documentation (e.g. SQL syntax). check-in: 3e112a4504 user: mistachkin tags: trunk | |
01:39 | Update version history docs. Closed-Leaf check-in: 6e651ad0df user: mistachkin tags: coreDocs | |
2014-02-04
| ||
22:55 | Reorganize the documentation files. check-in: 6fc137b4c3 user: mistachkin tags: trunk | |
Added Doc/Extra/Core/images/sqlite370_banner.gif.
cannot compute difference between binary files
Added Doc/Extra/Core/images/syntax/a.gif.
cannot compute difference between binary files
Added Doc/Extra/Core/images/syntax/alter-table-stmt.gif.
cannot compute difference between binary files
Added Doc/Extra/Core/images/syntax/analyze-stmt.gif.
cannot compute difference between binary files
Added Doc/Extra/Core/images/syntax/attach-stmt.gif.
cannot compute difference between binary files
Added Doc/Extra/Core/images/syntax/begin-stmt.gif.
cannot compute difference between binary files
Added Doc/Extra/Core/images/syntax/column-constraint.gif.
cannot compute difference between binary files
Added Doc/Extra/Core/images/syntax/column-def.gif.
cannot compute difference between binary files
Added Doc/Extra/Core/images/syntax/comment-syntax.gif.
cannot compute difference between binary files
Added Doc/Extra/Core/images/syntax/commit-stmt.gif.
cannot compute difference between binary files
Added Doc/Extra/Core/images/syntax/common-table-expression.gif.
cannot compute difference between binary files
Added Doc/Extra/Core/images/syntax/compound-operator.gif.
cannot compute difference between binary files
Added Doc/Extra/Core/images/syntax/compound-select-stmt.gif.
cannot compute difference between binary files
Added Doc/Extra/Core/images/syntax/conflict-clause.gif.
cannot compute difference between binary files
Added Doc/Extra/Core/images/syntax/create-index-stmt.gif.
cannot compute difference between binary files
Added Doc/Extra/Core/images/syntax/create-table-stmt.gif.
cannot compute difference between binary files
Added Doc/Extra/Core/images/syntax/create-trigger-stmt.gif.
cannot compute difference between binary files
Added Doc/Extra/Core/images/syntax/create-view-stmt.gif.
cannot compute difference between binary files
Added Doc/Extra/Core/images/syntax/create-virtual-table-stmt.gif.
cannot compute difference between binary files
Added Doc/Extra/Core/images/syntax/cte-table-name.gif.
cannot compute difference between binary files
Added Doc/Extra/Core/images/syntax/delete-stmt-limited.gif.
cannot compute difference between binary files
Added Doc/Extra/Core/images/syntax/delete-stmt.gif.
cannot compute difference between binary files
Added Doc/Extra/Core/images/syntax/detach-stmt.gif.
cannot compute difference between binary files
Added Doc/Extra/Core/images/syntax/drop-index-stmt.gif.
cannot compute difference between binary files
Added Doc/Extra/Core/images/syntax/drop-table-stmt.gif.
cannot compute difference between binary files
Added Doc/Extra/Core/images/syntax/drop-trigger-stmt.gif.
cannot compute difference between binary files
Added Doc/Extra/Core/images/syntax/drop-view-stmt.gif.
cannot compute difference between binary files
Added Doc/Extra/Core/images/syntax/expr.gif.
cannot compute difference between binary files
Added Doc/Extra/Core/images/syntax/factored-select-stmt.gif.
cannot compute difference between binary files
Added Doc/Extra/Core/images/syntax/floating-point-literal.gif.
cannot compute difference between binary files
Added Doc/Extra/Core/images/syntax/foreign-key-clause.gif.
cannot compute difference between binary files
Added Doc/Extra/Core/images/syntax/foreign-key-clause2.gif.
cannot compute difference between binary files
Added Doc/Extra/Core/images/syntax/indexed-column.gif.
cannot compute difference between binary files
Added Doc/Extra/Core/images/syntax/insert-stmt.gif.
cannot compute difference between binary files
Added Doc/Extra/Core/images/syntax/join-clause.gif.
cannot compute difference between binary files
Added Doc/Extra/Core/images/syntax/join-constraint.gif.
cannot compute difference between binary files
Added Doc/Extra/Core/images/syntax/join-op.gif.
cannot compute difference between binary files
Added Doc/Extra/Core/images/syntax/join-operator.gif.
cannot compute difference between binary files
Added Doc/Extra/Core/images/syntax/join-source.gif.
cannot compute difference between binary files
Added Doc/Extra/Core/images/syntax/literal-value.gif.
cannot compute difference between binary files
Added Doc/Extra/Core/images/syntax/numeric-literal.gif.
cannot compute difference between binary files
Added Doc/Extra/Core/images/syntax/ordering-term.gif.
cannot compute difference between binary files
Added Doc/Extra/Core/images/syntax/pragma-stmt.gif.
cannot compute difference between binary files
Added Doc/Extra/Core/images/syntax/pragma-value.gif.
cannot compute difference between binary files
Added Doc/Extra/Core/images/syntax/qualified-table-name.gif.
cannot compute difference between binary files
Added Doc/Extra/Core/images/syntax/raise-function.gif.
cannot compute difference between binary files
Added Doc/Extra/Core/images/syntax/recursive-cte.gif.
cannot compute difference between binary files
Added Doc/Extra/Core/images/syntax/reindex-stmt.gif.
cannot compute difference between binary files
Added Doc/Extra/Core/images/syntax/release-stmt.gif.
cannot compute difference between binary files
Added Doc/Extra/Core/images/syntax/result-column.gif.
cannot compute difference between binary files
Added Doc/Extra/Core/images/syntax/rollback-stmt.gif.
cannot compute difference between binary files
Added Doc/Extra/Core/images/syntax/savepoint-stmt.gif.
cannot compute difference between binary files
Added Doc/Extra/Core/images/syntax/select-core.gif.
cannot compute difference between binary files
Added Doc/Extra/Core/images/syntax/select-stmt.gif.
cannot compute difference between binary files
Added Doc/Extra/Core/images/syntax/signed-number.gif.
cannot compute difference between binary files
Added Doc/Extra/Core/images/syntax/simple-select-stmt.gif.
cannot compute difference between binary files
Added Doc/Extra/Core/images/syntax/single-source.gif.
cannot compute difference between binary files
Added Doc/Extra/Core/images/syntax/sql-stmt-list.gif.
cannot compute difference between binary files
Added Doc/Extra/Core/images/syntax/sql-stmt.gif.
cannot compute difference between binary files
Added Doc/Extra/Core/images/syntax/table-constraint.gif.
cannot compute difference between binary files
Added Doc/Extra/Core/images/syntax/table-or-subquery.gif.
cannot compute difference between binary files
Added Doc/Extra/Core/images/syntax/type-name.gif.
cannot compute difference between binary files
Added Doc/Extra/Core/images/syntax/update-stmt-limited.gif.
cannot compute difference between binary files
Added Doc/Extra/Core/images/syntax/update-stmt.gif.
cannot compute difference between binary files
Added Doc/Extra/Core/images/syntax/vacuum-stmt.gif.
cannot compute difference between binary files
Added Doc/Extra/Core/images/syntax/with-clause.gif.
cannot compute difference between binary files
Added Doc/Extra/Core/lang.html.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html><head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Query Language Understood by SQLite</title> <style type="text/css"> body { margin: auto; font-family: Verdana, sans-serif; padding: 8px 1%; } a { color: #044a64 } a:visited { color: #734559 } .logo { position:absolute; margin:3px; } .tagline { float:right; text-align:right; font-style:italic; width:300px; margin:12px; margin-top:58px; } .menubar { clear: both; border-radius: 8px; background: #044a64; padding: 0px; margin: 0px; cell-spacing: 0px; } .toolbar { text-align: center; line-height: 1.6em; margin: 0; padding: 0px 8px; } .toolbar a { color: white; text-decoration: none; padding: 6px 12px; } .toolbar a:visited { color: white; } .toolbar a:hover { color: #044a64; background: white; } .content { margin: 5%; } .content dt { font-weight:bold; } .content dd { margin-bottom: 25px; margin-left:20%; } .content ul { padding:0px; padding-left: 15px; margin:0px; } /* Things for "fancyformat" documents start here. */ .fancy img+p {font-style:italic} .fancy .codeblock i { color: darkblue; } .fancy h1,.fancy h2,.fancy h3,.fancy h4 {font-weight:normal;color:#044a64} .fancy h2 { margin-left: 10px } .fancy h3 { margin-left: 20px } .fancy h4 { margin-left: 30px } .fancy th {white-space:nowrap;text-align:left;border-bottom:solid 1px #444} .fancy th, .fancy td {padding: 0.2em 1ex; vertical-align:top} .fancy #toc a { color: darkblue ; text-decoration: none } .fancy .todo { color: #AA3333 ; font-style : italic } .fancy .todo:before { content: 'TODO:' } .fancy p.todo { border: solid #AA3333 1px; padding: 1ex } .fancy img { display:block; } .fancy :link:hover, .fancy :visited:hover { background: wheat } .fancy p,.fancy ul,.fancy ol { margin: 1em 5ex } .fancy li p { margin: 1em 0 } /* End of "fancyformat" specific rules. */ </style> </head> <body> <div><!-- container div to satisfy validator --> <a href="index.html"> <img class="logo" src="images/sqlite370_banner.gif" alt="SQLite Logo" border="0"></a> <div><!-- IE hack to prevent disappearing logo--></div> <div class="tagline">Small. Fast. Reliable.<br>Choose any three.</div> <table width=100% class="menubar"><tr> <td width=100%> <div class="toolbar"> <a href="about.html">About</a> <a href="sitemap.html">Sitemap</a> <a href="docs.html">Documentation</a> <a href="download.html">Download</a> <a href="copyright.html">License</a> <a href="news.html">News</a> <a href="support.html">Support</a> </div> <script> gMsg = "Search SQLite Docs..." function entersearch() { var q = document.getElementById("q"); if( q.value == gMsg ) { q.value = "" } q.style.color = "black" q.style.fontStyle = "normal" } function leavesearch() { var q = document.getElementById("q"); if( q.value == "" ) { q.value = gMsg q.style.color = "#044a64" q.style.fontStyle = "italic" } } function hideorshow(btn,obj){ var x = document.getElementById(obj); var b = document.getElementById(btn); if( x.style.display!='none' ){ x.style.display = 'none'; b.innerHTML='show'; }else{ x.style.display = ''; b.innerHTML='hide'; } return false; } </script> <td> <div style="padding:0 1em 0px 0;white-space:nowrap"> <form name=f method="GET" action="http://www.sqlite.org/search"> <input id=q name=q type=text onfocus="entersearch()" onblur="leavesearch()" style="width:24ex;padding:1px 1ex; border:solid white 1px; font-size:0.9em ; font-style:italic;color:#044a64;" value="Search SQLite Docs..."> <input type=submit value="Go" style="border:solid white 1px;background-color:#044a64;color:white;font-size:0.9em;padding:0 1ex"> </form> </div> </table> <div class=startsearch></div> <h1 align=center>SQL As Understood By SQLite</h1> <p>SQLite understands most of the standard SQL language. But it does <a href="omitted.html">omit some features</a> while at the same time adding a few features of its own. This document attempts to describe precisely what parts of the SQL language SQLite does and does not support. A list of <a href="lang_keywords.html">SQL keywords</a> is also provided. The SQL language syntax is described by <a href="syntaxdiagrams.html">syntax diagrams</a>. <p>The following syntax documentation topics are available:</p> <table width="100%" cellpadding="5" border="0"> <tr><td valign="top"><ul> <li><a href="lang_aggfunc.html">aggregate functions</a></li><li><a href="lang_altertable.html">ALTER TABLE</a></li><li><a href="lang_analyze.html">ANALYZE</a></li><li><a href="lang_attach.html">ATTACH DATABASE</a></li><li><a href="lang_transaction.html">BEGIN TRANSACTION</a></li><li><a href="lang_comment.html">comment</a></li><li><a href="lang_transaction.html">COMMIT TRANSACTION</a></li><li><a href="lang_corefunc.html">core functions</a></li><li><a href="lang_createindex.html">CREATE INDEX</a></li><li><a href="lang_createtable.html">CREATE TABLE</a></li><li><a href="lang_createtrigger.html">CREATE TRIGGER</a></li><li><a href="lang_createview.html">CREATE VIEW</a></li><li><a href="lang_createvtab.html">CREATE VIRTUAL TABLE</a></li></ul></td><td valign="top"><ul><li><a href="lang_datefunc.html">date and time functions</a></li><li><a href="lang_delete.html">DELETE</a></li><li><a href="lang_detach.html">DETACH DATABASE</a></li><li><a href="lang_dropindex.html">DROP INDEX</a></li><li><a href="lang_droptable.html">DROP TABLE</a></li><li><a href="lang_droptrigger.html">DROP TRIGGER</a></li><li><a href="lang_dropview.html">DROP VIEW</a></li><li><a href="lang_transaction.html">END TRANSACTION</a></li><li><a href="lang_explain.html">EXPLAIN</a></li><li><a href="lang_expr.html">expression</a></li><li><a href="lang_indexedby.html">INDEXED BY</a></li><li><a href="lang_insert.html">INSERT</a></li><li><a href="lang_keywords.html">keywords</a></li></ul></td><td valign="top"><ul><li><a href="lang_conflict.html">ON CONFLICT clause</a></li><li><a href="pragma.html#syntax">PRAGMA</a></li><li><a href="lang_reindex.html">REINDEX</a></li><li><a href="lang_savepoint.html">RELEASE SAVEPOINT</a></li><li><a href="lang_replace.html">REPLACE</a></li><li><a href="lang_transaction.html">ROLLBACK TRANSACTION</a></li><li><a href="lang_savepoint.html">SAVEPOINT</a></li><li><a href="lang_select.html">SELECT</a></li><li><a href="lang_update.html">UPDATE</a></li><li><a href="lang_vacuum.html">VACUUM</a></li><li><a href="lang_with.html">WITH clause</a></li> </ul></td></tr></table> <p>The routines <a href="c3ref/prepare.html">sqlite3_prepare_v2()</a>, <a href="c3ref/prepare.html">sqlite3_prepare()</a>, <a href="c3ref/prepare.html">sqlite3_prepare16()</a>, <a href="c3ref/prepare.html">sqlite3_prepare16_v2()</a>, <a href="c3ref/exec.html">sqlite3_exec()</a>, and <a href="c3ref/free_table.html">sqlite3_get_table()</a> accept an SQL statement list (sql-stmt-list) which is a semicolon-separated list of statements.</p> <p><b><a href="syntaxdiagrams.html#sql-stmt-list">sql-stmt-list:</a></b></p><blockquote> <img alt="syntax diagram sql-stmt-list" src="images/syntax/sql-stmt-list.gif"></img> </blockquote> <p>Each SQL statement in the statement list is an instance of the following:</p> <p><b><a href="syntaxdiagrams.html#sql-stmt">sql-stmt:</a></b></p><blockquote> <img alt="syntax diagram sql-stmt" src="images/syntax/sql-stmt.gif"></img> </blockquote> |
Added Doc/Extra/Core/lang_aggfunc.html.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html><head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>SQLite Query Language: Aggregate Functions</title> <style type="text/css"> body { margin: auto; font-family: Verdana, sans-serif; padding: 8px 1%; } a { color: #044a64 } a:visited { color: #734559 } .logo { position:absolute; margin:3px; } .tagline { float:right; text-align:right; font-style:italic; width:300px; margin:12px; margin-top:58px; } .menubar { clear: both; border-radius: 8px; background: #044a64; padding: 0px; margin: 0px; cell-spacing: 0px; } .toolbar { text-align: center; line-height: 1.6em; margin: 0; padding: 0px 8px; } .toolbar a { color: white; text-decoration: none; padding: 6px 12px; } .toolbar a:visited { color: white; } .toolbar a:hover { color: #044a64; background: white; } .content { margin: 5%; } .content dt { font-weight:bold; } .content dd { margin-bottom: 25px; margin-left:20%; } .content ul { padding:0px; padding-left: 15px; margin:0px; } /* Things for "fancyformat" documents start here. */ .fancy img+p {font-style:italic} .fancy .codeblock i { color: darkblue; } .fancy h1,.fancy h2,.fancy h3,.fancy h4 {font-weight:normal;color:#044a64} .fancy h2 { margin-left: 10px } .fancy h3 { margin-left: 20px } .fancy h4 { margin-left: 30px } .fancy th {white-space:nowrap;text-align:left;border-bottom:solid 1px #444} .fancy th, .fancy td {padding: 0.2em 1ex; vertical-align:top} .fancy #toc a { color: darkblue ; text-decoration: none } .fancy .todo { color: #AA3333 ; font-style : italic } .fancy .todo:before { content: 'TODO:' } .fancy p.todo { border: solid #AA3333 1px; padding: 1ex } .fancy img { display:block; } .fancy :link:hover, .fancy :visited:hover { background: wheat } .fancy p,.fancy ul,.fancy ol { margin: 1em 5ex } .fancy li p { margin: 1em 0 } /* End of "fancyformat" specific rules. */ </style> </head> <body> <div><!-- container div to satisfy validator --> <a href="index.html"> <img class="logo" src="images/sqlite370_banner.gif" alt="SQLite Logo" border="0"></a> <div><!-- IE hack to prevent disappearing logo--></div> <div class="tagline">Small. Fast. Reliable.<br>Choose any three.</div> <table width=100% class="menubar"><tr> <td width=100%> <div class="toolbar"> <a href="about.html">About</a> <a href="sitemap.html">Sitemap</a> <a href="docs.html">Documentation</a> <a href="download.html">Download</a> <a href="copyright.html">License</a> <a href="news.html">News</a> <a href="support.html">Support</a> </div> <script> gMsg = "Search SQLite Docs..." function entersearch() { var q = document.getElementById("q"); if( q.value == gMsg ) { q.value = "" } q.style.color = "black" q.style.fontStyle = "normal" } function leavesearch() { var q = document.getElementById("q"); if( q.value == "" ) { q.value = gMsg q.style.color = "#044a64" q.style.fontStyle = "italic" } } function hideorshow(btn,obj){ var x = document.getElementById(obj); var b = document.getElementById(btn); if( x.style.display!='none' ){ x.style.display = 'none'; b.innerHTML='show'; }else{ x.style.display = ''; b.innerHTML='hide'; } return false; } </script> <td> <div style="padding:0 1em 0px 0;white-space:nowrap"> <form name=f method="GET" action="http://www.sqlite.org/search"> <input id=q name=q type=text onfocus="entersearch()" onblur="leavesearch()" style="width:24ex;padding:1px 1ex; border:solid white 1px; font-size:0.9em ; font-style:italic;color:#044a64;" value="Search SQLite Docs..."> <input type=submit value="Go" style="border:solid white 1px;background-color:#044a64;color:white;font-size:0.9em;padding:0 1ex"> </form> </div> </table> <div class=startsearch></div> <h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>Aggregate Functions</h2> <p> The aggregate functions shown below are available by default. Additional aggregate functions written in C may be added using the <a href="c3ref/create_function.html">sqlite3_create_function()</a></a> API.</p> <p> In any aggregate function that takes a single argument, that argument can be preceded by the keyword DISTINCT. In such cases, duplicate elements are filtered before being passed into the aggregate function. 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. </p> <table border=0 cellpadding=10> <tr><td valign="top" align="right" width="120"><a name="avg"></a> avg(<i>X</i>)</td><td valign="top"> The avg() function returns the average value of all non-NULL <i>X</i> 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. </td></tr><tr><td valign="top" align="right" width="120"><a name="count"></a> count(<i>X</i>)<br />count(*)</td><td valign="top"> The count(X) function returns a count of the number of times that <i>X</i> is not NULL in a group. The count(*) function (with no arguments) returns the total number of rows in the group. </td></tr><tr><td valign="top" align="right" width="120"><a name="groupconcat"></a> group_concat(<i>X</i>)<br />group_concat(<i>X</i>,<i>Y</i>)</td><td valign="top"> The group_concat() function returns a string which is the concatenation of all non-NULL values of <i>X</i>. If parameter <i>Y</i> is present then it is used as the separator between instances of <i>X</i>. A comma (",") is used as the separator if <i>Y</i> is omitted. The order of the concatenated elements is arbitrary. </td></tr><tr><td valign="top" align="right" width="120"><a name="maxggunc"></a> max(<i>X</i>)</td><td valign="top"> 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. </td></tr><tr><td valign="top" align="right" width="120"><a name="minggunc"></a> min(<i>X</i>)</td><td valign="top"> 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. </td></tr><tr><td valign="top" align="right" width="120"><a name="sumunc"></a> sum(<i>X</i>)<br />total(<i>X</i>)</td><td valign="top"> 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 but the SQL standard requires it and most other SQL database engines implement sum() that way so SQLite does it in the same way in order to be compatible. The non-standard total() function is provided as a convenient way to work around this design problem in the SQL language.</p> <p>The result of total() is always a floating point value. The result of sum() is an integer value if all non-NULL inputs are integers. If any input to sum() is neither an integer or a NULL then sum() returns a floating point value which might be an approximation to the true sum.</p> <p>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. </td></tr> </table> |
Changes to Doc/Extra/Core/lang_altertable.html.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
<html dir="LTR" xmlns="http://www.w3.org/1999/xhtml" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:MSHelp="http://msdn.microsoft.com/mshelp" xmlns:tool="http://www.microsoft.com/tooltip" xmlns:ndoc="urn:ndoc-preprocess"> <head> <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252" /> <title>ALTER TABLE</title> <link rel="stylesheet" type="text/css" href="../Include/ndoc.css" /> </head> <body> <div id="header"> <table width="100%" id="topTable"> <tr id="headerTableRow1"> <td align="left"> <span id="runningHeaderText">ALTER TABLE</span> </td> </tr> <tr id="headerTableRow2"> <td align="left"> <span id="nsrTitle">SQLite Language Reference Documentation</span> </td> </tr> <tr id="headerTableRow3" style="display:none"> <td> <a id="seeAlsoSectionLink" href="#seeAlsoToggle" onclick="OpenSection(seeAlsoToggle)">See Also</a> <a id="exampleSectionLink" href="#codeExampleToggle" onclick="OpenSection(codeExampleToggle)">Example</a> </td> </tr> </table> <table width="100%" id="bottomTable" cellspacing="0" cellpadding="0" style="display:none"> <tr> <td> <span onclick="ExpandCollapseAll(toggleAllImage)" style="cursor:default;" onkeypress="ExpandCollapseAll_CheckKey(toggleAllImage)" tabindex="0"> <img ID="toggleAllImage" class="toggleAll" src="collall.gif" /> <label id="collapseAllLabel" for="toggleAllImage" style="display: none;"> Collapse All </label> <label id="expandAllLabel" for="toggleAllImage" style="display: none;"> Expand All </label> </span> </td> </tr> </table> </div> <div id="mainSection"> <div id="mainBody"> <h1 class="heading"> SQL As Understood By SQLite</h1> <h4> ALTER TABLE</h4> <p> <table cellpadding="10"> <tr> <td align="right" width="1%" nowrap> <i><font color="#ff3434">sql-statement</font></i> ::=</td> <td> <b><font color="#2c2cf0">ALTER TABLE </font></b>[<b><font color="#2c2cf0"></font></b><i><font color="#ff3434">database-name</font></i><b><font color="#2c2cf0"> <big>.</big></font></b>]<b><font color="#2c2cf0"> </font></b><i><font color="#ff3434">table-name</font></i><b><font color="#2c2cf0"> </font></b><i><font color="#ff3434">alteration</font></i><b><font color="#2c2cf0"></font></b></td> </tr> <tr> <td align="right" width="1%" nowrap> <i><font color="#ff3434">alteration</font></i> ::=</td> <td> <b><font color="#2c2cf0">RENAME TO </font></b><i><font color="#ff3434">new-table-name</font></i><b><font color="#2c2cf0"></font></b></td> </tr> <tr> <td align="right" width="1%" nowrap> <i><font color="#ff3434">alteration</font></i> ::=</td> <td> <b><font color="#2c2cf0">ADD </font></b>[<b><font color="#2c2cf0">COLUMN</font></b>]<b><font color="#2c2cf0"> </font></b><i><font color="#ff3434">column-def</font></i><b><font color="#2c2cf0"></font></b></td> </tr> </table> </p> <p> SQLite's version of the ALTER TABLE command allows the user to rename or add a new column to an existing table. It is not possible to remove a column from a table. </p> <p> The RENAME TO syntax is used to rename the table identified by <i>[database-name.]table-name</i> to <i>new-table-name</i>. This command cannot be used to move a table between attached databases, only to rename a table within the same database.</p> <p> If the table being renamed has triggers or indices, then these remain attached to the table after it has been renamed. However, if there are any view definitions, or statements executed by triggers that refer to the table being renamed, these are not automatically modified to use the new table name. If this is required, the triggers or view definitions must be dropped and recreated to use the new table name by hand. </p> <p> The ADD [COLUMN] syntax is used to add a new column to an existing table. The new column is always appended to the end of the list of existing columns. <i>Column-def</i> may take any of the forms permissable in a CREATE TABLE statement, with the following restrictions: </p> <ul> <li>The column may not have a PRIMARY KEY or UNIQUE constraint. </li> <li>The column may not have a default value of CURRENT_TIME, CURRENT_DATE or CURRENT_TIMESTAMP. </li> <li>If a NOT NULL constraint is specified, then the column must have a default value other than NULL. </li> </ul> <p> The execution time of the ALTER TABLE command is independent of the amount of data in the table. The ALTER TABLE command runs as quickly on a table with 10 million rows as it does on a table with 1 row. </p> <p> After ADD COLUMN has been run on a database, that database will not be readable by SQLite version 3.1.3 and earlier until the database is <a href="lang_vacuum.html"> VACUUM</a>ed.</p> <p> </p> <hr> <div id="footer"> <p> </p> <p> </p> </div> </div> </div> </body> </html> |
| | | | | < | > | | < < > > | | < > | | | | | | | | < < > > | | | | | | | < > | | | | | < > | | | < > | | | < < < > > > | | | | | | | | | | | | | | < > | | > > > > > > > > > > > > > > > > > > > > > > > | < < < > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | < < < > > > > > > | | < < < > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | < > | > > | | < > | | | | | | | < > > > > > > > > > | | < > > | < | | | < > | | > > > | < > > > > > > > | | | | < > | | < < < < < < < < < < < < < < > > |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html><head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>SQLite Query Language: ALTER TABLE</title> <style type="text/css"> body { margin: auto; font-family: Verdana, sans-serif; padding: 8px 1%; } a { color: #044a64 } a:visited { color: #734559 } .logo { position:absolute; margin:3px; } .tagline { float:right; text-align:right; font-style:italic; width:300px; margin:12px; margin-top:58px; } .menubar { clear: both; border-radius: 8px; background: #044a64; padding: 0px; margin: 0px; cell-spacing: 0px; } .toolbar { text-align: center; line-height: 1.6em; margin: 0; padding: 0px 8px; } .toolbar a { color: white; text-decoration: none; padding: 6px 12px; } .toolbar a:visited { color: white; } .toolbar a:hover { color: #044a64; background: white; } .content { margin: 5%; } .content dt { font-weight:bold; } .content dd { margin-bottom: 25px; margin-left:20%; } .content ul { padding:0px; padding-left: 15px; margin:0px; } /* Things for "fancyformat" documents start here. */ .fancy img+p {font-style:italic} .fancy .codeblock i { color: darkblue; } .fancy h1,.fancy h2,.fancy h3,.fancy h4 {font-weight:normal;color:#044a64} .fancy h2 { margin-left: 10px } .fancy h3 { margin-left: 20px } .fancy h4 { margin-left: 30px } .fancy th {white-space:nowrap;text-align:left;border-bottom:solid 1px #444} .fancy th, .fancy td {padding: 0.2em 1ex; vertical-align:top} .fancy #toc a { color: darkblue ; text-decoration: none } .fancy .todo { color: #AA3333 ; font-style : italic } .fancy .todo:before { content: 'TODO:' } .fancy p.todo { border: solid #AA3333 1px; padding: 1ex } .fancy img { display:block; } .fancy :link:hover, .fancy :visited:hover { background: wheat } .fancy p,.fancy ul,.fancy ol { margin: 1em 5ex } .fancy li p { margin: 1em 0 } /* End of "fancyformat" specific rules. */ </style> </head> <body> <div><!-- container div to satisfy validator --> <a href="index.html"> <img class="logo" src="images/sqlite370_banner.gif" alt="SQLite Logo" border="0"></a> <div><!-- IE hack to prevent disappearing logo--></div> <div class="tagline">Small. Fast. Reliable.<br>Choose any three.</div> <table width=100% class="menubar"><tr> <td width=100%> <div class="toolbar"> <a href="about.html">About</a> <a href="sitemap.html">Sitemap</a> <a href="docs.html">Documentation</a> <a href="download.html">Download</a> <a href="copyright.html">License</a> <a href="news.html">News</a> <a href="support.html">Support</a> </div> <script> gMsg = "Search SQLite Docs..." function entersearch() { var q = document.getElementById("q"); if( q.value == gMsg ) { q.value = "" } q.style.color = "black" q.style.fontStyle = "normal" } function leavesearch() { var q = document.getElementById("q"); if( q.value == "" ) { q.value = gMsg q.style.color = "#044a64" q.style.fontStyle = "italic" } } function hideorshow(btn,obj){ var x = document.getElementById(obj); var b = document.getElementById(btn); if( x.style.display!='none' ){ x.style.display = 'none'; b.innerHTML='show'; }else{ x.style.display = ''; b.innerHTML='hide'; } return false; } </script> <td> <div style="padding:0 1em 0px 0;white-space:nowrap"> <form name=f method="GET" action="http://www.sqlite.org/search"> <input id=q name=q type=text onfocus="entersearch()" onblur="leavesearch()" style="width:24ex;padding:1px 1ex; border:solid white 1px; font-size:0.9em ; font-style:italic;color:#044a64;" value="Search SQLite Docs..."> <input type=submit value="Go" style="border:solid white 1px;background-color:#044a64;color:white;font-size:0.9em;padding:0 1ex"> </form> </div> </table> <div class=startsearch></div> <h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>ALTER TABLE</h2><p><b><a href="syntaxdiagrams.html#alter-table-stmt">alter-table-stmt:</a></b> <button id='x729' onclick='hideorshow("x729","x730")'>hide</button></p> <blockquote id='x730'> <img alt="syntax diagram alter-table-stmt" src="images/syntax/alter-table-stmt.gif" /> <p><b><a href="syntaxdiagrams.html#column-def">column-def:</a></b> <button id='x731' onclick='hideorshow("x731","x732")'>show</button></p> <blockquote id='x732' style='display:none;'> <img alt="syntax diagram column-def" src="images/syntax/column-def.gif" /> <p><b><a href="syntaxdiagrams.html#column-constraint">column-constraint:</a></b> <button id='x733' onclick='hideorshow("x733","x734")'>show</button></p> <blockquote id='x734' style='display:none;'> <img alt="syntax diagram column-constraint" src="images/syntax/column-constraint.gif" /> <p><b><a href="syntaxdiagrams.html#conflict-clause">conflict-clause:</a></b> <button id='x735' onclick='hideorshow("x735","x736")'>show</button></p> <blockquote id='x736' style='display:none;'> <img alt="syntax diagram conflict-clause" src="images/syntax/conflict-clause.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#expr">expr:</a></b> <button id='x737' onclick='hideorshow("x737","x738")'>show</button></p> <blockquote id='x738' style='display:none;'> <img alt="syntax diagram expr" src="images/syntax/expr.gif" /> <p><b><a href="syntaxdiagrams.html#raise-function">raise-function:</a></b> <button id='x739' onclick='hideorshow("x739","x740")'>show</button></p> <blockquote id='x740' style='display:none;'> <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#select-stmt">select-stmt:</a></b> <button id='x741' onclick='hideorshow("x741","x742")'>show</button></p> <blockquote id='x742' style='display:none;'> <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" /> <p><b><a href="syntaxdiagrams.html#common-table-expression">common-table-expression:</a></b> <button id='x743' onclick='hideorshow("x743","x744")'>show</button></p> <blockquote id='x744' style='display:none;'> <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#compound-operator">compound-operator:</a></b> <button id='x745' onclick='hideorshow("x745","x746")'>show</button></p> <blockquote id='x746' style='display:none;'> <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#join-clause">join-clause:</a></b> <button id='x747' onclick='hideorshow("x747","x748")'>show</button></p> <blockquote id='x748' style='display:none;'> <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" /> <p><b><a href="syntaxdiagrams.html#join-constraint">join-constraint:</a></b> <button id='x749' onclick='hideorshow("x749","x750")'>show</button></p> <blockquote id='x750' style='display:none;'> <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#join-operator">join-operator:</a></b> <button id='x751' onclick='hideorshow("x751","x752")'>show</button></p> <blockquote id='x752' style='display:none;'> <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" /> </blockquote> </blockquote> <p><b><a href="syntaxdiagrams.html#ordering-term">ordering-term:</a></b> <button id='x753' onclick='hideorshow("x753","x754")'>show</button></p> <blockquote id='x754' style='display:none;'> <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#result-column">result-column:</a></b> <button id='x755' onclick='hideorshow("x755","x756")'>show</button></p> <blockquote id='x756' style='display:none;'> <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#table-or-subquery">table-or-subquery:</a></b> <button id='x757' onclick='hideorshow("x757","x758")'>show</button></p> <blockquote id='x758' style='display:none;'> <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" /> </blockquote> </blockquote> </blockquote> <p><b><a href="syntaxdiagrams.html#foreign-key-clause">foreign-key-clause:</a></b> <button id='x759' onclick='hideorshow("x759","x760")'>show</button></p> <blockquote id='x760' style='display:none;'> <img alt="syntax diagram foreign-key-clause" src="images/syntax/foreign-key-clause.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#literal-value">literal-value:</a></b> <button id='x761' onclick='hideorshow("x761","x762")'>show</button></p> <blockquote id='x762' style='display:none;'> <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#signed-number">signed-number:</a></b> <button id='x763' onclick='hideorshow("x763","x764")'>show</button></p> <blockquote id='x764' style='display:none;'> <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" /> </blockquote> </blockquote> <p><b><a href="syntaxdiagrams.html#type-name">type-name:</a></b> <button id='x765' onclick='hideorshow("x765","x766")'>show</button></p> <blockquote id='x766' style='display:none;'> <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" /> <p><b><a href="syntaxdiagrams.html#signed-number">signed-number:</a></b> <button id='x767' onclick='hideorshow("x767","x768")'>show</button></p> <blockquote id='x768' style='display:none;'> <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" /> </blockquote> </blockquote> </blockquote> </blockquote> <p>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. </p> <p> The RENAME TO syntax is used to rename the table identified by <i>[database-name.]table-name</i> to <i>new-table-name</i>. This command cannot be used to move a table between attached databases, only to rename a table within the same database.</p> <p> If the table being renamed has triggers or indices, then these remain attached to the table after it has been renamed. However, if there are any view definitions, or statements executed by triggers that refer to the table being renamed, these are not automatically modified to use the new table name. If this is required, the triggers or view definitions must be dropped and recreated to use the new table name by hand. </p> <p>If <a href="foreignkeys.html">foreign key constraints</a> are <a href="pragma.html#pragma_foreign_keys">enabled</a> when a table is renamed, then any <a href="syntaxdiagrams.html#foreign-key-clause">REFERENCES clauses</a> in any table (either the table being renamed or some other table) that refer to the table being renamed are modified to refer to the renamed table by its new name. <p> The ADD COLUMN syntax is used to add a new column to an existing table. The new column is always appended to the end of the list of existing columns. The <a href="syntaxdiagrams.html#column-def">column-def</a> rule defines the characteristics of the new column. The new column may take any of the forms permissible in a <a href="lang_createtable.html">CREATE TABLE</a> statement, with the following restrictions: <ul> <li>The column may not have a PRIMARY KEY or UNIQUE constraint.</li> <li>The column may not have a default value of CURRENT_TIME, CURRENT_DATE, CURRENT_TIMESTAMP, or an expression in parentheses.</li> <li>If a NOT NULL constraint is specified, then the column must have a default value other than NULL. <li>If <a href="foreignkeys.html">foreign key constraints</a> are <a href="pragma.html#pragma_foreign_keys">enabled</a> and a column with a <a href="syntaxdiagrams.html#foreign-key-clause">REFERENCES clause</a> is added, the column must have a default value of NULL. </ul> <p>Note also that when adding a <a href="lang_createtable.html#ckconst">CHECK constraint</a>, the CHECK constraint is not tested against preexisting rows of the table. This can result in a table that contains data that is in violation of the CHECK constraint. Future versions of SQLite might change to validate CHECK constraints as they are added.</p> <p> The execution time of the ALTER TABLE command is independent of the amount of data in the table. The ALTER TABLE command runs as quickly on a table with 10 million rows as it does on a table with 1 row. </p> <p>After ADD COLUMN has been run on a database, that database will not be readable by SQLite version 3.1.3 and earlier.</p> |
Changes to Doc/Extra/Core/lang_analyze.html.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
<html dir="LTR" xmlns="http://www.w3.org/1999/xhtml" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:MSHelp="http://msdn.microsoft.com/mshelp" xmlns:tool="http://www.microsoft.com/tooltip" xmlns:ndoc="urn:ndoc-preprocess"> <head> <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252" /> <title>ANALYZE</title> <link rel="stylesheet" type="text/css" href="../Include/ndoc.css" /> </head> <body> <div id="header"> <table width="100%" id="topTable"> <tr id="headerTableRow1"> <td align="left"> <span id="runningHeaderText">ANALYZE</span> </td> </tr> <tr id="headerTableRow2"> <td align="left"> <span id="nsrTitle">SQLite Language Reference Documentation</span> </td> </tr> <tr id="headerTableRow3" style="display:none"> <td> <a id="seeAlsoSectionLink" href="#seeAlsoToggle" onclick="OpenSection(seeAlsoToggle)">See Also</a> <a id="exampleSectionLink" href="#codeExampleToggle" onclick="OpenSection(codeExampleToggle)">Example</a> </td> </tr> </table> <table width="100%" id="bottomTable" cellspacing="0" cellpadding="0" style="display:none"> <tr> <td> <span onclick="ExpandCollapseAll(toggleAllImage)" style="cursor:default;" onkeypress="ExpandCollapseAll_CheckKey(toggleAllImage)" tabindex="0"> <img ID="toggleAllImage" class="toggleAll" src="collall.gif" /> <label id="collapseAllLabel" for="toggleAllImage" style="display: none;"> Collapse All </label> <label id="expandAllLabel" for="toggleAllImage" style="display: none;"> Expand All </label> </span> </td> </tr> </table> </div> <div id="mainSection"> <div id="mainBody"> <h1 class="heading"> SQL As Understood By SQLite</h1> <h4> ANALYZE</h4> <p> <table cellpadding="10"> <tr> <td align="right" width="1%" nowrap> <i><font color="#ff3434">sql-statement</font></i> ::=</td> <td> <b><font color="#2c2cf0">ANALYZE</font></b></td> </tr> </table> <table cellpadding="10"> <tr> <td align="right" width="1%" nowrap> <i><font color="#ff3434">sql-statement</font></i> ::=</td> <td> <b><font color="#2c2cf0">ANALYZE </font></b><i><font color="#ff3434">database-name</font></i><b><font color="#2c2cf0"></font></b></td> </tr> </table> <table cellpadding="10"> <tr> <td align="right" width="1%" nowrap> <i><font color="#ff3434">sql-statement</font></i> ::=</td> <td> <b><font color="#2c2cf0">ANALYZE </font></b>[<b><font color="#2c2cf0"></font></b><i><font color="#ff3434">database-name</font></i><b><font color="#2c2cf0"> <big>.</big></font></b>]<b><font color="#2c2cf0"> </font></b><i><font color="#ff3434">table-name</font></i><b><font color="#2c2cf0"></font></b></td> </tr> </table> </p> <p> The ANALYZE command gathers statistics about indices and stores them in a special tables in the database where the query optimizer can use them to help make better index choices. If no arguments are given, all indices in all attached databases are analyzed. If a database name is given as the argument, all indices in that one database are analyzed. If the argument is a table name, then only indices associated with that one table are analyzed.</p> <p> The initial implementation stores all statistics in a single table named <b>sqlite_stat1</b>. Future enhancements may create additional tables with the same name pattern except with the "1" changed to a different digit. The <b>sqlite_stat1</b> table cannot be <a href="lang_droptable.html">DROP</a>ped, but all the content can be <a href="lang_delete.html"> DELETE</a>d which has the same effect.</p> <p> </p> <hr> <div id="footer"> <p> </p> <p> </p> </div> </div> </div> </body> </html> |
| | | | | < | > | | < < > > | | < > | | | | | | | | < < > > | | | | | | | < > | | | | | < > | | | < > | | | < < < > > > | | | | | | | | | | | | | | | > > > > > > > > > > > > > > > > > > > > > > > > > | < < < < < > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | < < < < > > > > > > | | < < > > > > > > > > > > | > | > | | > | < < > > > | > > > > > > > > > > | < < < > > > | < < > > > > > > > > > > > > > > > > > > > > > > > > > > | < < < < < < < < > > |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html><head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>SQLite Query Language: ANALYZE</title> <style type="text/css"> body { margin: auto; font-family: Verdana, sans-serif; padding: 8px 1%; } a { color: #044a64 } a:visited { color: #734559 } .logo { position:absolute; margin:3px; } .tagline { float:right; text-align:right; font-style:italic; width:300px; margin:12px; margin-top:58px; } .menubar { clear: both; border-radius: 8px; background: #044a64; padding: 0px; margin: 0px; cell-spacing: 0px; } .toolbar { text-align: center; line-height: 1.6em; margin: 0; padding: 0px 8px; } .toolbar a { color: white; text-decoration: none; padding: 6px 12px; } .toolbar a:visited { color: white; } .toolbar a:hover { color: #044a64; background: white; } .content { margin: 5%; } .content dt { font-weight:bold; } .content dd { margin-bottom: 25px; margin-left:20%; } .content ul { padding:0px; padding-left: 15px; margin:0px; } /* Things for "fancyformat" documents start here. */ .fancy img+p {font-style:italic} .fancy .codeblock i { color: darkblue; } .fancy h1,.fancy h2,.fancy h3,.fancy h4 {font-weight:normal;color:#044a64} .fancy h2 { margin-left: 10px } .fancy h3 { margin-left: 20px } .fancy h4 { margin-left: 30px } .fancy th {white-space:nowrap;text-align:left;border-bottom:solid 1px #444} .fancy th, .fancy td {padding: 0.2em 1ex; vertical-align:top} .fancy #toc a { color: darkblue ; text-decoration: none } .fancy .todo { color: #AA3333 ; font-style : italic } .fancy .todo:before { content: 'TODO:' } .fancy p.todo { border: solid #AA3333 1px; padding: 1ex } .fancy img { display:block; } .fancy :link:hover, .fancy :visited:hover { background: wheat } .fancy p,.fancy ul,.fancy ol { margin: 1em 5ex } .fancy li p { margin: 1em 0 } /* End of "fancyformat" specific rules. */ </style> </head> <body> <div><!-- container div to satisfy validator --> <a href="index.html"> <img class="logo" src="images/sqlite370_banner.gif" alt="SQLite Logo" border="0"></a> <div><!-- IE hack to prevent disappearing logo--></div> <div class="tagline">Small. Fast. Reliable.<br>Choose any three.</div> <table width=100% class="menubar"><tr> <td width=100%> <div class="toolbar"> <a href="about.html">About</a> <a href="sitemap.html">Sitemap</a> <a href="docs.html">Documentation</a> <a href="download.html">Download</a> <a href="copyright.html">License</a> <a href="news.html">News</a> <a href="support.html">Support</a> </div> <script> gMsg = "Search SQLite Docs..." function entersearch() { var q = document.getElementById("q"); if( q.value == gMsg ) { q.value = "" } q.style.color = "black" q.style.fontStyle = "normal" } function leavesearch() { var q = document.getElementById("q"); if( q.value == "" ) { q.value = gMsg q.style.color = "#044a64" q.style.fontStyle = "italic" } } function hideorshow(btn,obj){ var x = document.getElementById(obj); var b = document.getElementById(btn); if( x.style.display!='none' ){ x.style.display = 'none'; b.innerHTML='show'; }else{ x.style.display = ''; b.innerHTML='hide'; } return false; } </script> <td> <div style="padding:0 1em 0px 0;white-space:nowrap"> <form name=f method="GET" action="http://www.sqlite.org/search"> <input id=q name=q type=text onfocus="entersearch()" onblur="leavesearch()" style="width:24ex;padding:1px 1ex; border:solid white 1px; font-size:0.9em ; font-style:italic;color:#044a64;" value="Search SQLite Docs..."> <input type=submit value="Go" style="border:solid white 1px;background-color:#044a64;color:white;font-size:0.9em;padding:0 1ex"> </form> </div> </table> <div class=startsearch></div> <h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>ANALYZE</h2><p><b><a href="syntaxdiagrams.html#analyze-stmt">analyze-stmt:</a></b> <button id='x769' onclick='hideorshow("x769","x770")'>hide</button></p> <blockquote id='x770'> <img alt="syntax diagram analyze-stmt" src="images/syntax/analyze-stmt.gif" /> </blockquote> <p> The ANALYZE command gathers statistics about tables and indices and stores the collected information in <a href="fileformat2.html#intschema">internal tables</a> of the database where the query optimizer can access the information and use it to help make better query planning choices. If no arguments are given, all attached databases are analyzed. If a database name is given as the argument, then all tables and indices in that one database are analyzed. If the argument is a table name, then only that table and the indices associated with that table are analyzed. If the argument is an index name, then only that one index is analyzed.</p> <p> The default implementation stores all statistics in a single table named "<a href="fileformat2.html#stat1tab">sqlite_stat1</a>". If SQLite is compiled with the <a href="compile.html#enable_stat3">SQLITE_ENABLE_STAT3</a> option and without the <a href="compile.html#enable_stat4">SQLITE_ENABLE_STAT4</a> option, then additional histogram data is collected and stored in <a href="fileformat2.html#stat3tab">sqlite_stat3</a>. If SQLite is compiled with the <a href="compile.html#enable_stat4">SQLITE_ENABLE_STAT4</a> option, then additional histogram data is collected and stored in <a href="fileformat2.html#stat4tab">sqlite_stat4</a>. Older versions of SQLite would make use of the <a href="fileformat2.html#stat2tab">sqlite_stat2</a> table when compiled with <a href="compile.html#enable_stat2">SQLITE_ENABLE_STAT2</a> but all recent versions of SQLite ignore the sqlite_stat2 table. Future enhancements may create additional <a href="fileformat2.html#intschema">internal tables</a> with the same name pattern except with final digit larger than "4". All of these tables are collectively referred to as "statistics tables". </p> <p> The content of the statistics tables can be queried using <a href="lang_select.html">SELECT</a> and can be changed using the <a href="lang_delete.html">DELETE</a>, <a href="lang_insert.html">INSERT</a>, and <a href="lang_update.html">UPDATE</a> commands. The <a href="lang_droptable.html">DROP TABLE</a> command works on statistics tables as of SQLite version 3.7.9. The <a href="lang_altertable.html">ALTER TABLE</a> command does not work on statistics tables. Appropriate care should be used when changing the content of the statistics tables as invalid content can cause SQLite to select inefficient query plans. Generally speaking, one should not modify the content of the statistics tables by any mechanism other than invoking the ANALYZE command. See "<a href="optoverview.html#manctrl">Manual Control Of Query Plans Using SQLITE_STAT Tables</a>" for further information.</p> <p> Statistics gathered by ANALYZE are not automatically updated as the content of the database changes. If the content of the database changes significantly, or if the database schema changes, then one should consider rerunning the ANALYZE command in order to update the statistics.</p> <p> The query planner loads the content of the statistics tables into memory when the schema is read. Hence, when an application changes the statistics tables directly, SQLite will not immediately notice the changes. An application can force the query planner to reread the statistics tables by running <b>ANALYZE sqlite_master</b>. </p> <p> |
Changes to Doc/Extra/Core/lang_attach.html.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
<html dir="LTR" xmlns="http://www.w3.org/1999/xhtml" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:MSHelp="http://msdn.microsoft.com/mshelp" xmlns:tool="http://www.microsoft.com/tooltip" xmlns:ndoc="urn:ndoc-preprocess"> <head> <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252" /> <title>ATTACH DATABASE</title> <link rel="stylesheet" type="text/css" href="../Include/ndoc.css" /> </head> <body> <div id="header"> <table width="100%" id="topTable"> <tr id="headerTableRow1"> <td align="left"> <span id="runningHeaderText">ATTACH DATABASE</span> </td> </tr> <tr id="headerTableRow2"> <td align="left"> <span id="nsrTitle">SQLite Language Reference Documentation</span> </td> </tr> <tr id="headerTableRow3" style="display:none"> <td> <a id="seeAlsoSectionLink" href="#seeAlsoToggle" onclick="OpenSection(seeAlsoToggle)">See Also</a> <a id="exampleSectionLink" href="#codeExampleToggle" onclick="OpenSection(codeExampleToggle)">Example</a> </td> </tr> </table> <table width="100%" id="bottomTable" cellspacing="0" cellpadding="0" style="display:none"> <tr> <td> <span onclick="ExpandCollapseAll(toggleAllImage)" style="cursor:default;" onkeypress="ExpandCollapseAll_CheckKey(toggleAllImage)" tabindex="0"> <img ID="toggleAllImage" class="toggleAll" src="collall.gif" /> <label id="collapseAllLabel" for="toggleAllImage" style="display: none;"> Collapse All </label> <label id="expandAllLabel" for="toggleAllImage" style="display: none;"> Expand All </label> </span> </td> </tr> </table> </div> <div id="mainSection"> <div id="mainBody"> <h1 class="heading"> SQL As Understood By SQLite</h1> <h4> ATTACH DATABASE</h4> <p> <table cellpadding="10"> <tr> <td align="right" width="1%" nowrap> <i><font color="#ff3434">sql-statement</font></i> ::=</td> <td> <b><font color="#2c2cf0">ATTACH </font></b>[<b><font color="#2c2cf0">DATABASE</font></b>]<b><font color="#2c2cf0"> </font></b><i><font color="#ff3434">database-filename</font></i><b><font color="#2c2cf0"> AS </font></b><i><font color="#ff3434">database-name</font></i><b><font color="#2c2cf0"></font></b></td> </tr> </table> </p> <p> The ATTACH DATABASE statement adds another database file to the current database connection. If the filename contains punctuation characters it must be quoted. The names 'main' and 'temp' refer to the main database and the database used for temporary tables. These cannot be detached. Attached databases are removed using the <a href="lang_detach.html"> DETACH DATABASE</a> statement.</p> <p> You can read from and write to an attached database and you can modify the schema of the attached database. This is a new feature of SQLite version 3.0. In SQLite 2.8, schema changes to attached databases were not allowed.</p> <p> You cannot create a new table with the same name as a table in an attached database, but you can attach a database which contains tables whose names are duplicates of tables in the main database. It is also permissible to attach the same database file multiple times.</p> <p> Tables in an attached database can be referred to using the syntax <i>database-name.table-name</i>. If an attached table doesn't have a duplicate table name in the main database, it doesn't require a database name prefix. When a database is attached, all of its tables which don't have duplicate names become the default table of that name. Any tables of that name attached afterwards require the table prefix. If the default table of a given name is detached, then the last table of that name attached becomes the new default.</p> <p> Transactions involving multiple attached databases are atomic, assuming that the main database is not ":memory:". If the main database is ":memory:" then transactions continue to be atomic within each individual database file. But if the host computer crashes in the middle of a COMMIT where two or more database files are updated, some of those files might get the changes where others might not. Atomic commit of attached databases is a new feature of SQLite version 3.0. In SQLite version 2.8, all commits to attached databases behaved as if the main database were ":memory:". </p> <p> There is a compile-time limit of 10 attached database files.</p> <p> <hr> </p> <div id="footer"> <p> </p> <p> </p> </div> </div> </div> </body> </html> |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html><head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>SQLite Query Language: ATTACH DATABASE</title> <style type="text/css"> body { margin: auto; font-family: Verdana, sans-serif; padding: 8px 1%; } a { color: #044a64 } a:visited { color: #734559 } .logo { position:absolute; margin:3px; } .tagline { float:right; text-align:right; font-style:italic; width:300px; margin:12px; margin-top:58px; } .menubar { clear: both; border-radius: 8px; background: #044a64; padding: 0px; margin: 0px; cell-spacing: 0px; } .toolbar { text-align: center; line-height: 1.6em; margin: 0; padding: 0px 8px; } .toolbar a { color: white; text-decoration: none; padding: 6px 12px; } .toolbar a:visited { color: white; } .toolbar a:hover { color: #044a64; background: white; } .content { margin: 5%; } .content dt { font-weight:bold; } .content dd { margin-bottom: 25px; margin-left:20%; } .content ul { padding:0px; padding-left: 15px; margin:0px; } /* Things for "fancyformat" documents start here. */ .fancy img+p {font-style:italic} .fancy .codeblock i { color: darkblue; } .fancy h1,.fancy h2,.fancy h3,.fancy h4 {font-weight:normal;color:#044a64} .fancy h2 { margin-left: 10px } .fancy h3 { margin-left: 20px } .fancy h4 { margin-left: 30px } .fancy th {white-space:nowrap;text-align:left;border-bottom:solid 1px #444} .fancy th, .fancy td {padding: 0.2em 1ex; vertical-align:top} .fancy #toc a { color: darkblue ; text-decoration: none } .fancy .todo { color: #AA3333 ; font-style : italic } .fancy .todo:before { content: 'TODO:' } .fancy p.todo { border: solid #AA3333 1px; padding: 1ex } .fancy img { display:block; } .fancy :link:hover, .fancy :visited:hover { background: wheat } .fancy p,.fancy ul,.fancy ol { margin: 1em 5ex } .fancy li p { margin: 1em 0 } /* End of "fancyformat" specific rules. */ </style> </head> <body> <div><!-- container div to satisfy validator --> <a href="index.html"> <img class="logo" src="images/sqlite370_banner.gif" alt="SQLite Logo" border="0"></a> <div><!-- IE hack to prevent disappearing logo--></div> <div class="tagline">Small. Fast. Reliable.<br>Choose any three.</div> <table width=100% class="menubar"><tr> <td width=100%> <div class="toolbar"> <a href="about.html">About</a> <a href="sitemap.html">Sitemap</a> <a href="docs.html">Documentation</a> <a href="download.html">Download</a> <a href="copyright.html">License</a> <a href="news.html">News</a> <a href="support.html">Support</a> </div> <script> gMsg = "Search SQLite Docs..." function entersearch() { var q = document.getElementById("q"); if( q.value == gMsg ) { q.value = "" } q.style.color = "black" q.style.fontStyle = "normal" } function leavesearch() { var q = document.getElementById("q"); if( q.value == "" ) { q.value = gMsg q.style.color = "#044a64" q.style.fontStyle = "italic" } } function hideorshow(btn,obj){ var x = document.getElementById(obj); var b = document.getElementById(btn); if( x.style.display!='none' ){ x.style.display = 'none'; b.innerHTML='show'; }else{ x.style.display = ''; b.innerHTML='hide'; } return false; } </script> <td> <div style="padding:0 1em 0px 0;white-space:nowrap"> <form name=f method="GET" action="http://www.sqlite.org/search"> <input id=q name=q type=text onfocus="entersearch()" onblur="leavesearch()" style="width:24ex;padding:1px 1ex; border:solid white 1px; font-size:0.9em ; font-style:italic;color:#044a64;" value="Search SQLite Docs..."> <input type=submit value="Go" style="border:solid white 1px;background-color:#044a64;color:white;font-size:0.9em;padding:0 1ex"> </form> </div> </table> <div class=startsearch></div> <h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>ATTACH DATABASE</h2><p><b><a href="syntaxdiagrams.html#attach-stmt">attach-stmt:</a></b> <button id='x771' onclick='hideorshow("x771","x772")'>hide</button></p> <blockquote id='x772'> <img alt="syntax diagram attach-stmt" src="images/syntax/attach-stmt.gif" /> <p><b><a href="syntaxdiagrams.html#expr">expr:</a></b> <button id='x773' onclick='hideorshow("x773","x774")'>show</button></p> <blockquote id='x774' style='display:none;'> <img alt="syntax diagram expr" src="images/syntax/expr.gif" /> <p><b><a href="syntaxdiagrams.html#literal-value">literal-value:</a></b> <button id='x775' onclick='hideorshow("x775","x776")'>show</button></p> <blockquote id='x776' style='display:none;'> <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#raise-function">raise-function:</a></b> <button id='x777' onclick='hideorshow("x777","x778")'>show</button></p> <blockquote id='x778' style='display:none;'> <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#select-stmt">select-stmt:</a></b> <button id='x779' onclick='hideorshow("x779","x780")'>show</button></p> <blockquote id='x780' style='display:none;'> <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" /> <p><b><a href="syntaxdiagrams.html#common-table-expression">common-table-expression:</a></b> <button id='x781' onclick='hideorshow("x781","x782")'>show</button></p> <blockquote id='x782' style='display:none;'> <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#compound-operator">compound-operator:</a></b> <button id='x783' onclick='hideorshow("x783","x784")'>show</button></p> <blockquote id='x784' style='display:none;'> <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#join-clause">join-clause:</a></b> <button id='x785' onclick='hideorshow("x785","x786")'>show</button></p> <blockquote id='x786' style='display:none;'> <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" /> <p><b><a href="syntaxdiagrams.html#join-constraint">join-constraint:</a></b> <button id='x787' onclick='hideorshow("x787","x788")'>show</button></p> <blockquote id='x788' style='display:none;'> <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#join-operator">join-operator:</a></b> <button id='x789' onclick='hideorshow("x789","x790")'>show</button></p> <blockquote id='x790' style='display:none;'> <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" /> </blockquote> </blockquote> <p><b><a href="syntaxdiagrams.html#ordering-term">ordering-term:</a></b> <button id='x791' onclick='hideorshow("x791","x792")'>show</button></p> <blockquote id='x792' style='display:none;'> <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#result-column">result-column:</a></b> <button id='x793' onclick='hideorshow("x793","x794")'>show</button></p> <blockquote id='x794' style='display:none;'> <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#table-or-subquery">table-or-subquery:</a></b> <button id='x795' onclick='hideorshow("x795","x796")'>show</button></p> <blockquote id='x796' style='display:none;'> <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" /> </blockquote> </blockquote> <p><b><a href="syntaxdiagrams.html#type-name">type-name:</a></b> <button id='x797' onclick='hideorshow("x797","x798")'>show</button></p> <blockquote id='x798' style='display:none;'> <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" /> <p><b><a href="syntaxdiagrams.html#signed-number">signed-number:</a></b> <button id='x799' onclick='hideorshow("x799","x800")'>show</button></p> <blockquote id='x800' style='display:none;'> <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" /> </blockquote> </blockquote> </blockquote> </blockquote> <p> The ATTACH DATABASE statement adds another database file to the current <a href="c3ref/sqlite3.html">database connection</a>. The filename for the database to be attached is the value of the expression that occurs before the AS keyword. The filename of the database follows the same semantics as the filename argument to <a href="c3ref/open.html">sqlite3_open()</a> and <a href="c3ref/open.html">sqlite3_open_v2()</a>; the special name "<a href="inmemorydb.html">:memory:</a>" results in an <a href="inmemorydb.html">in-memory database</a> and an empty string results in a new temporary database. The filename argument can be a <a href="uri.html">URI filename</a> if URI filename processing is enable on the database connection. The default behavior is for URI filenames to be disabled, however that might change in a future release of SQLite, so application developers are advised to plan accordingly. <p>The name that occurs after the AS keyword is the name of the database used internally by SQLite. The database-names 'main' and 'temp' refer to the main database and the database used for temporary tables. The main and temp databases cannot be attached or detached.</p> <p> Tables in an attached database can be referred to using the syntax <i>database-name.table-name</i>. If the name of the table is unique across all attached databases and the main and temp databases, then the <i>database-name</i> prefix is not required. If two or more tables in different databases have the same name and the <i>database-name</i> prefix is not used on a table reference, then the table chosen is the one in the database that was least recently attached.</p> <p> Transactions involving multiple attached databases are atomic, assuming that the main database is not "<a href="inmemorydb.html">:memory:</a>" and the <a href="pragma.html#pragma_journal_mode">journal_mode</a> is not <a href="wal.html">WAL</a>. If the main database is ":memory:" or if the journal_mode is WAL, then transactions continue to be atomic within each individual database file. But if the host computer crashes in the middle of a <a href="lang_transaction.html">COMMIT</a> where two or more database files are updated, some of those files might get the changes where others might not. </p> <p> There is a limit, set using <a href="c3ref/limit.html">sqlite3_limit()</a> and <a href="c3ref/c_limit_attached.html#sqlitelimitattached">SQLITE_LIMIT_ATTACHED</a>, to the number of databases that can be simultaneously attached to a single database connection.</p> |
Changes to Doc/Extra/Core/lang_comment.html.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
<html dir="LTR" xmlns="http://www.w3.org/1999/xhtml" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:MSHelp="http://msdn.microsoft.com/mshelp" xmlns:tool="http://www.microsoft.com/tooltip" xmlns:ndoc="urn:ndoc-preprocess"> <head> <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252" /> <title>comment</title> <link rel="stylesheet" type="text/css" href="../Include/ndoc.css" /> </head> <body> <div id="header"> <table width="100%" id="topTable"> <tr id="headerTableRow1"> <td align="left"> <span id="runningHeaderText">comment</span> </td> </tr> <tr id="headerTableRow2"> <td align="left"> <span id="nsrTitle">SQLite Language Reference Documentation</span> </td> </tr> <tr id="headerTableRow3" style="display:none"> <td> <a id="seeAlsoSectionLink" href="#seeAlsoToggle" onclick="OpenSection(seeAlsoToggle)">See Also</a> <a id="exampleSectionLink" href="#codeExampleToggle" onclick="OpenSection(codeExampleToggle)">Example</a> </td> </tr> </table> <table width="100%" id="bottomTable" cellspacing="0" cellpadding="0" style="display:none"> <tr> <td> <span onclick="ExpandCollapseAll(toggleAllImage)" style="cursor:default;" onkeypress="ExpandCollapseAll_CheckKey(toggleAllImage)" tabindex="0"> <img ID="toggleAllImage" class="toggleAll" src="collall.gif" /> <label id="collapseAllLabel" for="toggleAllImage" style="display: none;"> Collapse All </label> <label id="expandAllLabel" for="toggleAllImage" style="display: none;"> Expand All </label> </span> </td> </tr> </table> </div> <div id="mainSection"> <div id="mainBody"> <h1 class="heading"> SQL As Understood By SQLite</h1> <h4> comment</h4> <p> <table cellpadding="10"> <tr> <td align="right" width="1%" nowrap> <i><font color="#ff3434">comment</font></i> ::=</td> <td> <b><font color="#2c2cf0"></font></b><i><font color="#ff3434">SQL-comment</font></i><b><font color="#2c2cf0"> </font></b><big>|</big><b><font color="#2c2cf0"> </font></b><i><font color="#ff3434">C-comment</font></i><b><font color="#2c2cf0"></font></b></td> </tr> <tr> <td align="right" width="1%" nowrap> <i><font color="#ff3434">SQL-comment</font></i> ::=</td> <td> <b><font color="#2c2cf0">-- </font></b><i><font color="#ff3434">single-line</font></i><b><font color="#2c2cf0"></font></b></td> </tr> <tr> <td align="right" width="1%" nowrap> <i><font color="#ff3434">C-comment</font></i> ::=</td> <td> <b><font color="#2c2cf0">/<big>*</big> </font></b><i><font color="#ff3434">multiple-lines</font></i><b><font color="#2c2cf0"> </font></b>[<b><font color="#2c2cf0"><big>*</big>/</font></b>]<b><font color="#2c2cf0"></font></b></td> </tr> </table> </p> <p> Comments aren't SQL commands, but can occur in SQL queries. They are treated as whitespace by the parser. They can begin anywhere whitespace can be found, including inside expressions that span multiple lines. </p> <p> SQL comments only extend to the end of the current line.</p> <p> C comments can span any number of lines. If there is no terminating delimiter, they extend to the end of the input. This is not treated as an error. A new SQL statement can begin on a line after a multiline comment ends. C comments can be embedded anywhere whitespace can occur, including inside expressions, and in the middle of other SQL statements. C comments do not nest. SQL comments inside a C comment will be ignored. </p> <p> <hr> </p> <div id="footer"> <p> </p> <p> </p> </div> </div> </div> </body> </html> |
| | | | | < | > | | < < > > | | < > | | | | | | | | < < > > | | | | | | | < > | | | | | < > | | | < > | | | < < < > > > | | | | | | | | | | | | | | | > > > > > > > > > > > > > > > > > > > > > > > > > | < < < > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | < < < > > > > > > | | < < > > > > > > > > > > | > > | | | < < < < < < > > > > > > > > > > > | < | | < < < < < < < < < < < < < > > > |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html><head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>SQLite Query Language: comment</title> <style type="text/css"> body { margin: auto; font-family: Verdana, sans-serif; padding: 8px 1%; } a { color: #044a64 } a:visited { color: #734559 } .logo { position:absolute; margin:3px; } .tagline { float:right; text-align:right; font-style:italic; width:300px; margin:12px; margin-top:58px; } .menubar { clear: both; border-radius: 8px; background: #044a64; padding: 0px; margin: 0px; cell-spacing: 0px; } .toolbar { text-align: center; line-height: 1.6em; margin: 0; padding: 0px 8px; } .toolbar a { color: white; text-decoration: none; padding: 6px 12px; } .toolbar a:visited { color: white; } .toolbar a:hover { color: #044a64; background: white; } .content { margin: 5%; } .content dt { font-weight:bold; } .content dd { margin-bottom: 25px; margin-left:20%; } .content ul { padding:0px; padding-left: 15px; margin:0px; } /* Things for "fancyformat" documents start here. */ .fancy img+p {font-style:italic} .fancy .codeblock i { color: darkblue; } .fancy h1,.fancy h2,.fancy h3,.fancy h4 {font-weight:normal;color:#044a64} .fancy h2 { margin-left: 10px } .fancy h3 { margin-left: 20px } .fancy h4 { margin-left: 30px } .fancy th {white-space:nowrap;text-align:left;border-bottom:solid 1px #444} .fancy th, .fancy td {padding: 0.2em 1ex; vertical-align:top} .fancy #toc a { color: darkblue ; text-decoration: none } .fancy .todo { color: #AA3333 ; font-style : italic } .fancy .todo:before { content: 'TODO:' } .fancy p.todo { border: solid #AA3333 1px; padding: 1ex } .fancy img { display:block; } .fancy :link:hover, .fancy :visited:hover { background: wheat } .fancy p,.fancy ul,.fancy ol { margin: 1em 5ex } .fancy li p { margin: 1em 0 } /* End of "fancyformat" specific rules. */ </style> </head> <body> <div><!-- container div to satisfy validator --> <a href="index.html"> <img class="logo" src="images/sqlite370_banner.gif" alt="SQLite Logo" border="0"></a> <div><!-- IE hack to prevent disappearing logo--></div> <div class="tagline">Small. Fast. Reliable.<br>Choose any three.</div> <table width=100% class="menubar"><tr> <td width=100%> <div class="toolbar"> <a href="about.html">About</a> <a href="sitemap.html">Sitemap</a> <a href="docs.html">Documentation</a> <a href="download.html">Download</a> <a href="copyright.html">License</a> <a href="news.html">News</a> <a href="support.html">Support</a> </div> <script> gMsg = "Search SQLite Docs..." function entersearch() { var q = document.getElementById("q"); if( q.value == gMsg ) { q.value = "" } q.style.color = "black" q.style.fontStyle = "normal" } function leavesearch() { var q = document.getElementById("q"); if( q.value == "" ) { q.value = gMsg q.style.color = "#044a64" q.style.fontStyle = "italic" } } function hideorshow(btn,obj){ var x = document.getElementById(obj); var b = document.getElementById(btn); if( x.style.display!='none' ){ x.style.display = 'none'; b.innerHTML='show'; }else{ x.style.display = ''; b.innerHTML='hide'; } return false; } </script> <td> <div style="padding:0 1em 0px 0;white-space:nowrap"> <form name=f method="GET" action="http://www.sqlite.org/search"> <input id=q name=q type=text onfocus="entersearch()" onblur="leavesearch()" style="width:24ex;padding:1px 1ex; border:solid white 1px; font-size:0.9em ; font-style:italic;color:#044a64;" value="Search SQLite Docs..."> <input type=submit value="Go" style="border:solid white 1px;background-color:#044a64;color:white;font-size:0.9em;padding:0 1ex"> </form> </div> </table> <div class=startsearch></div> <h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>comment</h2><p><b><a href="syntaxdiagrams.html#comment-syntax">comment-syntax:</a></b> <button id='x805' onclick='hideorshow("x805","x806")'>hide</button></p> <blockquote id='x806'> <img alt="syntax diagram comment-syntax" src="images/syntax/comment-syntax.gif" /> </blockquote> <p>Comments are not SQL commands, but can occur within the text of SQL queries passed to <a href="c3ref/prepare.html">sqlite3_prepare_v2()</a> and related interfaces. Comments are treated as whitespace by the parser. Comments can begin anywhere whitespace can be found, including inside expressions that span multiple lines. </p> <p>SQL comments begin with two consecutive "-" characters (ASCII 0x2d) and extend up to and including the next newline character (ASCII 0x0a) or until the end of input, whichever comes first.</p> <p>C-style comments begin with "/*" and extend up to and including the next "*/" character pair or until the end of input, whichever comes first. C-style comments can span multiple lines. </p> <p>Comments can appear anywhere whitespace can occur, including inside expressions and in the middle of other SQL statements. Comments do not nest. </p> |
Changes to Doc/Extra/Core/lang_conflict.html.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
<html dir="LTR" xmlns="http://www.w3.org/1999/xhtml" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:MSHelp="http://msdn.microsoft.com/mshelp" xmlns:tool="http://www.microsoft.com/tooltip" xmlns:ndoc="urn:ndoc-preprocess"> <head> <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252" /> <title>ON CONFLICT</title> <link rel="stylesheet" type="text/css" href="../Include/ndoc.css" /> </head> <body> <div id="header"> <table width="100%" id="topTable"> <tr id="headerTableRow1"> <td align="left"> <span id="runningHeaderText">ON CONFLICT clause</span> </td> </tr> <tr id="headerTableRow2"> <td align="left"> <span id="nsrTitle">SQLite Language Reference Documentation</span> </td> </tr> <tr id="headerTableRow3" style="display:none"> <td> <a id="seeAlsoSectionLink" href="#seeAlsoToggle" onclick="OpenSection(seeAlsoToggle)">See Also</a> <a id="exampleSectionLink" href="#codeExampleToggle" onclick="OpenSection(codeExampleToggle)">Example</a> </td> </tr> </table> <table width="100%" id="bottomTable" cellspacing="0" cellpadding="0" style="display:none"> <tr> <td> <span onclick="ExpandCollapseAll(toggleAllImage)" style="cursor:default;" onkeypress="ExpandCollapseAll_CheckKey(toggleAllImage)" tabindex="0"> <img ID="toggleAllImage" class="toggleAll" src="collall.gif" /> <label id="collapseAllLabel" for="toggleAllImage" style="display: none;"> Collapse All </label> <label id="expandAllLabel" for="toggleAllImage" style="display: none;"> Expand All </label> </span> </td> </tr> </table> </div> <div id="mainSection"> <div id="mainBody"> <h1 class="heading"> SQL As Understood By SQLite</h1> <h4> ON CONFLICT clause</h4> <p> <table cellpadding="10"> <tr> <td align="right" width="1%" nowrap> <i><font color="#ff3434">conflict-clause</font></i> ::=</td> <td> <b><font color="#2c2cf0">ON CONFLICT </font></b><i><font color="#ff3434">conflict-algorithm</font></i><b><font color="#2c2cf0"></font></b></td> </tr> <tr> <td align="right" width="1%" nowrap> <i><font color="#ff3434">conflict-algorithm</font></i> ::=</td> <td> <b><font color="#2c2cf0">ROLLBACK </font></b><big>|</big><b><font color="#2c2cf0"> ABORT </font></b><big>|</big><b><font color="#2c2cf0"> FAIL </font></b><big>|</big><b><font color="#2c2cf0"> IGNORE </font></b><big>|</big><b><font color="#2c2cf0"> REPLACE</font></b></td> </tr> </table> </p> <p> 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 part of standard SQL and therefore might not be familiar.</p> <p> The syntax for the ON CONFLICT clause is as shown above for the CREATE TABLE command. For the INSERT and UPDATE commands, the keywords "ON CONFLICT" are replaced by "OR", to make the syntax seem more natural. For example, instead of "INSERT ON CONFLICT IGNORE" we have "INSERT OR IGNORE". The keywords change but the meaning of the clause is the same either way.</p> <p> The ON CONFLICT clause specifies an algorithm used to resolve constraint conflicts. There are five choices: ROLLBACK, ABORT, FAIL, IGNORE, and REPLACE. The default algorithm is ABORT. This is what they mean:</p> <dl> <dt><b>ROLLBACK</b> </dt> <dd> <p> When a constraint violation occurs, an immediate ROLLBACK occurs, thus ending the current transaction, and the command aborts with a return code of SQLITE_CONSTRAINT. If no transaction is active (other than the implied transaction that is created on every command) 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 out any prior changes it might have made and aborts with a return code of SQLITE_CONSTRAINT. But no ROLLBACK is executed so changes from prior commands within the same transaction are preserved. This is the default behavior.</p> </dd> <dt><b>FAIL</b> </dt> <dd> <p> When a constraint violation occurs, the command aborts with a return code SQLITE_CONSTRAINT. But any changes to the database that the command made prior to encountering the constraint violation are preserved and are not backed out. For example, if an UPDATE statement encountered a constraint violation on the 100th row that it attempts to update, then the first 99 row changes are preserved but 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 contains the constraint violation is not inserted or changed. But the command continues executing normally. Other rows before and after the row that contained the constraint violation continue to be inserted or updated normally. No error is returned.</p> </dd> <dt><b>REPLACE</b> </dt> <dd> <p> When a UNIQUE constraint violation occurs, the pre-existing rows that are causing the constraint violation are removed prior to inserting or 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 replaced by the default value for that column. If the column has no default value, then the ABORT algorithm is used. If a CHECK constraint violation occurs then the IGNORE algorithm is used.</p> <p> When this conflict resolution strategy deletes rows in order to satisfy a constraint, it does not invoke delete triggers on those rows. This behavior might change in a future release.</p> </dd> </dl> <p> The algorithm specified in the OR clause of a INSERT or UPDATE overrides any algorithm specified in a CREATE TABLE. If no algorithm is specified anywhere, the ABORT algorithm is used.</p> <p> <hr> </p> <div id="footer"> <p> </p> <p> </p> </div> </div> </div> </body> </html> |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html><head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>SQLite Query Language: ON CONFLICT clause</title> <style type="text/css"> body { margin: auto; font-family: Verdana, sans-serif; padding: 8px 1%; } a { color: #044a64 } a:visited { color: #734559 } .logo { position:absolute; margin:3px; } .tagline { float:right; text-align:right; font-style:italic; width:300px; margin:12px; margin-top:58px; } .menubar { clear: both; border-radius: 8px; background: #044a64; padding: 0px; margin: 0px; cell-spacing: 0px; } .toolbar { text-align: center; line-height: 1.6em; margin: 0; padding: 0px 8px; } .toolbar a { color: white; text-decoration: none; padding: 6px 12px; } .toolbar a:visited { color: white; } .toolbar a:hover { color: #044a64; background: white; } .content { margin: 5%; } .content dt { font-weight:bold; } .content dd { margin-bottom: 25px; margin-left:20%; } .content ul { padding:0px; padding-left: 15px; margin:0px; } /* Things for "fancyformat" documents start here. */ .fancy img+p {font-style:italic} .fancy .codeblock i { color: darkblue; } .fancy h1,.fancy h2,.fancy h3,.fancy h4 {font-weight:normal;color:#044a64} .fancy h2 { margin-left: 10px } .fancy h3 { margin-left: 20px } .fancy h4 { margin-left: 30px } .fancy th {white-space:nowrap;text-align:left;border-bottom:solid 1px #444} .fancy th, .fancy td {padding: 0.2em 1ex; vertical-align:top} .fancy #toc a { color: darkblue ; text-decoration: none } .fancy .todo { color: #AA3333 ; font-style : italic } .fancy .todo:before { content: 'TODO:' } .fancy p.todo { border: solid #AA3333 1px; padding: 1ex } .fancy img { display:block; } .fancy :link:hover, .fancy :visited:hover { background: wheat } .fancy p,.fancy ul,.fancy ol { margin: 1em 5ex } .fancy li p { margin: 1em 0 } /* End of "fancyformat" specific rules. */ </style> </head> <body> <div><!-- container div to satisfy validator --> <a href="index.html"> <img class="logo" src="images/sqlite370_banner.gif" alt="SQLite Logo" border="0"></a> <div><!-- IE hack to prevent disappearing logo--></div> <div class="tagline">Small. Fast. Reliable.<br>Choose any three.</div> <table width=100% class="menubar"><tr> <td width=100%> <div class="toolbar"> <a href="about.html">About</a> <a href="sitemap.html">Sitemap</a> <a href="docs.html">Documentation</a> <a href="download.html">Download</a> <a href="copyright.html">License</a> <a href="news.html">News</a> <a href="support.html">Support</a> </div> <script> gMsg = "Search SQLite Docs..." function entersearch() { var q = document.getElementById("q"); if( q.value == gMsg ) { q.value = "" } q.style.color = "black" q.style.fontStyle = "normal" } function leavesearch() { var q = document.getElementById("q"); if( q.value == "" ) { q.value = gMsg q.style.color = "#044a64" q.style.fontStyle = "italic" } } function hideorshow(btn,obj){ var x = document.getElementById(obj); var b = document.getElementById(btn); if( x.style.display!='none' ){ x.style.display = 'none'; b.innerHTML='show'; }else{ x.style.display = ''; b.innerHTML='hide'; } return false; } </script> <td> <div style="padding:0 1em 0px 0;white-space:nowrap"> <form name=f method="GET" action="http://www.sqlite.org/search"> <input id=q name=q type=text onfocus="entersearch()" onblur="leavesearch()" style="width:24ex;padding:1px 1ex; border:solid white 1px; font-size:0.9em ; font-style:italic;color:#044a64;" value="Search SQLite Docs..."> <input type=submit value="Go" style="border:solid white 1px;background-color:#044a64;color:white;font-size:0.9em;padding:0 1ex"> </form> </div> </table> <div class=startsearch></div> <h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>ON CONFLICT clause</h2><p><b><a href="syntaxdiagrams.html#conflict-clause">conflict-clause:</a></b> <button id='x1117' onclick='hideorshow("x1117","x1118")'>hide</button></p> <blockquote id='x1118'> <img alt="syntax diagram conflict-clause" src="images/syntax/conflict-clause.gif" /> </blockquote> <p>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 part of standard SQL and therefore might not be familiar.</p> <p>The syntax for the ON CONFLICT clause is as shown above for the CREATE TABLE command. For the INSERT and UPDATE commands, the keywords "ON CONFLICT" are replaced by "OR" so that the syntax reads more naturally. For example, instead of "INSERT ON CONFLICT IGNORE" we have "INSERT OR IGNORE". The keywords change but the meaning of the clause is the same either way.</p> <p>The ON CONFLICT clause applies to UNIQUE and NOT NULL constraints (and to PRIMARY KEY constraints which for the purposes of this section are the same thing as UNIQUE constraints). The ON CONFLICT algorithm does not apply to <a href="foreignkeys.html">FOREIGN KEY constraints</a>. There are five conflict resolution algorithm choices: ROLLBACK, ABORT, FAIL, IGNORE, and REPLACE. The default conflict resolution algorithm is ABORT. This is what they mean:</p> <dl> <dt><b>ROLLBACK</b></dt> <dd><p> When an applicable constraint violation occurs, the ROLLBACK resolution algorithm aborts the current SQL statement with an SQLITE_CONSTRAINT error and rolls back the current transaction. If no transaction is active (other than the implied transaction that is created on every command) then the ROLLBACK resolution algorithm works the same as the ABORT algorithm.</p></dd> <dt><b>ABORT</b></dt> <dd><p> When an applicable constraint violation occurs, the ABORT resolution algorithm aborts the current SQL statement with an SQLITE_CONSTRAINT error and backs out any changes made by the current SQL statement; but changes caused by prior SQL statements within the same transaction are preserved and the transaction remains active. This is the default behavior and the behavior specified by the SQL standard.</p></dd> <dt><b>FAIL</b></dt> <dd><p> When an applicable constraint violation occurs, the FAIL resolution algorithm aborts the current SQL statement with an SQLITE_CONSTRAINT error. But the FAIL resolution does not back out prior changes of the SQL statement that failed nor does it end the transaction. For example, if an UPDATE statement encountered a constraint violation on the 100th row that it attempts to update, then the first 99 row changes are preserved but changes to rows 100 and beyond never occur.</p></dd> <dt><b>IGNORE</b></dt> <dd><p> When an applicable constraint violation occurs, the IGNORE resolution algorithm skips the one row that contains the constraint violation and continues processing subsequent rows of the SQL statement as if nothing went wrong. Other rows before and after the row that contained the constraint violation are inserted or updated normally. No error is returned when the IGNORE conflict resolution algorithm is used.</p></dd> <dt><b>REPLACE</b></dt> <dd><p> When a UNIQUE constraint violation occurs, the REPLACE algorithm deletes pre-existing rows that are causing the constraint violation prior to inserting or updating the current row and the command continues executing normally. If a NOT NULL constraint violation occurs, the REPLACE conflict resolution replaces the NULL value with the default value for that column, or if the column has no default value, then the ABORT algorithm is used. If a CHECK constraint violation occurs, the REPLACE conflict resolution algorithm always works like ABORT.</p> <p>When the REPLACE conflict resolution strategy deletes rows in order to satisfy a constraint, <a href="lang_createtrigger.html">delete triggers</a> fire if and only if <a href="pragma.html#pragma_recursive_triggers">recursive triggers</a> are enabled.</p> <p>The <a href="c3ref/update_hook.html">update hook</a> is not invoked for rows that are deleted by the REPLACE conflict resolution strategy. Nor does REPLACE increment the <a href="c3ref/changes.html">change counter</a>. The exceptional behaviors defined in this paragraph might change in a future release.</p> </dl> <p>The algorithm specified in the OR clause of an INSERT or UPDATE overrides any algorithm specified in a CREATE TABLE. If no algorithm is specified anywhere, the ABORT algorithm is used.</p> |
Added Doc/Extra/Core/lang_corefunc.html.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html><head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>SQLite Query Language: Core Functions</title> <style type="text/css"> body { margin: auto; font-family: Verdana, sans-serif; padding: 8px 1%; } a { color: #044a64 } a:visited { color: #734559 } .logo { position:absolute; margin:3px; } .tagline { float:right; text-align:right; font-style:italic; width:300px; margin:12px; margin-top:58px; } .menubar { clear: both; border-radius: 8px; background: #044a64; padding: 0px; margin: 0px; cell-spacing: 0px; } .toolbar { text-align: center; line-height: 1.6em; margin: 0; padding: 0px 8px; } .toolbar a { color: white; text-decoration: none; padding: 6px 12px; } .toolbar a:visited { color: white; } .toolbar a:hover { color: #044a64; background: white; } .content { margin: 5%; } .content dt { font-weight:bold; } .content dd { margin-bottom: 25px; margin-left:20%; } .content ul { padding:0px; padding-left: 15px; margin:0px; } /* Things for "fancyformat" documents start here. */ .fancy img+p {font-style:italic} .fancy .codeblock i { color: darkblue; } .fancy h1,.fancy h2,.fancy h3,.fancy h4 {font-weight:normal;color:#044a64} .fancy h2 { margin-left: 10px } .fancy h3 { margin-left: 20px } .fancy h4 { margin-left: 30px } .fancy th {white-space:nowrap;text-align:left;border-bottom:solid 1px #444} .fancy th, .fancy td {padding: 0.2em 1ex; vertical-align:top} .fancy #toc a { color: darkblue ; text-decoration: none } .fancy .todo { color: #AA3333 ; font-style : italic } .fancy .todo:before { content: 'TODO:' } .fancy p.todo { border: solid #AA3333 1px; padding: 1ex } .fancy img { display:block; } .fancy :link:hover, .fancy :visited:hover { background: wheat } .fancy p,.fancy ul,.fancy ol { margin: 1em 5ex } .fancy li p { margin: 1em 0 } /* End of "fancyformat" specific rules. */ </style> </head> <body> <div><!-- container div to satisfy validator --> <a href="index.html"> <img class="logo" src="images/sqlite370_banner.gif" alt="SQLite Logo" border="0"></a> <div><!-- IE hack to prevent disappearing logo--></div> <div class="tagline">Small. Fast. Reliable.<br>Choose any three.</div> <table width=100% class="menubar"><tr> <td width=100%> <div class="toolbar"> <a href="about.html">About</a> <a href="sitemap.html">Sitemap</a> <a href="docs.html">Documentation</a> <a href="download.html">Download</a> <a href="copyright.html">License</a> <a href="news.html">News</a> <a href="support.html">Support</a> </div> <script> gMsg = "Search SQLite Docs..." function entersearch() { var q = document.getElementById("q"); if( q.value == gMsg ) { q.value = "" } q.style.color = "black" q.style.fontStyle = "normal" } function leavesearch() { var q = document.getElementById("q"); if( q.value == "" ) { q.value = gMsg q.style.color = "#044a64" q.style.fontStyle = "italic" } } function hideorshow(btn,obj){ var x = document.getElementById(obj); var b = document.getElementById(btn); if( x.style.display!='none' ){ x.style.display = 'none'; b.innerHTML='show'; }else{ x.style.display = ''; b.innerHTML='hide'; } return false; } </script> <td> <div style="padding:0 1em 0px 0;white-space:nowrap"> <form name=f method="GET" action="http://www.sqlite.org/search"> <input id=q name=q type=text onfocus="entersearch()" onblur="leavesearch()" style="width:24ex;padding:1px 1ex; border:solid white 1px; font-size:0.9em ; font-style:italic;color:#044a64;" value="Search SQLite Docs..."> <input type=submit value="Go" style="border:solid white 1px;background-color:#044a64;color:white;font-size:0.9em;padding:0 1ex"> </form> </div> </table> <div class=startsearch></div> <h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>Core Functions</h2> <p>The core functions shown below are available by default. <a href="lang_datefunc.html">Date & Time functions</a> and <a href="lang_aggfunc.html">aggregate functions</a> are documented separately. An application may define additional functions written in C and added to the database engine using the <a href="c3ref/create_function.html">sqlite3_create_function()</a> API.</p> <table border=0 cellpadding=10> <tr><td valign="top" align="right" width="120"><a name="abs"></a> abs(<i>X</i>)</td><td valign="top"> The abs(X) function returns the absolute value of the numeric argument X. Abs(X) returns NULL if X is NULL. Abs(X) return 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. </td></tr><tr><td valign="top" align="right" width="120"><a name="changes"></a> changes()</td><td valign="top"> 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 <a href="c3ref/changes.html">sqlite3_changes()</a> C/C++ function and hence follows the same rules for counting changes. </td></tr><tr><td valign="top" align="right" width="120"><a name="char"></a> char(<i>X1</i>,<i>X2</i>,...,<i>XN</i>)</td><td valign="top"> The char(X1,X2,...,XN) function returns a string composed of characters having the unicode code point values of integers X1 through XN, respectively. </td></tr><tr><td valign="top" align="right" width="120"><a name="coalesce"></a> coalesce(<i>X</i>,<i>Y</i>,...)</td><td valign="top"> 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. </td></tr><tr><td valign="top" align="right" width="120"><a name="glob"></a> glob(<i>X</i>,<i>Y</i>)</td><td valign="top"> The glob(X,Y) function is equivalent to the expression "<b>Y GLOB X</b>". Note that the X and Y arguments are reversed in the glob() function relative to the infix <a href="lang_expr.html#glob">GLOB</a> operator. If the <a href="c3ref/create_function.html">sqlite3_create_function()</a> interface is used to override the glob(X,Y) function with an alternative implementation then the <a href="lang_expr.html#glob">GLOB</a> operator will invoke the alternative implementation. </td></tr><tr><td valign="top" align="right" width="120"><a name="ifnull"></a> ifnull(<i>X</i>,<i>Y</i>)</td><td valign="top"> 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 <a href="lang_corefunc.html#coalesce">coalesce()</a> with two arguments. </td></tr><tr><td valign="top" align="right" width="120"><a name="instr"></a> instr(<i>X</i>,<i>Y</i>)</td><td valign="top"> 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. </td></tr><tr><td valign="top" align="right" width="120"><a name="hex"></a> hex(<i>X</i>)</td><td valign="top"> 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. </td></tr><tr><td valign="top" align="right" width="120"><a name="last_insert_rowid"></a> last_insert_rowid()</td><td valign="top"> The last_insert_rowid() function returns the <a href="lang_createtable.html#rowid">ROWID</a> of the last row insert from the database connection which invoked the function. The last_insert_rowid() SQL function is a wrapper around the <a href="c3ref/last_insert_rowid.html">sqlite3_last_insert_rowid()</a> C/C++ interface function. </td></tr><tr><td valign="top" align="right" width="120"><a name="length"></a> length(<i>X</i>)</td><td valign="top"> 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. </td></tr><tr><td valign="top" align="right" width="120"><a name="like"></a> like(<i>X</i>,<i>Y</i>)<br />like(<i>X</i>,<i>Y</i>,<i>Z</i>)</td><td valign="top"> The like() function is used to implement the "<b>Y LIKE X [ESCAPE Z]</b>" 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 reversed in the like() function relative to the infix <a href="lang_expr.html#like">LIKE</a> operator. The <a href="c3ref/create_function.html">sqlite3_create_function()</a> interface can be used to override the like() function and thereby change the operation of the <a href="lang_expr.html#like">LIKE</a> 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 <a href="lang_expr.html#like">LIKE</a> operator depending on whether or not an ESCAPE clause was specified. </td></tr><tr><td valign="top" align="right" width="120"><a name="likelihood"></a> likelihood(<i>X</i>,<i>Y</i>)</td><td valign="top"> 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 (that is, during calls to <a href="c3ref/step.html">sqlite3_step()</a>). 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 <a href="lang_corefunc.html#unlikely">unlikely(X)</a> function is short-hand for likelihood(X,0.0625). </td></tr><tr><td valign="top" align="right" width="120"><a name="load_extension"></a> load_extension(<i>X</i>)<br />load_extension(<i>X</i>,<i>Y</i>)</td><td valign="top"> The load_extension(X,Y) function loads <a href="loadext.html">SQLite extensions</a> 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. <p>The load_extension() function will fail if the extension attempts to modify or delete an SQL function or collating sequence. The extension can add new functions or collating sequences, but cannot modify or delete existing functions or collating sequences because those functions and/or collating sequences might be used elsewhere in the currently running SQL statement. To load an extension that changes or deletes functions or collating sequences, use the <a href="c3ref/load_extension.html">sqlite3_load_extension()</a> C-language API.</p> <p>For security reasons, extension loaded is turned off by default and must be enabled by a prior call to <a href="c3ref/enable_load_extension.html">sqlite3_enable_load_extension()</a>.</p> </td></tr><tr><td valign="top" align="right" width="120"><a name="lower"></a> lower(<i>X</i>)</td><td valign="top"> 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. </td></tr><tr><td valign="top" align="right" width="120"><a name="ltrim"></a> ltrim(<i>X</i>)<br />ltrim(<i>X</i>,<i>Y</i>)</td><td valign="top"> 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. </td></tr><tr><td valign="top" align="right" width="120"><a name="maxoreunc"></a> max(<i>X</i>,<i>Y</i>,...)</td><td valign="top"> 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 <b>max()</b> is a simple function when it has 2 or more arguments but operates as an <a href="lang_aggfunc.html#minggunc">aggregate function</a> if given only a single argument. </td></tr><tr><td valign="top" align="right" width="120"><a name="minoreunc"></a> min(<i>X</i>,<i>Y</i>,...)</td><td valign="top"> 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() define a collating function, then the BINARY collating function is used. Note that <b>min()</b> is a simple function when it has 2 or more arguments but operates as an <a href="lang_aggfunc.html#maxggunc">aggregate function</a> if given only a single argument. </td></tr><tr><td valign="top" align="right" width="120"><a name="nullif"></a> nullif(<i>X</i>,<i>Y</i>)</td><td valign="top"> 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. </td></tr><tr><td valign="top" align="right" width="120"><a name="printf"></a> printf(<i>FORMAT</i>,...)</td><td valign="top"> The printf(FORMAT,...) SQL function works like the <a href="c3ref/mprintf.html">sqlite3_mprintf()</a> 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. </td></tr><tr><td valign="top" align="right" width="120"><a name="quote"></a> quote(<i>X</i>)</td><td valign="top"> 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. </td></tr><tr><td valign="top" align="right" width="120"><a name="random"></a> random()</td><td valign="top"> The random() function returns a pseudo-random integer between -9223372036854775808 and +9223372036854775807. </td></tr><tr><td valign="top" align="right" width="120"><a name="randomblob"></a> randomblob(<i>N</i>)</td><td valign="top"> 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. <p>Hint: applications can generate globally unique identifiers using this function together with <a href="lang_corefunc.html#hex">hex()</a> and/or <a href="lang_corefunc.html#lower">lower()</a> like this:</p> <blockquote> hex(randomblob(16))<br></br> lower(hex(randomblob(16))) </blockquote> </td></tr><tr><td valign="top" align="right" width="120"><a name="replace"></a> replace(<i>X</i>,<i>Y</i>,<i>Z</i>)</td><td valign="top"> The replace(X,Y,Z) function returns a string formed by substituting string Z for every occurrence of string Y in string X. The <a href="datatype3.html#collation">BINARY</a> 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. </td></tr><tr><td valign="top" align="right" width="120"><a name="round"></a> round(<i>X</i>)<br />round(<i>X</i>,<i>Y</i>)</td><td valign="top"> 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. </td></tr><tr><td valign="top" align="right" width="120"><a name="rtrim"></a> rtrim(<i>X</i>)<br />rtrim(<i>X</i>,<i>Y</i>)</td><td valign="top"> 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. </td></tr><tr><td valign="top" align="right" width="120"><a name="soundex"></a> soundex(<i>X</i>)</td><td valign="top"> 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 <a href="compile.html#soundex">SQLITE_SOUNDEX</a> compile-time option is used when SQLite is built. </td></tr><tr><td valign="top" align="right" width="120"><a name="sqlite_compileoption_get"></a> sqlite_compileoption_get(<i>N</i>)</td><td valign="top"> The sqlite_compileoption_get() SQL function is a wrapper around the <a href="c3ref/compileoption_get.html">sqlite3_compileoption_get()</a> 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 <a href="pragma.html#pragma_compile_options">compile_options pragma</a>. </td></tr><tr><td valign="top" align="right" width="120"><a name="sqlite_compileoption_used"></a> sqlite_compileoption_used(<i>X</i>)</td><td valign="top"> The sqlite_compileoption_used() SQL function is a wrapper around the <a href="c3ref/compileoption_get.html">sqlite3_compileoption_used()</a> 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. </td></tr><tr><td valign="top" align="right" width="120"><a name="sqlite_source_id"></a> sqlite_source_id()</td><td valign="top"> 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() begins with the date and time that the source code was checked in and is follows by an SHA1 hash that uniquely identifies the source tree. This function is an SQL wrapper around the <a href="c3ref/libversion.html">sqlite3_sourceid()</a> C interface. </td></tr><tr><td valign="top" align="right" width="120"><a name="sqlite_version"></a> sqlite_version()</td><td valign="top"> The sqlite_version() function returns the version string for the SQLite library that is running. This function is an SQL wrapper around the <a href="c3ref/libversion.html">sqlite3_libversion()</a> C-interface. </td></tr><tr><td valign="top" align="right" width="120"><a name="substr"></a> substr(<i>X</i>,<i>Y</i>,<i>Z</i>)<br />substr(<i>X</i>,<i>Y</i>)</td><td valign="top"> 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 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. </td></tr><tr><td valign="top" align="right" width="120"><a name="total_changes"></a> total_changes()</td><td valign="top"> 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 <a href="c3ref/total_changes.html">sqlite3_total_changes()</a> C/C++ interface. </td></tr><tr><td valign="top" align="right" width="120"><a name="trim"></a> trim(<i>X</i>)<br />trim(<i>X</i>,<i>Y</i>)</td><td valign="top"> 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. </td></tr><tr><td valign="top" align="right" width="120"><a name="typeof"></a> typeof(<i>X</i>)</td><td valign="top"> The typeof(X) function returns a string that indicates the <a href="datatype3.html">datatype</a> of the expression X: "null", "integer", "real", "text", or "blob". </td></tr><tr><td valign="top" align="right" width="120"><a name="unlikely"></a> unlikely(<i>X</i>)</td><td valign="top"> 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 <a href="c3ref/step.html">sqlite3_step()</a>). 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 <a href="lang_corefunc.html#likelihood">likelihood</a>(X, 0.0625). </td></tr><tr><td valign="top" align="right" width="120"><a name="unicode"></a> unicode(<i>X</i>)</td><td valign="top"> 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. </td></tr><tr><td valign="top" align="right" width="120"><a name="upper"></a> upper(<i>X</i>)</td><td valign="top"> 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. </td></tr><tr><td valign="top" align="right" width="120"><a name="zeroblob"></a> zeroblob(<i>N</i>)</td><td valign="top"> 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 <a href="c3ref/blob_open.html">incremental BLOB I/O</a>. This SQL function is implemented using the <a href="c3ref/result_blob.html">sqlite3_result_zeroblob()</a> routine from the C/C++ interface. </td></tr> </table> |
Changes to Doc/Extra/Core/lang_createindex.html.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
<html dir="LTR" xmlns="http://www.w3.org/1999/xhtml" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:MSHelp="http://msdn.microsoft.com/mshelp" xmlns:tool="http://www.microsoft.com/tooltip" xmlns:ndoc="urn:ndoc-preprocess"> <head> <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252" /> <title>CREATE INDEX</title> <link rel="stylesheet" type="text/css" href="../Include/ndoc.css" /> </head> <body> <div id="header"> <table width="100%" id="topTable"> <tr id="headerTableRow1"> <td align="left"> <span id="runningHeaderText">CREATE INDEX</span> </td> </tr> <tr id="headerTableRow2"> <td align="left"> <span id="nsrTitle">SQLite Language Reference Documentation</span> </td> </tr> <tr id="headerTableRow3" style="display:none"> <td> <a id="seeAlsoSectionLink" href="#seeAlsoToggle" onclick="OpenSection(seeAlsoToggle)">See Also</a> <a id="exampleSectionLink" href="#codeExampleToggle" onclick="OpenSection(codeExampleToggle)">Example</a> </td> </tr> </table> <table width="100%" id="bottomTable" cellspacing="0" cellpadding="0" style="display:none"> <tr> <td> <span onclick="ExpandCollapseAll(toggleAllImage)" style="cursor:default;" onkeypress="ExpandCollapseAll_CheckKey(toggleAllImage)" tabindex="0"> <img ID="toggleAllImage" class="toggleAll" src="collall.gif" /> <label id="collapseAllLabel" for="toggleAllImage" style="display: none;"> Collapse All </label> <label id="expandAllLabel" for="toggleAllImage" style="display: none;"> Expand All </label> </span> </td> </tr> </table> </div> <div id="mainSection"> <div id="mainBody"> <h1 class="heading"> SQL As Understood By SQLite</h1> <h4> CREATE INDEX</h4> <p> <table cellpadding="10"> <tr> <td align="right" width="1%" nowrap> <i><font color="#ff3434">sql-statement</font></i> ::=</td> <td> <b><font color="#2c2cf0">CREATE </font></b>[<b><font color="#2c2cf0">UNIQUE</font></b>]<b><font color="#2c2cf0"> INDEX </font></b>[<b><font color="#2c2cf0">IF NOT EXISTS</font></b>]<b><font color="#2c2cf0"> </font></b>[<b><font color="#2c2cf0"></font></b><i><font color="#ff3434">database-name</font></i><b><font color="#2c2cf0"> <big>.</big></font></b>]<b><font color="#2c2cf0"> </font></b> <i><font color="#ff3434">index-name</font></i><b><font color="#2c2cf0"> <br /> ON </font></b><i><font color="#ff3434">table-name</font></i><b><font color="#2c2cf0"> <big>(</big> </font></b><i><font color="#ff3434">column-name</font></i><b><font color="#2c2cf0"> </font></b>[<b><font color="#2c2cf0"><big>,</big> </font></b><i><font color="#ff3434"> column-name</font></i><b><font color="#2c2cf0"></font></b>]<b><font color="#2c2cf0"></font></b><big>*</big><b><font color="#2c2cf0"> <big>)</big></font></b></td> </tr> <tr> <td align="right" width="1%" nowrap> <i><font color="#ff3434">column-name</font></i> ::=</td> <td> <b><font color="#2c2cf0"></font></b><i><font color="#ff3434">name</font></i><b><font color="#2c2cf0"> </font></b>[<b><font color="#2c2cf0"> COLLATE </font></b><i><font color="#ff3434">collation-name</font></i><b><font color="#2c2cf0"></font></b>]<b><font color="#2c2cf0"> </font></b>[<b><font color="#2c2cf0"> ASC </font></b><big>|</big><b><font color="#2c2cf0"> DESC </font></b>]<b><font color="#2c2cf0"></font></b></td> </tr> </table> </p> <p> 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 names of columns in the table that are used for the index key. Each column name can be followed by one of the "ASC" or "DESC" keywords to indicate sort order, but the sort order is ignored in the current implementation. Sorting is always done in ascending order.</p> <p> The COLLATE clause following each column name defines a collating sequence used for text entires in that column. The default collating sequence is the collating sequence defined for that column in the CREATE TABLE statement. Or if no collating sequence is otherwise defined, the built-in BINARY collating sequence is used.</p> <p> There are no arbitrary limits on the number of indices that can be attached to a single table, nor on the number of columns in an index.</p> <p> If the UNIQUE keyword appears between CREATE and INDEX then duplicate index entries are not allowed. Any attempt to insert a duplicate entry will result in an error.</p> <p> The exact text of each CREATE INDEX statement is stored in the <b>sqlite_master</b> or <b>sqlite_temp_master</b> table, depending on whether the table being indexed is temporary. Every time the database is opened, all CREATE INDEX statements are read from the <b>sqlite_master</b> table and used to regenerate SQLite's internal representation of the index layout.</p> <p> If the optional IF NOT EXISTS clause is present and another index with the same name aleady exists, then this command becomes a no-op.</p> <p> Indexes are removed with the <a href="lang_dropindex.html">DROP INDEX</a> command.</p> <p> <hr> </p> <div id="footer"> <p> </p> <p> </p> </div> </div> </div> </body> </html> |
| | | | | < | > | | < < > > | | < > | | | | | | | | < < > > | | | | | | | < > | | | | | < > | | | < > | | | < < < > > > | | | | | | | | | | | | | | | | > > > > > > > > > > > > > > > > > > > > > > > > | < < < > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | < < < < < > > > > > > | | < < > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | | > > > > > > | < < < > > > > > > > > > > > | > | | > | < > | | < > > > > > | | < < < < < < < < > > > > > > > | < > > | < < < < < < < < < < < < < > > > |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html><head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>SQLite Query Language: CREATE INDEX</title> <style type="text/css"> body { margin: auto; font-family: Verdana, sans-serif; padding: 8px 1%; } a { color: #044a64 } a:visited { color: #734559 } .logo { position:absolute; margin:3px; } .tagline { float:right; text-align:right; font-style:italic; width:300px; margin:12px; margin-top:58px; } .menubar { clear: both; border-radius: 8px; background: #044a64; padding: 0px; margin: 0px; cell-spacing: 0px; } .toolbar { text-align: center; line-height: 1.6em; margin: 0; padding: 0px 8px; } .toolbar a { color: white; text-decoration: none; padding: 6px 12px; } .toolbar a:visited { color: white; } .toolbar a:hover { color: #044a64; background: white; } .content { margin: 5%; } .content dt { font-weight:bold; } .content dd { margin-bottom: 25px; margin-left:20%; } .content ul { padding:0px; padding-left: 15px; margin:0px; } /* Things for "fancyformat" documents start here. */ .fancy img+p {font-style:italic} .fancy .codeblock i { color: darkblue; } .fancy h1,.fancy h2,.fancy h3,.fancy h4 {font-weight:normal;color:#044a64} .fancy h2 { margin-left: 10px } .fancy h3 { margin-left: 20px } .fancy h4 { margin-left: 30px } .fancy th {white-space:nowrap;text-align:left;border-bottom:solid 1px #444} .fancy th, .fancy td {padding: 0.2em 1ex; vertical-align:top} .fancy #toc a { color: darkblue ; text-decoration: none } .fancy .todo { color: #AA3333 ; font-style : italic } .fancy .todo:before { content: 'TODO:' } .fancy p.todo { border: solid #AA3333 1px; padding: 1ex } .fancy img { display:block; } .fancy :link:hover, .fancy :visited:hover { background: wheat } .fancy p,.fancy ul,.fancy ol { margin: 1em 5ex } .fancy li p { margin: 1em 0 } /* End of "fancyformat" specific rules. */ </style> </head> <body> <div><!-- container div to satisfy validator --> <a href="index.html"> <img class="logo" src="images/sqlite370_banner.gif" alt="SQLite Logo" border="0"></a> <div><!-- IE hack to prevent disappearing logo--></div> <div class="tagline">Small. Fast. Reliable.<br>Choose any three.</div> <table width=100% class="menubar"><tr> <td width=100%> <div class="toolbar"> <a href="about.html">About</a> <a href="sitemap.html">Sitemap</a> <a href="docs.html">Documentation</a> <a href="download.html">Download</a> <a href="copyright.html">License</a> <a href="news.html">News</a> <a href="support.html">Support</a> </div> <script> gMsg = "Search SQLite Docs..." function entersearch() { var q = document.getElementById("q"); if( q.value == gMsg ) { q.value = "" } q.style.color = "black" q.style.fontStyle = "normal" } function leavesearch() { var q = document.getElementById("q"); if( q.value == "" ) { q.value = gMsg q.style.color = "#044a64" q.style.fontStyle = "italic" } } function hideorshow(btn,obj){ var x = document.getElementById(obj); var b = document.getElementById(btn); if( x.style.display!='none' ){ x.style.display = 'none'; b.innerHTML='show'; }else{ x.style.display = ''; b.innerHTML='hide'; } return false; } </script> <td> <div style="padding:0 1em 0px 0;white-space:nowrap"> <form name=f method="GET" action="http://www.sqlite.org/search"> <input id=q name=q type=text onfocus="entersearch()" onblur="leavesearch()" style="width:24ex;padding:1px 1ex; border:solid white 1px; font-size:0.9em ; font-style:italic;color:#044a64;" value="Search SQLite Docs..."> <input type=submit value="Go" style="border:solid white 1px;background-color:#044a64;color:white;font-size:0.9em;padding:0 1ex"> </form> </div> </table> <div class=startsearch></div> <h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>CREATE INDEX</h2><p><b><a href="syntaxdiagrams.html#create-index-stmt">create-index-stmt:</a></b> <button id='x807' onclick='hideorshow("x807","x808")'>hide</button></p> <blockquote id='x808'> <img alt="syntax diagram create-index-stmt" src="images/syntax/create-index-stmt.gif" /> <p><b><a href="syntaxdiagrams.html#expr">expr:</a></b> <button id='x809' onclick='hideorshow("x809","x810")'>show</button></p> <blockquote id='x810' style='display:none;'> <img alt="syntax diagram expr" src="images/syntax/expr.gif" /> <p><b><a href="syntaxdiagrams.html#literal-value">literal-value:</a></b> <button id='x811' onclick='hideorshow("x811","x812")'>show</button></p> <blockquote id='x812' style='display:none;'> <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#raise-function">raise-function:</a></b> <button id='x813' onclick='hideorshow("x813","x814")'>show</button></p> <blockquote id='x814' style='display:none;'> <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#select-stmt">select-stmt:</a></b> <button id='x815' onclick='hideorshow("x815","x816")'>show</button></p> <blockquote id='x816' style='display:none;'> <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" /> <p><b><a href="syntaxdiagrams.html#common-table-expression">common-table-expression:</a></b> <button id='x817' onclick='hideorshow("x817","x818")'>show</button></p> <blockquote id='x818' style='display:none;'> <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#compound-operator">compound-operator:</a></b> <button id='x819' onclick='hideorshow("x819","x820")'>show</button></p> <blockquote id='x820' style='display:none;'> <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#join-clause">join-clause:</a></b> <button id='x821' onclick='hideorshow("x821","x822")'>show</button></p> <blockquote id='x822' style='display:none;'> <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" /> <p><b><a href="syntaxdiagrams.html#join-constraint">join-constraint:</a></b> <button id='x823' onclick='hideorshow("x823","x824")'>show</button></p> <blockquote id='x824' style='display:none;'> <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#join-operator">join-operator:</a></b> <button id='x825' onclick='hideorshow("x825","x826")'>show</button></p> <blockquote id='x826' style='display:none;'> <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" /> </blockquote> </blockquote> <p><b><a href="syntaxdiagrams.html#ordering-term">ordering-term:</a></b> <button id='x827' onclick='hideorshow("x827","x828")'>show</button></p> <blockquote id='x828' style='display:none;'> <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#result-column">result-column:</a></b> <button id='x829' onclick='hideorshow("x829","x830")'>show</button></p> <blockquote id='x830' style='display:none;'> <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#table-or-subquery">table-or-subquery:</a></b> <button id='x831' onclick='hideorshow("x831","x832")'>show</button></p> <blockquote id='x832' style='display:none;'> <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" /> </blockquote> </blockquote> <p><b><a href="syntaxdiagrams.html#type-name">type-name:</a></b> <button id='x833' onclick='hideorshow("x833","x834")'>show</button></p> <blockquote id='x834' style='display:none;'> <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" /> <p><b><a href="syntaxdiagrams.html#signed-number">signed-number:</a></b> <button id='x835' onclick='hideorshow("x835","x836")'>show</button></p> <blockquote id='x836' style='display:none;'> <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" /> </blockquote> </blockquote> </blockquote> <p><b><a href="syntaxdiagrams.html#indexed-column">indexed-column:</a></b> <button id='x837' onclick='hideorshow("x837","x838")'>show</button></p> <blockquote id='x838' style='display:none;'> <img alt="syntax diagram indexed-column" src="images/syntax/indexed-column.gif" /> </blockquote> </blockquote> <p>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 names of columns in the table that are used for the index key. If the optional WHERE clause is included, then the index is a "<a href="partialindex.html">partial index</a>". </p> <a name="descidx"></a> <p>Each column name can be followed by one of the "ASC" or "DESC" keywords to indicate sort order. The sort order may or may not be ignored depending on the database file format, and in particular the <a href="fileformat2.html#schemaformat">schema format number</a>. The "legacy" schema format (1) ignores index sort order. The descending index schema format (4) takes index sort order into account. Only versions of SQLite 3.3.0 and later are able to understand the descending index format. For compatibility, version of SQLite between 3.3.0 and 3.7.9 use the legacy schema format by default. The newer schema format is used by default in version 3.7.10 and later. The <a href="pragma.html#pragma_legacy_file_format">legacy_file_format pragma</a> can be used to change set the specific behavior for any version of SQLite.</p> <p>The COLLATE clause optionally following each column name defines a collating sequence used for text entries in that column. The default collating sequence is the collating sequence defined for that column in the <a href="lang_createtable.html">CREATE TABLE</a> statement. Or if no collating sequence is otherwise defined, the built-in BINARY collating sequence is used.</p> <p>There are no arbitrary limits on the number of indices that can be attached to a single table. The number of columns in an index is limited to the value set by <a href="c3ref/limit.html">sqlite3_limit</a>(<a href="c3ref/c_limit_attached.html#sqlitelimitcolumn">SQLITE_LIMIT_COLUMN</a>,...).</p> <a name="uniqueidx"></a> <p>If the UNIQUE keyword appears between CREATE and INDEX then duplicate index entries are not allowed. Any attempt to insert a duplicate entry will result in an error. For the purposes of unique indices, all NULL values are considered to different from all other NULL values and are thus unique. This is one of the two possible interpretations of the SQL-92 standard (the language in the standard is ambiguous) and is the interpretation followed by PostgreSQL, MySQL, Firebird, and Oracle. Informix and Microsoft SQL Server follow the other interpretation of the standard.</p> <p>If the optional IF NOT EXISTS clause is present and another index with the same name already exists, then this command becomes a no-op.</p> <p>Indexes are removed with the <a href="lang_dropindex.html">DROP INDEX</a> command.</p> |
Changes to Doc/Extra/Core/lang_createtable.html.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 |
<html dir="LTR" xmlns="http://www.w3.org/1999/xhtml" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:MSHelp="http://msdn.microsoft.com/mshelp" xmlns:tool="http://www.microsoft.com/tooltip" xmlns:ndoc="urn:ndoc-preprocess"> <head> <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252" /> <title>CREATE TABLE</title> <link rel="stylesheet" type="text/css" href="../Include/ndoc.css" /> </head> <body> <div id="header"> <table width="100%" id="topTable"> <tr id="headerTableRow1"> <td align="left"> <span id="runningHeaderText">CREATE TABLE</span> </td> </tr> <tr id="headerTableRow2"> <td align="left"> <span id="nsrTitle">SQLite Language Reference Documentation</span> </td> </tr> <tr id="headerTableRow3" style="display:none"> <td> <a id="seeAlsoSectionLink" href="#seeAlsoToggle" onclick="OpenSection(seeAlsoToggle)">See Also</a> <a id="exampleSectionLink" href="#codeExampleToggle" onclick="OpenSection(codeExampleToggle)">Example</a> </td> </tr> </table> <table width="100%" id="bottomTable" cellspacing="0" cellpadding="0" style="display:none"> <tr> <td> <span onclick="ExpandCollapseAll(toggleAllImage)" style="cursor:default;" onkeypress="ExpandCollapseAll_CheckKey(toggleAllImage)" tabindex="0"> <img ID="toggleAllImage" class="toggleAll" src="collall.gif" /> <label id="collapseAllLabel" for="toggleAllImage" style="display: none;"> Collapse All </label> <label id="expandAllLabel" for="toggleAllImage" style="display: none;"> Expand All </label> </span> </td> </tr> </table> </div> <div id="mainSection"> <div id="mainBody"> <h1 class="heading"> SQL As Understood By SQLite</h1> <h4> CREATE TABLE</h4> <p> <table cellpadding="10"> <tr> <td align="right" width="1%" nowrap> <i><font color="#ff3434">sql-command</font></i> ::=</td> <td> <b><font color="#2c2cf0">CREATE </font></b>[<b><font color="#2c2cf0">TEMP </font></b> <big>|</big><b><font color="#2c2cf0"> TEMPORARY</font></b>]<b><font color="#2c2cf0"> TABLE </font></b>[<b><font color="#2c2cf0">IF NOT EXISTS</font></b>]<b><font color="#2c2cf0"> </font></b>[<b><font color="#2c2cf0"></font></b><i><font color="#ff3434">database-name</font></i><b><font color="#2c2cf0"> <big>.</big></font></b>]<b><font color="#2c2cf0"> </font></b> <i><font color="#ff3434">table-name</font></i><b><font color="#2c2cf0"> <big>(</big><br /> </font></b><i><font color="#ff3434">column-def</font></i><b><font color="#2c2cf0"> </font></b>[<b><font color="#2c2cf0"><big>,</big> </font></b><i><font color="#ff3434"> column-def</font></i><b><font color="#2c2cf0"></font></b>]<b><font color="#2c2cf0"></font></b><big>*</big><b><font color="#2c2cf0"><br /> </font></b>[<b><font color="#2c2cf0"><big>,</big> </font></b> <i><font color="#ff3434">constraint</font></i><b><font color="#2c2cf0"></font></b>]<b><font color="#2c2cf0"></font></b><big>*</big><b><font color="#2c2cf0"><br /> <big>)</big></font></b></td> </tr> <tr> <td align="right" width="1%" nowrap> <i><font color="#ff3434">sql-command</font></i> ::=</td> <td> <b><font color="#2c2cf0">CREATE </font></b>[<b><font color="#2c2cf0">TEMP </font></b> <big>|</big><b><font color="#2c2cf0"> TEMPORARY</font></b>]<b><font color="#2c2cf0"> TABLE </font></b>[<b><font color="#2c2cf0"></font></b><i><font color="#ff3434">database-name</font></i><b><font color="#2c2cf0"><big>.</big></font></b>]<b><font color="#2c2cf0"> </font></b> <i><font color="#ff3434">table-name</font></i><b><font color="#2c2cf0"> AS </font> </b><i><font color="#ff3434">select-statement</font></i><b><font color="#2c2cf0"></font></b></td> </tr> <tr> <td align="right" width="1%" nowrap> <i><font color="#ff3434">column-def</font></i> ::=</td> <td> <b><font color="#2c2cf0"></font></b><i><font color="#ff3434">name</font></i><b><font color="#2c2cf0"> </font></b>[<b><font color="#2c2cf0"></font></b><i><font color="#ff3434">type</font></i><b><font color="#2c2cf0"></font></b>]<b><font color="#2c2cf0"> </font></b>[<b><font color="#2c2cf0"></font></b>[<b><font color="#2c2cf0">CONSTRAINT </font></b><i><font color="#ff3434">name</font></i><b><font color="#2c2cf0"></font></b>]<b><font color="#2c2cf0"> </font></b><i><font color="#ff3434"> column-constraint</font></i><b><font color="#2c2cf0"></font></b>]<b><font color="#2c2cf0"></font></b><big>*</big><b><font color="#2c2cf0"></font></b></td> </tr> <tr> <td align="right" width="1%" nowrap> <i><font color="#ff3434">type</font></i> ::=</td> <td> <b><font color="#2c2cf0"></font></b><i><font color="#ff3434">typename</font></i><b><font color="#2c2cf0"> </font></b><big>|</big><b><font color="#2c2cf0"><br /> </font></b><i><font color="#ff3434">typename</font></i><b><font color="#2c2cf0"> <big> (</big> </font></b><i><font color="#ff3434">number</font></i><b><font color="#2c2cf0"> <big>)</big> </font></b><big>|</big><b><font color="#2c2cf0"><br /> </font></b><i><font color="#ff3434">typename</font></i><b><font color="#2c2cf0"> <big> (</big> </font></b><i><font color="#ff3434">number</font></i><b><font color="#2c2cf0"> <big>,</big> </font></b><i><font color="#ff3434">number</font></i><b><font color="#2c2cf0"> <big>)</big></font></b></td> </tr> <tr> <td align="right" width="1%" nowrap> <i><font color="#ff3434">column-constraint</font></i> ::=</td> <td> <b><font color="#2c2cf0">NOT NULL </font></b>[<b><font color="#2c2cf0"> </font></b> <i><font color="#ff3434">conflict-clause</font></i><b><font color="#2c2cf0"> </font> </b>]<b><font color="#2c2cf0"> </font></b><big>|</big><b><font color="#2c2cf0"><br /> PRIMARY KEY </font></b>[<b><font color="#2c2cf0"></font></b><i><font color="#ff3434">sort-order</font></i><b><font color="#2c2cf0"></font></b>]<b><font color="#2c2cf0"> </font></b>[<b><font color="#2c2cf0"> </font></b><i><font color="#ff3434">conflict-clause</font></i><b><font color="#2c2cf0"> </font></b>]<b><font color="#2c2cf0"> </font></b>[<b><font color="#2c2cf0">AUTOINCREMENT</font></b>]<b><font color="#2c2cf0"> </font></b><big>|</big><b><font color="#2c2cf0"><br /> UNIQUE </font></b>[<b><font color="#2c2cf0"> </font></b><i><font color="#ff3434">conflict-clause</font></i><b><font color="#2c2cf0"> </font></b>]<b><font color="#2c2cf0"> </font></b><big>|</big><b><font color="#2c2cf0"><br /> CHECK <big>(</big> </font></b><i><font color="#ff3434">expr</font></i><b><font color="#2c2cf0"> <big>)</big> </font></b><big>|</big><b><font color="#2c2cf0"><br /> DEFAULT </font></b><i><font color="#ff3434">value</font></i><b><font color="#2c2cf0"> </font></b><big>|</big><b><font color="#2c2cf0"><br /> COLLATE </font></b><i><font color="#ff3434">collation-name</font></i><b><font color="#2c2cf0"></font></b></td> </tr> <tr> <td align="right" width="1%" nowrap> <i><font color="#ff3434">constraint</font></i> ::=</td> <td> <b><font color="#2c2cf0">PRIMARY KEY <big>(</big> </font></b><i><font color="#ff3434"> column-list</font></i><b><font color="#2c2cf0"> <big>)</big> </font></b>[<b><font color="#2c2cf0"> </font></b><i><font color="#ff3434">conflict-clause</font></i><b><font color="#2c2cf0"> </font></b>]<b><font color="#2c2cf0"> </font></b><big>|</big><b><font color="#2c2cf0"><br /> UNIQUE <big>(</big> </font></b><i><font color="#ff3434">column-list</font></i><b><font color="#2c2cf0"> <big>)</big> </font></b>[<b><font color="#2c2cf0"> </font></b> <i><font color="#ff3434">conflict-clause</font></i><b><font color="#2c2cf0"> </font> </b>]<b><font color="#2c2cf0"> </font></b><big>|</big><b><font color="#2c2cf0"><br /> CHECK <big>(</big> </font></b><i><font color="#ff3434">expr</font></i><b><font color="#2c2cf0"> <big>)</big></font></b></td> </tr> <tr> <td align="right" width="1%" nowrap> <i><font color="#ff3434">conflict-clause</font></i> ::=</td> <td> <b><font color="#2c2cf0">ON CONFLICT </font></b><i><font color="#ff3434">conflict-algorithm</font></i><b><font color="#2c2cf0"></font></b></td> </tr> </table> </p> <p> A CREATE TABLE statement is basically the keywords "CREATE TABLE" followed by the name of a new table and a parenthesized list of column definitions and constraints. The table name can be either an identifier or a string. Tables names that begin with "<b>sqlite_</b>" are reserved for use by the engine.</p> <p> Each column definition is the name of the column followed by the datatype for that column, then one or more optional column constraints. The datatype for the column does not restrict what data may be put in that column. See <a href="http://www.sqlite.org/datatype3.html"> Datatypes In SQLite Version 3</a> for additional information. The UNIQUE constraint causes an index to be created on the specified columns. This index must contain unique keys. The COLLATE clause specifies what text <a href="http://www.sqlite.org/datatype3.html#collation"> collating function</a> to use when comparing text entries for the column. The built-in BINARY collating function is used by default. </p> <p> The DEFAULT constraint specifies a default value to use when doing an INSERT. The value may be NULL, a string constant or a number. Starting with version 3.1.0, the default value may also be one of the special case-independant keywords CURRENT_TIME, CURRENT_DATE or CURRENT_TIMESTAMP. If the value is NULL, a string constant or number, it is literally inserted into the column whenever an INSERT statement that does not specify a value for the column is executed. If the value is CURRENT_TIME, CURRENT_DATE or CURRENT_TIMESTAMP, then the current UTC date and/or time is inserted into the columns. For CURRENT_TIME, the format is HH:MM:SS. For CURRENT_DATE, YYYY-MM-DD. The format for CURRENT_TIMESTAMP is "YYYY-MM-DD HH:MM:SS". </p> <p> Specifying a PRIMARY KEY normally just creates a UNIQUE index on the corresponding columns. However, if primary key is on a single column that has datatype INTEGER, then that column is used internally as the actual key of the B-Tree for the table. This means that the column may only hold unique integer values. (Except for this one case, SQLite ignores the datatype specification of columns and allows any kind of data to be put in a column regardless of its declared datatype.) If a table does not have an INTEGER PRIMARY KEY column, then the B-Tree key will be a automatically generated integer. The B-Tree key for a row can always be accessed using one of the special names "<b>ROWID</b>", "<b>OID</b>", or "<b>_ROWID_</b>". This is true regardless of whether or not there is an INTEGER PRIMARY KEY. An INTEGER PRIMARY KEY column man also include the keyword AUTOINCREMENT. The AUTOINCREMENT keyword modified the way that B-Tree keys are automatically generated. Additional detail on automatic B-Tree key generation is available <a href="http://www.sqlite.org/autoinc.html"> separately</a>.</p> <p> If the "TEMP" or "TEMPORARY" keyword occurs in between "CREATE" and "TABLE" then the table that is created is only visible within that same database connection and is automatically deleted when the database connection is closed. Any indices created on a temporary table are also temporary. Temporary tables and indices are stored in a separate file distinct from the main database file.</p> <p> If a <database-name> is specified, then the table is created in the named database. It is an error to specify both a <database-name> and the TEMP keyword, unless the <database-name> is "temp". If no database name is specified, and the TEMP keyword is not present, the table is created in the main database.</p> <p> The optional conflict-clause following each constraint allows the specification of an alternative default constraint conflict resolution algorithm for that constraint. The default is abort ABORT. Different constraints within the same table may have different default conflict resolution algorithms. If an COPY, INSERT, or UPDATE command specifies a different conflict resolution algorithm, then that algorithm is used in place of the default algorithm specified in the CREATE TABLE statement. See the section titled <a href="lang_conflict.html">ON CONFLICT</a> for additional information.</p> <p> CHECK constraints are supported as of version 3.3.0. Prior to version 3.3.0, CHECK constraints were parsed but not enforced.</p> <p> There are no arbitrary limits on the number of columns or on the number of constraints in a table. The total amount of data in a single row is limited to about 1 megabytes in version 2.8. In version 3.0 there is no arbitrary limit on the amount of data in a row.</p> <p> The CREATE TABLE AS form defines the table to be the result set of a query. The names of the table columns are the names of the columns in the result.</p> <p> The exact text of each CREATE TABLE statement is stored in the <b>sqlite_master</b> table. Every time the database is opened, all CREATE TABLE statements are read from the <b>sqlite_master</b> table and used to regenerate SQLite's internal representation of the table layout. If the original command was a CREATE TABLE AS then then an equivalent CREATE TABLE statement is synthesized and store in <b>sqlite_master</b> in place of the original command. The text of CREATE TEMPORARY TABLE statements are stored in the <b>sqlite_temp_master</b> table. </p> <p> If the optional IF NOT EXISTS clause is present and another table with the same name aleady exists, then this command becomes a no-op.</p> <p> Tables are removed using the <a href="lang_droptable.html">DROP TABLE</a> statement. </p> <p> <hr> </p> <div id="footer"> <p> </p> <p> </p> </div> </div> </div> </body> </html> |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html><head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>SQLite Query Language: CREATE TABLE</title> <style type="text/css"> body { margin: auto; font-family: Verdana, sans-serif; padding: 8px 1%; } a { color: #044a64 } a:visited { color: #734559 } .logo { position:absolute; margin:3px; } .tagline { float:right; text-align:right; font-style:italic; width:300px; margin:12px; margin-top:58px; } .menubar { clear: both; border-radius: 8px; background: #044a64; padding: 0px; margin: 0px; cell-spacing: 0px; } .toolbar { text-align: center; line-height: 1.6em; margin: 0; padding: 0px 8px; } .toolbar a { color: white; text-decoration: none; padding: 6px 12px; } .toolbar a:visited { color: white; } .toolbar a:hover { color: #044a64; background: white; } .content { margin: 5%; } .content dt { font-weight:bold; } .content dd { margin-bottom: 25px; margin-left:20%; } .content ul { padding:0px; padding-left: 15px; margin:0px; } /* Things for "fancyformat" documents start here. */ .fancy img+p {font-style:italic} .fancy .codeblock i { color: darkblue; } .fancy h1,.fancy h2,.fancy h3,.fancy h4 {font-weight:normal;color:#044a64} .fancy h2 { margin-left: 10px } .fancy h3 { margin-left: 20px } .fancy h4 { margin-left: 30px } .fancy th {white-space:nowrap;text-align:left;border-bottom:solid 1px #444} .fancy th, .fancy td {padding: 0.2em 1ex; vertical-align:top} .fancy #toc a { color: darkblue ; text-decoration: none } .fancy .todo { color: #AA3333 ; font-style : italic } .fancy .todo:before { content: 'TODO:' } .fancy p.todo { border: solid #AA3333 1px; padding: 1ex } .fancy img { display:block; } .fancy :link:hover, .fancy :visited:hover { background: wheat } .fancy p,.fancy ul,.fancy ol { margin: 1em 5ex } .fancy li p { margin: 1em 0 } /* End of "fancyformat" specific rules. */ </style> </head> <body> <div><!-- container div to satisfy validator --> <a href="index.html"> <img class="logo" src="images/sqlite370_banner.gif" alt="SQLite Logo" border="0"></a> <div><!-- IE hack to prevent disappearing logo--></div> <div class="tagline">Small. Fast. Reliable.<br>Choose any three.</div> <table width=100% class="menubar"><tr> <td width=100%> <div class="toolbar"> <a href="about.html">About</a> <a href="sitemap.html">Sitemap</a> <a href="docs.html">Documentation</a> <a href="download.html">Download</a> <a href="copyright.html">License</a> <a href="news.html">News</a> <a href="support.html">Support</a> </div> <script> gMsg = "Search SQLite Docs..." function entersearch() { var q = document.getElementById("q"); if( q.value == gMsg ) { q.value = "" } q.style.color = "black" q.style.fontStyle = "normal" } function leavesearch() { var q = document.getElementById("q"); if( q.value == "" ) { q.value = gMsg q.style.color = "#044a64" q.style.fontStyle = "italic" } } function hideorshow(btn,obj){ var x = document.getElementById(obj); var b = document.getElementById(btn); if( x.style.display!='none' ){ x.style.display = 'none'; b.innerHTML='show'; }else{ x.style.display = ''; b.innerHTML='hide'; } return false; } </script> <td> <div style="padding:0 1em 0px 0;white-space:nowrap"> <form name=f method="GET" action="http://www.sqlite.org/search"> <input id=q name=q type=text onfocus="entersearch()" onblur="leavesearch()" style="width:24ex;padding:1px 1ex; border:solid white 1px; font-size:0.9em ; font-style:italic;color:#044a64;" value="Search SQLite Docs..."> <input type=submit value="Go" style="border:solid white 1px;background-color:#044a64;color:white;font-size:0.9em;padding:0 1ex"> </form> </div> </table> <div class=startsearch></div> <h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>CREATE TABLE</h2><p><b><a href="syntaxdiagrams.html#create-table-stmt">create-table-stmt:</a></b> <button id='x839' onclick='hideorshow("x839","x840")'>hide</button></p> <blockquote id='x840'> <img alt="syntax diagram create-table-stmt" src="images/syntax/create-table-stmt.gif" /> <p><b><a href="syntaxdiagrams.html#column-def">column-def:</a></b> <button id='x841' onclick='hideorshow("x841","x842")'>show</button></p> <blockquote id='x842' style='display:none;'> <img alt="syntax diagram column-def" src="images/syntax/column-def.gif" /> <p><b><a href="syntaxdiagrams.html#column-constraint">column-constraint:</a></b> <button id='x843' onclick='hideorshow("x843","x844")'>show</button></p> <blockquote id='x844' style='display:none;'> <img alt="syntax diagram column-constraint" src="images/syntax/column-constraint.gif" /> <p><b><a href="syntaxdiagrams.html#conflict-clause">conflict-clause:</a></b> <button id='x845' onclick='hideorshow("x845","x846")'>show</button></p> <blockquote id='x846' style='display:none;'> <img alt="syntax diagram conflict-clause" src="images/syntax/conflict-clause.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#expr">expr:</a></b> <button id='x847' onclick='hideorshow("x847","x848")'>show</button></p> <blockquote id='x848' style='display:none;'> <img alt="syntax diagram expr" src="images/syntax/expr.gif" /> <p><b><a href="syntaxdiagrams.html#raise-function">raise-function:</a></b> <button id='x849' onclick='hideorshow("x849","x850")'>show</button></p> <blockquote id='x850' style='display:none;'> <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" /> </blockquote> </blockquote> <p><b><a href="syntaxdiagrams.html#foreign-key-clause">foreign-key-clause:</a></b> <button id='x851' onclick='hideorshow("x851","x852")'>show</button></p> <blockquote id='x852' style='display:none;'> <img alt="syntax diagram foreign-key-clause" src="images/syntax/foreign-key-clause.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#literal-value">literal-value:</a></b> <button id='x853' onclick='hideorshow("x853","x854")'>show</button></p> <blockquote id='x854' style='display:none;'> <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#signed-number">signed-number:</a></b> <button id='x855' onclick='hideorshow("x855","x856")'>show</button></p> <blockquote id='x856' style='display:none;'> <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" /> </blockquote> </blockquote> <p><b><a href="syntaxdiagrams.html#type-name">type-name:</a></b> <button id='x857' onclick='hideorshow("x857","x858")'>show</button></p> <blockquote id='x858' style='display:none;'> <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" /> <p><b><a href="syntaxdiagrams.html#signed-number">signed-number:</a></b> <button id='x859' onclick='hideorshow("x859","x860")'>show</button></p> <blockquote id='x860' style='display:none;'> <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" /> </blockquote> </blockquote> </blockquote> <p><b><a href="syntaxdiagrams.html#select-stmt">select-stmt:</a></b> <button id='x861' onclick='hideorshow("x861","x862")'>show</button></p> <blockquote id='x862' style='display:none;'> <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" /> <p><b><a href="syntaxdiagrams.html#common-table-expression">common-table-expression:</a></b> <button id='x863' onclick='hideorshow("x863","x864")'>show</button></p> <blockquote id='x864' style='display:none;'> <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#compound-operator">compound-operator:</a></b> <button id='x865' onclick='hideorshow("x865","x866")'>show</button></p> <blockquote id='x866' style='display:none;'> <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#expr">expr:</a></b> <button id='x867' onclick='hideorshow("x867","x868")'>show</button></p> <blockquote id='x868' style='display:none;'> <img alt="syntax diagram expr" src="images/syntax/expr.gif" /> <p><b><a href="syntaxdiagrams.html#literal-value">literal-value:</a></b> <button id='x869' onclick='hideorshow("x869","x870")'>show</button></p> <blockquote id='x870' style='display:none;'> <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#raise-function">raise-function:</a></b> <button id='x871' onclick='hideorshow("x871","x872")'>show</button></p> <blockquote id='x872' style='display:none;'> <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#type-name">type-name:</a></b> <button id='x873' onclick='hideorshow("x873","x874")'>show</button></p> <blockquote id='x874' style='display:none;'> <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" /> <p><b><a href="syntaxdiagrams.html#signed-number">signed-number:</a></b> <button id='x875' onclick='hideorshow("x875","x876")'>show</button></p> <blockquote id='x876' style='display:none;'> <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" /> </blockquote> </blockquote> </blockquote> <p><b><a href="syntaxdiagrams.html#join-clause">join-clause:</a></b> <button id='x877' onclick='hideorshow("x877","x878")'>show</button></p> <blockquote id='x878' style='display:none;'> <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" /> <p><b><a href="syntaxdiagrams.html#join-constraint">join-constraint:</a></b> <button id='x879' onclick='hideorshow("x879","x880")'>show</button></p> <blockquote id='x880' style='display:none;'> <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#join-operator">join-operator:</a></b> <button id='x881' onclick='hideorshow("x881","x882")'>show</button></p> <blockquote id='x882' style='display:none;'> <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" /> </blockquote> </blockquote> <p><b><a href="syntaxdiagrams.html#ordering-term">ordering-term:</a></b> <button id='x883' onclick='hideorshow("x883","x884")'>show</button></p> <blockquote id='x884' style='display:none;'> <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#result-column">result-column:</a></b> <button id='x885' onclick='hideorshow("x885","x886")'>show</button></p> <blockquote id='x886' style='display:none;'> <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#table-or-subquery">table-or-subquery:</a></b> <button id='x887' onclick='hideorshow("x887","x888")'>show</button></p> <blockquote id='x888' style='display:none;'> <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" /> </blockquote> </blockquote> <p><b><a href="syntaxdiagrams.html#table-constraint">table-constraint:</a></b> <button id='x889' onclick='hideorshow("x889","x890")'>show</button></p> <blockquote id='x890' style='display:none;'> <img alt="syntax diagram table-constraint" src="images/syntax/table-constraint.gif" /> <p><b><a href="syntaxdiagrams.html#conflict-clause">conflict-clause:</a></b> <button id='x891' onclick='hideorshow("x891","x892")'>show</button></p> <blockquote id='x892' style='display:none;'> <img alt="syntax diagram conflict-clause" src="images/syntax/conflict-clause.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#expr">expr:</a></b> <button id='x893' onclick='hideorshow("x893","x894")'>show</button></p> <blockquote id='x894' style='display:none;'> <img alt="syntax diagram expr" src="images/syntax/expr.gif" /> <p><b><a href="syntaxdiagrams.html#literal-value">literal-value:</a></b> <button id='x895' onclick='hideorshow("x895","x896")'>show</button></p> <blockquote id='x896' style='display:none;'> <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#raise-function">raise-function:</a></b> <button id='x897' onclick='hideorshow("x897","x898")'>show</button></p> <blockquote id='x898' style='display:none;'> <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#type-name">type-name:</a></b> <button id='x899' onclick='hideorshow("x899","x900")'>show</button></p> <blockquote id='x900' style='display:none;'> <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" /> <p><b><a href="syntaxdiagrams.html#signed-number">signed-number:</a></b> <button id='x901' onclick='hideorshow("x901","x902")'>show</button></p> <blockquote id='x902' style='display:none;'> <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" /> </blockquote> </blockquote> </blockquote> <p><b><a href="syntaxdiagrams.html#foreign-key-clause">foreign-key-clause:</a></b> <button id='x903' onclick='hideorshow("x903","x904")'>show</button></p> <blockquote id='x904' style='display:none;'> <img alt="syntax diagram foreign-key-clause" src="images/syntax/foreign-key-clause.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#indexed-column">indexed-column:</a></b> <button id='x905' onclick='hideorshow("x905","x906")'>show</button></p> <blockquote id='x906' style='display:none;'> <img alt="syntax diagram indexed-column" src="images/syntax/indexed-column.gif" /> </blockquote> </blockquote> </blockquote> <p>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: <ul> <li><p>The name of the new table. <li><p> The database in which the new table is created. Tables may be created in the main database, the temp database, or in any attached database. <li><p> The name of each column in the table. <li><p> The declared type of each column in the table. <li><p> A default value or expression for each column in the table. <li><p> A default collation sequence to use with each column. <li><p> Optionally, a PRIMARY KEY for the table. Both single column and composite (multiple column) primary keys are supported. <li><p> A set of SQL constraints for each table. SQLite supports UNIQUE, NOT NULL, CHECK and FOREIGN KEY constraints. <li><p> Whether the table is a <a href="withoutrowid.html">WITHOUT ROWID</a> table. </ul> <p>Every CREATE TABLE statement must specify a name for the new table. Table names that begin with "sqlite_" are reserved for internal use. It is an error to attempt to create a table with a name that starts with "sqlite_". <p> If a <database-name> is specified, it must be either "main", "temp", or the name of an <a href="lang_attach.html">attached database</a>. In this case the new table is created in the named database. If the "TEMP" or "TEMPORARY" keyword occurs between the "CREATE" and "TABLE" then the new table is created in the temp database. It is an error to specify both a <database-name> and the TEMP or TEMPORARY keyword, unless the <database-name> is "temp". If no database name is specified and the TEMP keyword is not present then the table is created in the main database. <p> It is usually an error to attempt to create a new table in a database that already contains a table, index or view of the same name. However, if the "IF NOT EXISTS" clause is specified as part of the CREATE TABLE statement and a table or view of the same name already exists, the CREATE TABLE command simply has no effect (and no error message is returned). An error is still returned if the table cannot be created because of an existing index, even if the "IF NOT EXISTS" clause is specified. <p>It is not an error to create a table that has the same name as an existing <a href="lang_createtrigger.html">trigger</a>. <p>Tables are removed using the <a href="lang_droptable.html">DROP TABLE</a> statement. </p> <h3>CREATE TABLE ... AS SELECT Statements</h3> <p>A "CREATE TABLE ... AS SELECT" statement creates and populates a database table based on the results of a SELECT statement. The table has the same number of columns as the rows returned by the SELECT statement. The name of each column is the same as the name of the corresponding column in the result set of the SELECT statement. The declared type of each column is determined by the <a href="datatype3.html#expraff">expression affinity</a> of the corresponding expression in the result set of the SELECT statement, as follows: </p> <center><table border=1> <tr><th>Expression Affinity <th>Column Declared Type <tr><td>TEXT <td>"TEXT" <tr><td>NUMERIC <td>"NUM" <tr><td>INTEGER <td>"INT" <tr><td>REAL <td>"REAL" <tr><td>NONE <td>"" (empty string) </table></center> <p>A table created using CREATE TABLE AS has no PRIMARY KEY and no constraints of any kind. The default value of each column is NULL. The default collation sequence for each column of the new table is BINARY. <p>Tables created using CREATE TABLE AS are initially populated with the rows of data returned by the SELECT statement. Rows are assigned contiguously ascending <a href="lang_createtable.html#rowid">rowid</a> values, starting with 1, in the <a href="lang_select.html#orderby">order</a> that they are returned by the SELECT statement. <a name="tablecoldef"></a> <h3>Column Definitions</h3> <p>Unless it is a CREATE TABLE ... AS SELECT statement, a CREATE TABLE includes one or more <a href="syntaxdiagrams.html#column-def">column definitions</a>, optionally followed by a list of <a href="syntaxdiagrams.html#table-constraint">table constraints</a>. Each column definition consists of the name of the column, optionally followed by the declared type of the column, then one or more optional <a href="syntaxdiagrams.html#column-constraint">column constraints</a>. Included in the definition of "column constraints" for the purposes of the previous statement are the COLLATE and DEFAULT clauses, even though these are not really constraints in the sense that they do not restrict the data that the table may contain. The other constraints - NOT NULL, CHECK, UNIQUE, PRIMARY KEY and FOREIGN KEY constraints - impose restrictions on the tables data, and are are described under <a href="lang_createtable.html#constraints">SQL Data Constraints</a> below. <p>Unlike most SQL databases, SQLite does not restrict the type of data that may be inserted into a column based on the columns declared type. Instead, SQLite uses <a href="datatype3.html">dynamic typing</a>. The declared type of a column is used to determine the <a href="datatype3.html#affinity">affinity</a> of the column only. <p>The DEFAULT clause specifies a default value to use for the column if no value is explicitly provided by the user when doing an <a href="lang_insert.html">INSERT</a>. If there is no explicit DEFAULT clause attached to a column definition, then the default value of the column is NULL. An explicit DEFAULT clause may specify that the default value is NULL, a string constant, a blob constant, a signed-number, or any constant expression enclosed in parentheses. An explicit default value may also be one of the special case-independent keywords CURRENT_TIME, CURRENT_DATE or CURRENT_TIMESTAMP. For the purposes of the DEFAULT clause, an expression is considered constant provided that it does not contain any sub-queries or string constants enclosed in double quotes. <p>Each time a row is inserted into the table by an INSERT statement that does not provide explicit values for all table columns the values stored in the new row are determined by their default values, as follows: <ul> <li><p>If the default value of the column is a constant NULL, text, blob or signed-number value, then that value is used directly in the new row. <li><p>If the default value of a column is an expression in parentheses, then the expression is evaluated once for each row inserted and the results used in the new row. <li><p>If the default value of a column is CURRENT_TIME, CURRENT_DATE or CURRENT_TIMESTAMP, then the value used in the new row is a text representation of the current UTC date and/or time. For CURRENT_TIME, the format of the value is "HH:MM:SS". For CURRENT_DATE, "YYYY-MM-DD". The format for CURRENT_TIMESTAMP is "YYYY-MM-DD HH:MM:SS". </ul> <p>The COLLATE clause specifies the name of a <a href="datatype3.html#collation">collating sequence</a> to use as the default collation sequence for the column. If no COLLATE clause is specified, the default collation sequence is <a href="datatype3.html#collation">BINARY</a>. <p>The number of columns in a table is limited by the <a href="limits.html#max_column">SQLITE_MAX_COLUMN</a> compile-time parameter. A single row of a table cannot store more than <a href="limits.html#max_length">SQLITE_MAX_LENGTH</a> bytes of data. Both of these limits can be lowered at runtime using the <a href="c3ref/limit.html">sqlite3_limit()</a> C/C++ interface.</p> <a name="constraints"></a> <h3>SQL Data Constraints</h3> <a name="primkeyconst"></a> <p>Each table in SQLite may have at most one <b>PRIMARY KEY</b>. If the keywords PRIMARY KEY are added to a column definition, then the primary key for the table consists of that single column. Or, if a PRIMARY KEY clause is specified as a <a href="syntaxdiagrams.html#table-constraint">table-constraint</a>, then the primary key of the table consists of the list of columns specified as part of the PRIMARY KEY clause. An error is raised if more than one PRIMARY KEY clause appears in a CREATE TABLE statement. The PRIMARY KEY is optional for ordinary tables but is required for <a href="withoutrowid.html">WITHOUT ROWID</a> tables. <p>If a table has a single column primary key and the declared type of that column is "INTEGER" and the table is not a <a href="withoutrowid.html">WITHOUT ROWID</a> table, then the column is known as an <a href="lang_createtable.html#rowid">INTEGER PRIMARY KEY</a>. See below for a description of the special properties and behaviors associated with an <a href="lang_createtable.html#rowid">INTEGER PRIMARY KEY</a>. <p>Each row in a table with a primary key must have a unique combination of values in its primary key columns. For the purposes of determining the uniqueness of primary key values, NULL values are considered distinct from all other values, including other NULLs. If an <a href="lang_insert.html">INSERT</a> or <a href="lang_update.html">UPDATE</a> statement attempts to modify the table content so that two or more rows feature identical primary key values, it is a constraint violation. According to the SQL standard, PRIMARY KEY should always imply NOT NULL. Unfortunately, due to a bug in some early versions, this is not the case in SQLite. Unless the column is an <a href="lang_createtable.html#rowid">INTEGER PRIMARY KEY</a> or the table is a <a href="withoutrowid.html">WITHOUT ROWID</a> table or the column is declared NOT NULL, SQLite allows NULL values in a PRIMARY KEY column. SQLite could be fixed to conform to the standard, but doing so might break legacy applications. Hence, it has been decided to merely document the fact that SQLite allowing NULLs in most PRIMARY KEY columns. <a name="uniqueconst"></a> <p>A <b>UNIQUE</b> constraint is similar to a PRIMARY KEY constraint, except that a single table may have any number of UNIQUE constraints. For each UNIQUE constraint on the table, each row must contain a unique combination of values in the columns identified by the UNIQUE constraint. For the purposes of UNIQUE constraints, NULL values are considered distinct from all other values, including other NULLs. <p>In most cases, UNIQUE and PRIMARY KEY constraints are implemented by creating a unique index in the database. (The exceptions are <a href="lang_createtable.html#rowid">INTEGER PRIMARY KEY</a> and PRIMARY KEYs on <a href="withoutrowid.html">WITHOUT ROWID</a> tables.) Hence, the following schemas are logically equivalent: <ol> <li><p>CREATE TABLE t1(a, b UNIQUE); <li><p>CREATE TABLE t1(a, b PRIMARY KEY); <li><p>CREATE TABLE t1(a, b);<br> CREATE UNIQUE INDEX t1b ON t1(b); </ol> <a name="ckconst"></a> <p>A <b>CHECK</b> constraint may be attached to a column definition or specified as a table constraint. In practice it makes no difference. Each time a new row is inserted into the table or an existing row is updated, the expression associated with each CHECK constraint is evaluated and cast to a NUMERIC value in the same way as a <a href="lang_expr.html#castexpr">CAST expression</a>. If the result is zero (integer value 0 or real value 0.0), then a constraint violation has occurred. If the CHECK expression evaluates to NULL, or any other non-zero value, it is not a constraint violation. The expression of a CHECK constraint may not contain a subquery. <p>CHECK constraints have been supported since <a href="releaselog/3_3_0.html">version 3.3.0</a>. Prior to version 3.3.0, CHECK constraints were parsed but not enforced. <a name="notnullconst"></a> <p>A <b>NOT NULL</b> constraint may only be attached to a column definition, not specified as a table constraint. Not surprisingly, a NOT NULL constraint dictates that the associated column may not contain a NULL value. Attempting to set the column value to NULL when inserting a new row or updating an existing one causes a constraint violation. <p>Exactly how a constraint violation is dealt with is determined by the <a href="lang_conflict.html">constraint conflict resolution algorithm</a>. Each PRIMARY KEY, UNIQUE, NOT NULL and CHECK constraint has a default conflict resolution algorithm. PRIMARY KEY, UNIQUE and NOT NULL constraints may be explicitly assigned a default conflict resolution algorithm by including a <a href="syntaxdiagrams.html#conflict-clause">conflict-clause</a> in their definitions. Or, if a constraint definition does not include a <a href="syntaxdiagrams.html#conflict-clause">conflict-clause</a> or it is a CHECK constraint, the default conflict resolution algorithm is ABORT. Different constraints within the same table may have different default conflict resolution algorithms. See the section titled <a href="lang_conflict.html">ON CONFLICT</a> for additional information. <a name="rowid"></a> <h3>ROWIDs and the INTEGER PRIMARY KEY</h3> <p>Except for <a href="withoutrowid.html">WITHOUT ROWID</a> tables, all rows within SQLite tables have a 64-bit signed integer key that uniquely identifies the row within its table. This integer is usually called the "rowid". The rowid value can be accessed using one of the special case-independent names "rowid", "oid", or "_rowid_" in place of a column name. If a table contains a user defined column named "rowid", "oid" or "_rowid_", then that name always refers the explicitly declared column and cannot be used to retrieve the integer rowid value. <p>The rowid (and "oid" and "_rowid_") is omitted in <a href="withoutrowid.html">WITHOUT ROWID</a> tables. WITHOUT ROWID tables are only available in SQLite <a href="releaselog/3_8_2.html">version 3.8.2</a> and later. A table that lacks the WITHOUT ROWID clause is called a "rowid table". <p>The data for rowid tables is stored as a B-Tree structure containing one entry for each table row, using the rowid value as the key. This means that retrieving or sorting records by rowid is fast. Searching for a record with a specific rowid, or for all records with rowids within a specified range is around twice as fast as a similar search made by specifying any other PRIMARY KEY or indexed value. <p> With one exception noted below, if a rowid table has a primary key that consists of a single column and the declared type of that column is "INTEGER" in any mixture of upper and lower case, then the column becomes an alias for the rowid. Such a column is usually referred to as an "integer primary key". A PRIMARY KEY column only becomes an integer primary key if the declared type name is exactly "INTEGER". Other integer type names like "INT" or "BIGINT" or "SHORT INTEGER" or "UNSIGNED INTEGER" causes the primary key column to behave as an ordinary table column with integer <a href="datatype3.html#affinity">affinity</a> and a unique index, not as an alias for the rowid. <p> The exception mentioned above is that if the declaration of a column with declared type "INTEGER" includes an "PRIMARY KEY DESC" clause, it does not become an alias for the rowid and is not classified as an integer primary key. This quirk is not by design. It is due to a bug in early versions of SQLite. But fixing the bug could result in backwards incompatibilities. Hence, the original behavior has been retained (and documented) because behavior in a corner case is far better than a compatibility break. This means that the following three table declarations all cause the column "x" to be an alias for the rowid (an integer primary key): <ul> <li><tt>CREATE TABLE t(x INTEGER PRIMARY KEY ASC, y, z);</tt> <li><tt>CREATE TABLE t(x INTEGER, y, z, PRIMARY KEY(x ASC));</tt> <li><tt>CREATE TABLE t(x INTEGER, y, z, PRIMARY KEY(x DESC));</tt> </ul> <p>But the following declaration does not result in "x" being an alias for the rowid: <ul> <li><tt>CREATE TABLE t(x INTEGER PRIMARY KEY DESC, y, z);</tt> </ul> <p>Rowid values may be modified using an UPDATE statement in the same way as any other column value can, either using one of the built-in aliases ("rowid", "oid" or "_rowid_") or by using an alias created by an integer primary key. Similarly, an INSERT statement may provide a value to use as the rowid for each row inserted. Unlike normal SQLite columns, an integer primary key or rowid column must contain integer values. Integer primary key or rowid columns are not able to hold floating point values, strings, BLOBs, or NULLs. <p>If an UPDATE statement attempts to set an integer primary key or rowid column to a NULL or blob value, or to a string or real value that cannot be losslessly converted to an integer, a "datatype mismatch" error occurs and the statement is aborted. If an INSERT statement attempts to insert a blob value, or a string or real value that cannot be losslessly converted to an integer into an integer primary key or rowid column, a "datatype mismatch" error occurs and the statement is aborted. <p>If an INSERT statement attempts to insert a NULL value into a rowid or integer primary key column, the system chooses an integer value to use as the rowid automatically. A detailed description of how this is done is provided <a href="autoinc.html">separately</a>.</p> <p>The <a href="foreignkeys.html#parentchild">parent key</a> of a <a href="foreignkeys.html">foreign key constraint</a> is not allowed to use the rowid. The parent key must used named columns only.</p> |
Changes to Doc/Extra/Core/lang_createtrigger.html.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 |
<html dir="LTR" xmlns="http://www.w3.org/1999/xhtml" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:MSHelp="http://msdn.microsoft.com/mshelp" xmlns:tool="http://www.microsoft.com/tooltip" xmlns:ndoc="urn:ndoc-preprocess"> <head> <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252" /> <title>CREATE TABLE</title> <link rel="stylesheet" type="text/css" href="../Include/ndoc.css" /> </head> <body> <div id="header"> <table width="100%" id="topTable"> <tr id="headerTableRow1"> <td align="left"> <span id="runningHeaderText">CREATE TRIGGER</span> </td> </tr> <tr id="headerTableRow2"> <td align="left"> <span id="nsrTitle">SQLite Language Reference Documentation</span> </td> </tr> <tr id="headerTableRow3" style="display:none"> <td> <a id="seeAlsoSectionLink" href="#seeAlsoToggle" onclick="OpenSection(seeAlsoToggle)">See Also</a> <a id="exampleSectionLink" href="#codeExampleToggle" onclick="OpenSection(codeExampleToggle)">Example</a> </td> </tr> </table> <table width="100%" id="bottomTable" cellspacing="0" cellpadding="0" style="display:none"> <tr> <td> <span onclick="ExpandCollapseAll(toggleAllImage)" style="cursor:default;" onkeypress="ExpandCollapseAll_CheckKey(toggleAllImage)" tabindex="0"> <img ID="toggleAllImage" class="toggleAll" src="collall.gif" /> <label id="collapseAllLabel" for="toggleAllImage" style="display: none;"> Collapse All </label> <label id="expandAllLabel" for="toggleAllImage" style="display: none;"> Expand All </label> </span> </td> </tr> </table> </div> <div id="mainSection"> <div id="mainBody"> <h1 class="heading"> SQL As Understood By SQLite</h1> <h4> CREATE TRIGGER</h4> <p> <table cellpadding="10"> <tr> <td align="right" width="1%" nowrap> <i><font color="#ff3434">sql-statement</font></i> ::=</td> <td> <b><font color="#2c2cf0">CREATE </font></b>[<b><font color="#2c2cf0">TEMP </font></b> <big>|</big><b><font color="#2c2cf0"> TEMPORARY</font></b>]<b><font color="#2c2cf0"> TRIGGER </font></b><i><font color="#ff3434">trigger-name</font></i><b><font color="#2c2cf0"> </font></b>[<b><font color="#2c2cf0"> BEFORE </font></b><big>|</big><b><font color="#2c2cf0"> AFTER </font></b>]<b><font color="#2c2cf0"><br /> </font></b><i><font color="#ff3434">database-event</font></i><b><font color="#2c2cf0"> ON </font></b>[<b><font color="#2c2cf0"></font></b><i><font color="#ff3434">database-name</font></i><b><font color="#2c2cf0"> <big>.</big></font></b>]<b><font color="#2c2cf0"> </font></b> <i><font color="#ff3434">table-name</font></i><b><font color="#2c2cf0"><br /> </font></b><i><font color="#ff3434">trigger-action</font></i><b><font color="#2c2cf0"></font></b></td> </tr> </table> <table cellpadding="10"> <tr> <td align="right" width="1%" nowrap> <i><font color="#ff3434">sql-statement</font></i> ::=</td> <td> <b><font color="#2c2cf0">CREATE </font></b>[<b><font color="#2c2cf0">TEMP </font></b> <big>|</big><b><font color="#2c2cf0"> TEMPORARY</font></b>]<b><font color="#2c2cf0"> TRIGGER </font></b><i><font color="#ff3434">trigger-name</font></i><b><font color="#2c2cf0"> INSTEAD OF<br /> </font></b><i><font color="#ff3434">database-event</font></i><b><font color="#2c2cf0"> ON </font></b>[<b><font color="#2c2cf0"></font></b><i><font color="#ff3434">database-name</font></i><b><font color="#2c2cf0"> <big>.</big></font></b>]<b><font color="#2c2cf0"> </font></b> <i><font color="#ff3434">view-name</font></i><b><font color="#2c2cf0"><br /> </font></b><i><font color="#ff3434">trigger-action</font></i><b><font color="#2c2cf0"></font></b></td> </tr> </table> <table cellpadding="10"> <tr> <td align="right" width="1%" nowrap> <i><font color="#ff3434">database-event</font></i> ::=</td> <td> <b><font color="#2c2cf0">DELETE </font></b><big>|</big><b><font color="#2c2cf0"> <br /> INSERT </font></b><big>|</big><b><font color="#2c2cf0"> <br /> UPDATE </font></b><big>|</big><b><font color="#2c2cf0"> <br /> UPDATE OF </font></b><i><font color="#ff3434">column-list</font></i><b><font color="#2c2cf0"></font></b></td> </tr> </table> <table cellpadding="10"> <tr> <td align="right" width="1%" nowrap> <i><font color="#ff3434">trigger-action</font></i> ::=</td> <td> <b><font color="#2c2cf0"></font></b>[<b><font color="#2c2cf0"> FOR EACH ROW </font> </b><big>|</big><b><font color="#2c2cf0"> FOR EACH STATEMENT </font></b>]<b><font color="#2c2cf0"> </font></b>[<b><font color="#2c2cf0"> WHEN </font></b><i><font color="#ff3434"> expression</font></i><b><font color="#2c2cf0"> </font></b>]<b><font color="#2c2cf0"> <br /> BEGIN <br /> </font></b><i><font color="#ff3434">trigger-step</font></i><b><font color="#2c2cf0"> ; </font></b>[<b><font color="#2c2cf0"> </font></b><i><font color="#ff3434"> trigger-step</font></i><b><font color="#2c2cf0"> ; </font></b>]<b><font color="#2c2cf0"></font></b><big>*</big><b><font color="#2c2cf0"><br /> END</font></b></td> </tr> </table> <table cellpadding="10"> <tr> <td align="right" width="1%" nowrap> <i><font color="#ff3434">trigger-step</font></i> ::=</td> <td> <b><font color="#2c2cf0"></font></b><i><font color="#ff3434">update-statement</font></i><b><font color="#2c2cf0"> </font></b><big>|</big><b><font color="#2c2cf0"> </font></b><i><font color="#ff3434">insert-statement</font></i><b><font color="#2c2cf0"> </font></b> <big>|</big><b><font color="#2c2cf0"> <br /> </font></b><i><font color="#ff3434">delete-statement</font></i><b><font color="#2c2cf0"> </font></b><big>|</big><b><font color="#2c2cf0"> </font></b><i><font color="#ff3434"> select-statement</font></i><b><font color="#2c2cf0"></font></b></td> </tr> </table> </p> <p> The CREATE TRIGGER statement is used to add triggers to the database schema. Triggers are database operations (the <i>trigger-action</i>) that are automatically performed when a specified database event (the <i>database-event</i>) occurs. </p> <p> A trigger may be specified to fire whenever a DELETE, INSERT or UPDATE of a particular database table occurs, or whenever an UPDATE of one or more specified columns of a table are updated.</p> <p> At this time SQLite supports only FOR EACH ROW triggers, not FOR EACH STATEMENT triggers. Hence explicitly specifying FOR EACH ROW is optional. FOR EACH ROW implies that the SQL statements specified as <i>trigger-steps</i> may be executed (depending on the WHEN clause) for each database row being inserted, updated or deleted by the statement causing the trigger to fire.</p> <p> Both the WHEN clause and the <i>trigger-steps</i> may access elements of the row being inserted, deleted or updated using references of the form "NEW.<i>column-name</i>" and "OLD.<i>column-name</i>", where <i>column-name</i> is the name of a column from the table that the trigger is associated with. OLD and NEW references may only be used in triggers on <i>trigger-event</i>s for which they are relevant, as follows:</p> <p> <table border="0" cellpadding="10"> <tr> <td align="right" valign="top" width="120"> <i>INSERT</i></td> <td valign="top"> NEW references are valid</td> </tr> <tr> <td align="right" valign="top" width="120"> <i>UPDATE</i></td> <td valign="top"> NEW and OLD references are valid</td> </tr> <tr> <td align="right" valign="top" width="120"> <i>DELETE</i></td> <td valign="top"> OLD references are valid</td> </tr> </table> </p> <p> </p> <p> If a WHEN clause is supplied, the SQL statements specified as <i>trigger-steps</i> are only executed for rows for which the WHEN clause is true. If no WHEN clause is supplied, the SQL statements are executed for all rows.</p> <p> The specified <i>trigger-time</i> determines when the <i>trigger-steps</i> will be executed relative to the insertion, modification or removal of the associated row.</p> <p> An ON CONFLICT clause may be specified as part of an UPDATE or INSERT <i>trigger-step</i>. However if an ON CONFLICT clause is specified as part of the statement causing the trigger to fire, then this conflict handling policy is used instead.</p> <p> Triggers are automatically dropped when the table that they are associated with is dropped.</p> <p> Triggers may be created on views, as well as ordinary tables, by specifying INSTEAD OF in the CREATE TRIGGER statement. If one or more ON INSERT, ON DELETE or ON UPDATE triggers are defined on a view, then it is not an error to execute an INSERT, DELETE or UPDATE statement on the view, respectively. Thereafter, executing an INSERT, DELETE or UPDATE on the view causes the associated triggers to fire. The real tables underlying the view are not modified (except possibly explicitly, by a trigger program).</p> <p> <b>Example:</b></p> <p> Assuming that customer records are stored in the "customers" table, and that order records are stored in the "orders" table, the following trigger ensures that all associated orders are redirected when a customer changes his or her address:</p> <blockquote> <pre> CREATE TRIGGER update_customer_address UPDATE OF address ON customers BEGIN UPDATE orders SET address = new.address WHERE customer_name = old.name; END; </pre> </blockquote> <p> With this trigger installed, executing the statement:</p> <blockquote> <pre> UPDATE customers SET address = '1 Main St.' WHERE name = 'Jack Jones'; </pre> </blockquote> <p> causes the following to be automatically executed:</p> <blockquote> <pre> UPDATE orders SET address = '1 Main St.' WHERE customer_name = 'Jack Jones'; </pre> </blockquote> <p> Note that currently, triggers may behave oddly when created on tables with INTEGER PRIMARY KEY fields. If a BEFORE trigger program modifies the INTEGER PRIMARY KEY field of a row that will be subsequently updated by the statement that causes the trigger to fire, then the update may not occur. The workaround is to declare the table with a PRIMARY KEY column instead of an INTEGER PRIMARY KEY column.</p> <p> A special SQL function RAISE() may be used within a trigger-program, with the following syntax</p> <p> <table cellpadding="10"> <tr> <td align="right" width="1%" nowrap> <i><font color="#ff3434">raise-function</font></i> ::=</td> <td> <b><font color="#2c2cf0">RAISE <big>(</big> ABORT<big>,</big> </font></b><i><font color="#ff3434">error-message</font></i><b><font color="#2c2cf0"> <big>)</big> </font> </b><big>|</big><b><font color="#2c2cf0"> <br /> RAISE <big>(</big> FAIL<big>,</big> </font></b><i><font color="#ff3434">error-message</font></i><b><font color="#2c2cf0"> <big>)</big> </font></b><big>|</big><b><font color="#2c2cf0"> <br /> RAISE <big>(</big> ROLLBACK<big>,</big> </font></b><i><font color="#ff3434">error-message</font></i><b><font color="#2c2cf0"> <big>)</big> </font></b><big>|</big><b><font color="#2c2cf0"> <br /> RAISE <big>(</big> IGNORE <big>)</big></font></b></td> </tr> </table> </p> <p> When one of the first three forms is called during trigger-program execution, the specified ON CONFLICT processing is performed (either ABORT, FAIL or ROLLBACK) and the current query terminates. An error code of SQLITE_CONSTRAINT is returned to the user, along with the specified error message.</p> <p> When RAISE(IGNORE) is called, the remainder of the current trigger program, the statement that caused the trigger program to execute and any subsequent trigger programs that would of been executed are abandoned. No database changes are rolled back. If the statement that caused the trigger program to execute is itself part of a trigger program, then that trigger program resumes execution at the beginning of the next step. </p> <p> Triggers are removed using the <a href="lang_droptrigger.html">DROP TRIGGER</a> statement.</p> <p> <hr> </p> <div id="footer"> <p> </p> <p> </p> </div> </div> </div> </body> </html> |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html><head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>SQLite Query Language: CREATE TRIGGER</title> <style type="text/css"> body { margin: auto; font-family: Verdana, sans-serif; padding: 8px 1%; } a { color: #044a64 } a:visited { color: #734559 } .logo { position:absolute; margin:3px; } .tagline { float:right; text-align:right; font-style:italic; width:300px; margin:12px; margin-top:58px; } .menubar { clear: both; border-radius: 8px; background: #044a64; padding: 0px; margin: 0px; cell-spacing: 0px; } .toolbar { text-align: center; line-height: 1.6em; margin: 0; padding: 0px 8px; } .toolbar a { color: white; text-decoration: none; padding: 6px 12px; } .toolbar a:visited { color: white; } .toolbar a:hover { color: #044a64; background: white; } .content { margin: 5%; } .content dt { font-weight:bold; } .content dd { margin-bottom: 25px; margin-left:20%; } .content ul { padding:0px; padding-left: 15px; margin:0px; } /* Things for "fancyformat" documents start here. */ .fancy img+p {font-style:italic} .fancy .codeblock i { color: darkblue; } .fancy h1,.fancy h2,.fancy h3,.fancy h4 {font-weight:normal;color:#044a64} .fancy h2 { margin-left: 10px } .fancy h3 { margin-left: 20px } .fancy h4 { margin-left: 30px } .fancy th {white-space:nowrap;text-align:left;border-bottom:solid 1px #444} .fancy th, .fancy td {padding: 0.2em 1ex; vertical-align:top} .fancy #toc a { color: darkblue ; text-decoration: none } .fancy .todo { color: #AA3333 ; font-style : italic } .fancy .todo:before { content: 'TODO:' } .fancy p.todo { border: solid #AA3333 1px; padding: 1ex } .fancy img { display:block; } .fancy :link:hover, .fancy :visited:hover { background: wheat } .fancy p,.fancy ul,.fancy ol { margin: 1em 5ex } .fancy li p { margin: 1em 0 } /* End of "fancyformat" specific rules. */ </style> </head> <body> <div><!-- container div to satisfy validator --> <a href="index.html"> <img class="logo" src="images/sqlite370_banner.gif" alt="SQLite Logo" border="0"></a> <div><!-- IE hack to prevent disappearing logo--></div> <div class="tagline">Small. Fast. Reliable.<br>Choose any three.</div> <table width=100% class="menubar"><tr> <td width=100%> <div class="toolbar"> <a href="about.html">About</a> <a href="sitemap.html">Sitemap</a> <a href="docs.html">Documentation</a> <a href="download.html">Download</a> <a href="copyright.html">License</a> <a href="news.html">News</a> <a href="support.html">Support</a> </div> <script> gMsg = "Search SQLite Docs..." function entersearch() { var q = document.getElementById("q"); if( q.value == gMsg ) { q.value = "" } q.style.color = "black" q.style.fontStyle = "normal" } function leavesearch() { var q = document.getElementById("q"); if( q.value == "" ) { q.value = gMsg q.style.color = "#044a64" q.style.fontStyle = "italic" } } function hideorshow(btn,obj){ var x = document.getElementById(obj); var b = document.getElementById(btn); if( x.style.display!='none' ){ x.style.display = 'none'; b.innerHTML='show'; }else{ x.style.display = ''; b.innerHTML='hide'; } return false; } </script> <td> <div style="padding:0 1em 0px 0;white-space:nowrap"> <form name=f method="GET" action="http://www.sqlite.org/search"> <input id=q name=q type=text onfocus="entersearch()" onblur="leavesearch()" style="width:24ex;padding:1px 1ex; border:solid white 1px; font-size:0.9em ; font-style:italic;color:#044a64;" value="Search SQLite Docs..."> <input type=submit value="Go" style="border:solid white 1px;background-color:#044a64;color:white;font-size:0.9em;padding:0 1ex"> </form> </div> </table> <div class=startsearch></div> <h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>CREATE TRIGGER</h2><p><b><a href="syntaxdiagrams.html#create-trigger-stmt">create-trigger-stmt:</a></b> <button id='x907' onclick='hideorshow("x907","x908")'>hide</button></p> <blockquote id='x908'> <img alt="syntax diagram create-trigger-stmt" src="images/syntax/create-trigger-stmt.gif" /> <p><b><a href="syntaxdiagrams.html#delete-stmt">delete-stmt:</a></b> <button id='x909' onclick='hideorshow("x909","x910")'>show</button></p> <blockquote id='x910' style='display:none;'> <img alt="syntax diagram delete-stmt" src="images/syntax/delete-stmt.gif" /> <p><b><a href="syntaxdiagrams.html#qualified-table-name">qualified-table-name:</a></b> <button id='x911' onclick='hideorshow("x911","x912")'>show</button></p> <blockquote id='x912' style='display:none;'> <img alt="syntax diagram qualified-table-name" src="images/syntax/qualified-table-name.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#with-clause">with-clause:</a></b> <button id='x913' onclick='hideorshow("x913","x914")'>show</button></p> <blockquote id='x914' style='display:none;'> <img alt="syntax diagram with-clause" src="images/syntax/with-clause.gif" /> <p><b><a href="syntaxdiagrams.html#cte-table-name">cte-table-name:</a></b> <button id='x915' onclick='hideorshow("x915","x916")'>show</button></p> <blockquote id='x916' style='display:none;'> <img alt="syntax diagram cte-table-name" src="images/syntax/cte-table-name.gif" /> </blockquote> </blockquote> </blockquote> <p><b><a href="syntaxdiagrams.html#expr">expr:</a></b> <button id='x917' onclick='hideorshow("x917","x918")'>show</button></p> <blockquote id='x918' style='display:none;'> <img alt="syntax diagram expr" src="images/syntax/expr.gif" /> <p><b><a href="syntaxdiagrams.html#literal-value">literal-value:</a></b> <button id='x919' onclick='hideorshow("x919","x920")'>show</button></p> <blockquote id='x920' style='display:none;'> <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#raise-function">raise-function:</a></b> <button id='x921' onclick='hideorshow("x921","x922")'>show</button></p> <blockquote id='x922' style='display:none;'> <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#type-name">type-name:</a></b> <button id='x923' onclick='hideorshow("x923","x924")'>show</button></p> <blockquote id='x924' style='display:none;'> <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" /> <p><b><a href="syntaxdiagrams.html#signed-number">signed-number:</a></b> <button id='x925' onclick='hideorshow("x925","x926")'>show</button></p> <blockquote id='x926' style='display:none;'> <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" /> </blockquote> </blockquote> </blockquote> <p><b><a href="syntaxdiagrams.html#insert-stmt">insert-stmt:</a></b> <button id='x927' onclick='hideorshow("x927","x928")'>show</button></p> <blockquote id='x928' style='display:none;'> <img alt="syntax diagram insert-stmt" src="images/syntax/insert-stmt.gif" /> <p><b><a href="syntaxdiagrams.html#with-clause">with-clause:</a></b> <button id='x929' onclick='hideorshow("x929","x930")'>show</button></p> <blockquote id='x930' style='display:none;'> <img alt="syntax diagram with-clause" src="images/syntax/with-clause.gif" /> <p><b><a href="syntaxdiagrams.html#cte-table-name">cte-table-name:</a></b> <button id='x931' onclick='hideorshow("x931","x932")'>show</button></p> <blockquote id='x932' style='display:none;'> <img alt="syntax diagram cte-table-name" src="images/syntax/cte-table-name.gif" /> </blockquote> </blockquote> </blockquote> <p><b><a href="syntaxdiagrams.html#select-stmt">select-stmt:</a></b> <button id='x933' onclick='hideorshow("x933","x934")'>show</button></p> <blockquote id='x934' style='display:none;'> <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" /> <p><b><a href="syntaxdiagrams.html#common-table-expression">common-table-expression:</a></b> <button id='x935' onclick='hideorshow("x935","x936")'>show</button></p> <blockquote id='x936' style='display:none;'> <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#compound-operator">compound-operator:</a></b> <button id='x937' onclick='hideorshow("x937","x938")'>show</button></p> <blockquote id='x938' style='display:none;'> <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#join-clause">join-clause:</a></b> <button id='x939' onclick='hideorshow("x939","x940")'>show</button></p> <blockquote id='x940' style='display:none;'> <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" /> <p><b><a href="syntaxdiagrams.html#join-constraint">join-constraint:</a></b> <button id='x941' onclick='hideorshow("x941","x942")'>show</button></p> <blockquote id='x942' style='display:none;'> <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#join-operator">join-operator:</a></b> <button id='x943' onclick='hideorshow("x943","x944")'>show</button></p> <blockquote id='x944' style='display:none;'> <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" /> </blockquote> </blockquote> <p><b><a href="syntaxdiagrams.html#ordering-term">ordering-term:</a></b> <button id='x945' onclick='hideorshow("x945","x946")'>show</button></p> <blockquote id='x946' style='display:none;'> <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#result-column">result-column:</a></b> <button id='x947' onclick='hideorshow("x947","x948")'>show</button></p> <blockquote id='x948' style='display:none;'> <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#table-or-subquery">table-or-subquery:</a></b> <button id='x949' onclick='hideorshow("x949","x950")'>show</button></p> <blockquote id='x950' style='display:none;'> <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" /> </blockquote> </blockquote> <p><b><a href="syntaxdiagrams.html#update-stmt">update-stmt:</a></b> <button id='x951' onclick='hideorshow("x951","x952")'>show</button></p> <blockquote id='x952' style='display:none;'> <img alt="syntax diagram update-stmt" src="images/syntax/update-stmt.gif" /> <p><b><a href="syntaxdiagrams.html#qualified-table-name">qualified-table-name:</a></b> <button id='x953' onclick='hideorshow("x953","x954")'>show</button></p> <blockquote id='x954' style='display:none;'> <img alt="syntax diagram qualified-table-name" src="images/syntax/qualified-table-name.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#with-clause">with-clause:</a></b> <button id='x955' onclick='hideorshow("x955","x956")'>show</button></p> <blockquote id='x956' style='display:none;'> <img alt="syntax diagram with-clause" src="images/syntax/with-clause.gif" /> <p><b><a href="syntaxdiagrams.html#cte-table-name">cte-table-name:</a></b> <button id='x957' onclick='hideorshow("x957","x958")'>show</button></p> <blockquote id='x958' style='display:none;'> <img alt="syntax diagram cte-table-name" src="images/syntax/cte-table-name.gif" /> </blockquote> </blockquote> </blockquote> </blockquote> <p>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 occurs. </p> <p>A trigger may be specified to fire whenever a <a href="lang_delete.html">DELETE</a>, <a href="lang_insert.html">INSERT</a>, or <a href="lang_update.html">UPDATE</a> of a particular database table occurs, or whenever an <a href="lang_update.html">UPDATE</a> occurs on on one or more specified columns of a table.</p> <p>At this time SQLite supports only FOR EACH ROW triggers, not FOR EACH STATEMENT triggers. Hence explicitly specifying FOR EACH ROW is optional. FOR EACH ROW implies that the SQL statements specified in the trigger may be executed (depending on the WHEN clause) for each database row being inserted, updated or deleted by the statement causing the trigger to fire.</p> <p>Both the WHEN clause and the trigger actions may access elements of the row being inserted, deleted or updated using references of the form "NEW.<i>column-name</i>" and "OLD.<i>column-name</i>", where <i>column-name</i> is the name of a column from the table that the trigger is associated with. OLD and NEW references may only be used in triggers on events for which they are relevant, as follows:</p> <table border=0 cellpadding=10> <tr> <td valign="top" align="right" width=120><i>INSERT</i></td> <td valign="top">NEW references are valid</td> </tr> <tr> <td valign="top" align="right" width=120><i>UPDATE</i></td> <td valign="top">NEW and OLD references are valid</td> </tr> <tr> <td valign="top" align="right" width=120><i>DELETE</i></td> <td valign="top">OLD references are valid</td> </tr> </table> </p> <p>If a WHEN clause is supplied, the SQL statements specified are only executed for rows for which the WHEN clause is true. If no WHEN clause is supplied, the SQL statements are executed for all rows.</p> <p>The BEFORE or AFTER keyword determines when the trigger actions will be executed relative to the insertion, modification or removal of the associated row.</p> <p>An <a href="lang_conflict.html">ON CONFLICT</a> clause may be specified as part of an <a href="lang_update.html">UPDATE</a> or <a href="lang_insert.html">INSERT</a> action within the body of the trigger. However if an <a href="lang_conflict.html">ON CONFLICT</a> clause is specified as part of the statement causing the trigger to fire, then conflict handling policy of the outer statement is used instead.</p> <p>Triggers are automatically <a href="lang_droptrigger.html">dropped</a> when the table that they are associated with (the <i>table-name</i> table) is <a href="lang_droptable.html">dropped</a>. However if the trigger actions reference other tables, the trigger is not dropped or modified if those other tables are <a href="lang_droptable.html">dropped</a> or <a href="lang_altertable.html">modified</a>.</p> <p>Triggers are removed using the <a href="lang_droptrigger.html">DROP TRIGGER</a> statement.</p> <h3>Syntax Restrictions On UPDATE, DELETE, and INSERT Statements Within Triggers</h3> <p>The <a href="lang_update.html">UPDATE</a>, <a href="lang_delete.html">DELETE</a>, and <a href="lang_insert.html">INSERT</a> statements within triggers do not support the full syntax for <a href="lang_update.html">UPDATE</a>, <a href="lang_delete.html">DELETE</a>, and <a href="lang_insert.html">INSERT</a> statements. The following restrictions apply:</p> <ul> <li><p> The name of the table to be modified in an <a href="lang_update.html">UPDATE</a>, <a href="lang_delete.html">DELETE</a>, or <a href="lang_insert.html">INSERT</a> statement must be an unqualified table name. In other words, one must use just "<i>tablename</i>" not "<i>database</i><b>.</b><i>tablename</i>" when specifying the table. The table to be modified must exist in the same database as the table or view to which the trigger is attached. </p></li> <li><p> The "INSERT INTO <i>table</i> DEFAULT VALUES" form of the <a href="lang_insert.html">INSERT</a> statement is not supported. </p></li> <li><p> The INDEXED BY and NOT INDEXED clauses are not supported for <a href="lang_update.html">UPDATE</a> and <a href="lang_delete.html">DELETE</a> statements. </p></li> <li><p> The ORDER BY and LIMIT clauses on <a href="lang_update.html">UPDATE</a> and <a href="lang_delete.html">DELETE</a> statements are not supported. ORDER BY and LIMIT are not normally supported for <a href="lang_update.html">UPDATE</a> or <a href="lang_delete.html">DELETE</a> in any context but can be enabled for top-level statements using the <a href="compile.html#enable_update_delete_limit">SQLITE_ENABLE_UPDATE_DELETE_LIMIT</a> compile-time option. However, that compile-time option only applies to top-level <a href="lang_update.html">UPDATE</a> and <a href="lang_delete.html">DELETE</a> statements, not <a href="lang_update.html">UPDATE</a> and <a href="lang_delete.html">DELETE</a> statements within triggers. </p></li> </ul> <a name="instead_of_trigger"></a> <h3>INSTEAD OF trigger</h3> <p>Triggers may be created on <a href="lang_createview.html">views</a>, as well as ordinary tables, by specifying INSTEAD OF in the CREATE TRIGGER statement. If one or more ON INSERT, ON DELETE or ON UPDATE triggers are defined on a view, then it is not an error to execute an INSERT, DELETE or UPDATE statement on the view, respectively. Instead, executing an INSERT, DELETE or UPDATE on the view causes the associated triggers to fire. The real tables underlying the view are not modified (except possibly explicitly, by a trigger program).</p> <p>Note that the <a href="c3ref/changes.html">sqlite3_changes()</a> and <a href="c3ref/total_changes.html">sqlite3_total_changes()</a> interfaces do not count INSTEAD OF trigger firings, but the <a href="pragma.html#pragma_count_changes">count_changes pragma</a> does count INSTEAD OF trigger firing.</p> <h3>Examples</h3> <p>Assuming that customer records are stored in the "customers" table, and that order records are stored in the "orders" table, the following trigger ensures that all associated orders are redirected when a customer changes his or her address:</p> <blockquote><pre> CREATE TRIGGER update_customer_address UPDATE OF address ON customers BEGIN UPDATE orders SET address = new.address WHERE customer_name = old.name; END; </pre></blockquote> <p>With this trigger installed, executing the statement:</p> <blockquote><pre> UPDATE customers SET address = '1 Main St.' WHERE name = 'Jack Jones'; </pre></blockquote> <p>causes the following to be automatically executed:</p> <blockquote><pre> UPDATE orders SET address = '1 Main St.' WHERE customer_name = 'Jack Jones'; </pre></blockquote> <a name="undef_before"></a> <h3>Cautions On The Use Of BEFORE triggers</h3> <p>If a BEFORE UPDATE or BEFORE DELETE trigger modifies or deletes a row that was to have been updated or deleted, then the result of the subsequent update or delete operation is undefined. Furthermore, if a BEFORE trigger modifies or deletes a row, then it is undefined whether or not AFTER triggers that would have otherwise run on those rows will in fact run. </p> <p>The value of NEW.rowid is undefined in a BEFORE INSERT trigger in which the rowid is not explicitly set to an integer.</p> <p>Because of the behaviors described above, programmers are encouraged to prefer AFTER triggers over BEFORE triggers.</p> <h3>The RAISE() function</h3> <p>A special SQL function RAISE() may be used within a trigger-program, with the following syntax</p> <p><b><a href="syntaxdiagrams.html#raise-function">raise-function:</a></b></p><blockquote> <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif"></img> </blockquote> <p>When one of RAISE(ROLLBACK,...), RAISE(ABORT,...) or RAISE(FAIL,...) is called during trigger-program execution, the specified <a href="lang_conflict.html">ON CONFLICT</a> processing is performed the current query terminates. An error code of <a href="c3ref/c_abort.html">SQLITE_CONSTRAINT</a> is returned to the application, along with the specified error message.</p> <p>When RAISE(IGNORE) is called, the remainder of the current trigger program, the statement that caused the trigger program to execute and any subsequent trigger programs that would have been executed are abandoned. No database changes are rolled back. If the statement that caused the trigger program to execute is itself part of a trigger program, then that trigger program resumes execution at the beginning of the next step. </p> <a name="temptrig"></a> <h3>TEMP Triggers on Non-TEMP Tables</h3> <p>A trigger normally exists in the same database as the table named after the "ON" keyword in the CREATE TRIGGER statement. Except, it is possible to create a TEMP TRIGGER on a table in another database. Such a trigger will only fire when changes are made to the target table by the application that defined the trigger. Other applications that modify the database will not be able to see the TEMP trigger and hence cannot run the trigger.</p> <p>When defining a TEMP trigger on a non-TEMP table, it is important to specify the database holding the non-TEMP table. For example, in the following statement, it is important to say "main.tab1" instead of just "tab1":</p> <blockquote><pre> CREATE TEMP TRIGGER ex1 AFTER INSERT ON <b>main.</b>tab1 BEGIN ... </pre></blockquote> <p>Failure to specify the database name on the target table could result in the TEMP trigger being reattached to a table with the same name in another database whenever any schema change occurs.</p> |
Changes to Doc/Extra/Core/lang_createview.html.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
<html dir="LTR" xmlns="http://www.w3.org/1999/xhtml" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:MSHelp="http://msdn.microsoft.com/mshelp" xmlns:tool="http://www.microsoft.com/tooltip" xmlns:ndoc="urn:ndoc-preprocess"> <head> <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252" /> <title>CREATE VIEW</title> <link rel="stylesheet" type="text/css" href="../Include/ndoc.css" /> </head> <body> <div id="header"> <table width="100%" id="topTable"> <tr id="headerTableRow1"> <td align="left"> <span id="runningHeaderText">CREATE VIEW</span> </td> </tr> <tr id="headerTableRow2"> <td align="left"> <span id="nsrTitle">SQLite Language Reference Documentation</span> </td> </tr> <tr id="headerTableRow3" style="display:none"> <td> <a id="seeAlsoSectionLink" href="#seeAlsoToggle" onclick="OpenSection(seeAlsoToggle)">See Also</a> <a id="exampleSectionLink" href="#codeExampleToggle" onclick="OpenSection(codeExampleToggle)">Example</a> </td> </tr> </table> <table width="100%" id="bottomTable" cellspacing="0" cellpadding="0" style="display:none"> <tr> <td> <span onclick="ExpandCollapseAll(toggleAllImage)" style="cursor:default;" onkeypress="ExpandCollapseAll_CheckKey(toggleAllImage)" tabindex="0"> <img ID="toggleAllImage" class="toggleAll" src="collall.gif" /> <label id="collapseAllLabel" for="toggleAllImage" style="display: none;"> Collapse All </label> <label id="expandAllLabel" for="toggleAllImage" style="display: none;"> Expand All </label> </span> </td> </tr> </table> </div> <div id="mainSection"> <div id="mainBody"> <h1 class="heading"> SQL As Understood By SQLite</h1> <h4> CREATE VIEW</h4> <p> <table cellpadding="10"> <tr> <td align="right" width="1%" nowrap> <i><font color="#ff3434">sql-command</font></i> ::=</td> <td> <b><font color="#2c2cf0">CREATE </font></b>[<b><font color="#2c2cf0">TEMP </font></b> <big>|</big><b><font color="#2c2cf0"> TEMPORARY</font></b>]<b><font color="#2c2cf0"> VIEW </font></b>[<b><font color="#2c2cf0"></font></b><i><font color="#ff3434">database-name</font></i><b><font color="#2c2cf0"><big>.</big></font></b>]<b><font color="#2c2cf0"> </font></b> <i><font color="#ff3434">view-name</font></i><b><font color="#2c2cf0"> AS </font></b> <i><font color="#ff3434">select-statement</font></i><b><font color="#2c2cf0"></font></b></td> </tr> </table> </p> <p> The CREATE VIEW command assigns a name to a pre-packaged <a href="lang_select.html"> SELECT</a> statement. Once the view is created, it can be used in the FROM clause of another SELECT in place of a table name. </p> <p> If the "TEMP" or "TEMPORARY" keyword occurs in between "CREATE" and "VIEW" then the view that is created is only visible to the process that opened the database and is automatically deleted when the database is closed.</p> <p> If a <database-name> is specified, then the view is created in the named database. It is an error to specify both a <database-name> and the TEMP keyword, unless the <database-name> is "temp". If no database name is specified, and the TEMP keyword is not present, the table is created in the main database.</p> <p> You cannot COPY, DELETE, INSERT or UPDATE a view. Views are read-only in SQLite. However, in many cases you can use a <a href="lang_createtrigger.html">TRIGGER</a> on the view to accomplish the same thing. Views are removed with the <a href="lang_dropview.html"> DROP VIEW</a> command.</p> <p> <hr> </p> <div id="footer"> <p> </p> <p> </p> </div> </div> </div> </body> </html> |
| | | | | < | > | | < < > > | | < > | | | | | | | | < < > > | | | | | | | < > | | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | < < < > > > > > > > > > > > > > > > > > > > > > | < < < < < < < < < < < > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | < < < < < < > > > > > > | | < < > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > | | | < > | | > | < > | | > | | < < > > | < > > | < < < < < < < < < < < < < > > |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html><head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>SQLite Query Language: CREATE VIEW</title> <style type="text/css"> body { margin: auto; font-family: Verdana, sans-serif; padding: 8px 1%; } a { color: #044a64 } a:visited { color: #734559 } .logo { position:absolute; margin:3px; } .tagline { float:right; text-align:right; font-style:italic; width:300px; margin:12px; margin-top:58px; } .menubar { clear: both; border-radius: 8px; background: #044a64; padding: 0px; margin: 0px; cell-spacing: 0px; } .toolbar { text-align: center; line-height: 1.6em; margin: 0; padding: 0px 8px; } .toolbar a { color: white; text-decoration: none; padding: 6px 12px; } .toolbar a:visited { color: white; } .toolbar a:hover { color: #044a64; background: white; } .content { margin: 5%; } .content dt { font-weight:bold; } .content dd { margin-bottom: 25px; margin-left:20%; } .content ul { padding:0px; padding-left: 15px; margin:0px; } /* Things for "fancyformat" documents start here. */ .fancy img+p {font-style:italic} .fancy .codeblock i { color: darkblue; } .fancy h1,.fancy h2,.fancy h3,.fancy h4 {font-weight:normal;color:#044a64} .fancy h2 { margin-left: 10px } .fancy h3 { margin-left: 20px } .fancy h4 { margin-left: 30px } .fancy th {white-space:nowrap;text-align:left;border-bottom:solid 1px #444} .fancy th, .fancy td {padding: 0.2em 1ex; vertical-align:top} .fancy #toc a { color: darkblue ; text-decoration: none } .fancy .todo { color: #AA3333 ; font-style : italic } .fancy .todo:before { content: 'TODO:' } .fancy p.todo { border: solid #AA3333 1px; padding: 1ex } .fancy img { display:block; } .fancy :link:hover, .fancy :visited:hover { background: wheat } .fancy p,.fancy ul,.fancy ol { margin: 1em 5ex } .fancy li p { margin: 1em 0 } /* End of "fancyformat" specific rules. */ </style> </head> <body> <div><!-- container div to satisfy validator --> <a href="index.html"> <img class="logo" src="images/sqlite370_banner.gif" alt="SQLite Logo" border="0"></a> <div><!-- IE hack to prevent disappearing logo--></div> <div class="tagline">Small. Fast. Reliable.<br>Choose any three.</div> <table width=100% class="menubar"><tr> <td width=100%> <div class="toolbar"> <a href="about.html">About</a> <a href="sitemap.html">Sitemap</a> <a href="docs.html">Documentation</a> <a href="download.html">Download</a> <a href="copyright.html">License</a> <a href="news.html">News</a> <a href="support.html">Support</a> </div> <script> gMsg = "Search SQLite Docs..." function entersearch() { var q = document.getElementById("q"); if( q.value == gMsg ) { q.value = "" } q.style.color = "black" q.style.fontStyle = "normal" } function leavesearch() { var q = document.getElementById("q"); if( q.value == "" ) { q.value = gMsg q.style.color = "#044a64" q.style.fontStyle = "italic" } } function hideorshow(btn,obj){ var x = document.getElementById(obj); var b = document.getElementById(btn); if( x.style.display!='none' ){ x.style.display = 'none'; b.innerHTML='show'; }else{ x.style.display = ''; b.innerHTML='hide'; } return false; } </script> <td> <div style="padding:0 1em 0px 0;white-space:nowrap"> <form name=f method="GET" action="http://www.sqlite.org/search"> <input id=q name=q type=text onfocus="entersearch()" onblur="leavesearch()" style="width:24ex;padding:1px 1ex; border:solid white 1px; font-size:0.9em ; font-style:italic;color:#044a64;" value="Search SQLite Docs..."> <input type=submit value="Go" style="border:solid white 1px;background-color:#044a64;color:white;font-size:0.9em;padding:0 1ex"> </form> </div> </table> <div class=startsearch></div> <h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>CREATE VIEW</h2><p><b><a href="syntaxdiagrams.html#create-view-stmt">create-view-stmt:</a></b> <button id='x959' onclick='hideorshow("x959","x960")'>hide</button></p> <blockquote id='x960'> <img alt="syntax diagram create-view-stmt" src="images/syntax/create-view-stmt.gif" /> <p><b><a href="syntaxdiagrams.html#select-stmt">select-stmt:</a></b> <button id='x961' onclick='hideorshow("x961","x962")'>show</button></p> <blockquote id='x962' style='display:none;'> <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" /> <p><b><a href="syntaxdiagrams.html#common-table-expression">common-table-expression:</a></b> <button id='x963' onclick='hideorshow("x963","x964")'>show</button></p> <blockquote id='x964' style='display:none;'> <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#compound-operator">compound-operator:</a></b> <button id='x965' onclick='hideorshow("x965","x966")'>show</button></p> <blockquote id='x966' style='display:none;'> <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#expr">expr:</a></b> <button id='x967' onclick='hideorshow("x967","x968")'>show</button></p> <blockquote id='x968' style='display:none;'> <img alt="syntax diagram expr" src="images/syntax/expr.gif" /> <p><b><a href="syntaxdiagrams.html#literal-value">literal-value:</a></b> <button id='x969' onclick='hideorshow("x969","x970")'>show</button></p> <blockquote id='x970' style='display:none;'> <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#raise-function">raise-function:</a></b> <button id='x971' onclick='hideorshow("x971","x972")'>show</button></p> <blockquote id='x972' style='display:none;'> <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#type-name">type-name:</a></b> <button id='x973' onclick='hideorshow("x973","x974")'>show</button></p> <blockquote id='x974' style='display:none;'> <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" /> <p><b><a href="syntaxdiagrams.html#signed-number">signed-number:</a></b> <button id='x975' onclick='hideorshow("x975","x976")'>show</button></p> <blockquote id='x976' style='display:none;'> <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" /> </blockquote> </blockquote> </blockquote> <p><b><a href="syntaxdiagrams.html#join-clause">join-clause:</a></b> <button id='x977' onclick='hideorshow("x977","x978")'>show</button></p> <blockquote id='x978' style='display:none;'> <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" /> <p><b><a href="syntaxdiagrams.html#join-constraint">join-constraint:</a></b> <button id='x979' onclick='hideorshow("x979","x980")'>show</button></p> <blockquote id='x980' style='display:none;'> <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#join-operator">join-operator:</a></b> <button id='x981' onclick='hideorshow("x981","x982")'>show</button></p> <blockquote id='x982' style='display:none;'> <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" /> </blockquote> </blockquote> <p><b><a href="syntaxdiagrams.html#ordering-term">ordering-term:</a></b> <button id='x983' onclick='hideorshow("x983","x984")'>show</button></p> <blockquote id='x984' style='display:none;'> <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#result-column">result-column:</a></b> <button id='x985' onclick='hideorshow("x985","x986")'>show</button></p> <blockquote id='x986' style='display:none;'> <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#table-or-subquery">table-or-subquery:</a></b> <button id='x987' onclick='hideorshow("x987","x988")'>show</button></p> <blockquote id='x988' style='display:none;'> <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" /> </blockquote> </blockquote> </blockquote> <p>The CREATE VIEW command assigns a name to a pre-packaged <a href="lang_select.html">SELECT</a> statement. Once the view is created, it can be used in the FROM clause of another <a href="lang_select.html">SELECT</a> in place of a table name. </p> <p>If the "TEMP" or "TEMPORARY" keyword occurs in between "CREATE" and "VIEW" then the view that is created is only visible to the process that opened the database and is automatically deleted when the database is closed.</p> <p> If a <database-name> is specified, then the view is created in the named database. It is an error to specify both a <database-name> and the TEMP keyword on a VIEW, unless the <database-name> is "temp". If no database name is specified, and the TEMP keyword is not present, the VIEW is created in the main database.</p> <p>You cannot <a href="lang_delete.html">DELETE</a>, <a href="lang_insert.html">INSERT</a>, or <a href="lang_update.html">UPDATE</a> a view. Views are read-only in SQLite. However, in many cases you can use an <a href="lang_createtrigger.html#instead_of_trigger">INSTEAD OF trigger</a> on the view to accomplish the same thing. Views are removed with the <a href="lang_dropview.html">DROP VIEW</a> command.</p> |
Changes to Doc/Extra/Core/lang_createvtab.html.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
<html dir="LTR" xmlns="http://www.w3.org/1999/xhtml" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:MSHelp="http://msdn.microsoft.com/mshelp" xmlns:tool="http://www.microsoft.com/tooltip" xmlns:ndoc="urn:ndoc-preprocess"> <head> <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252" /> <title>CREATE VIRTUAL TABLE</title> <link rel="stylesheet" type="text/css" href="../Include/ndoc.css" /> </head> <body> <div id="header"> <table width="100%" id="topTable"> <tr id="headerTableRow1"> <td align="left"> <span id="runningHeaderText">CREATE VIRTUAL TABLE</span> </td> </tr> <tr id="headerTableRow2"> <td align="left"> <span id="nsrTitle">SQLite Language Reference Documentation</span> </td> </tr> <tr id="headerTableRow3" style="display:none"> <td> <a id="seeAlsoSectionLink" href="#seeAlsoToggle" onclick="OpenSection(seeAlsoToggle)">See Also</a> <a id="exampleSectionLink" href="#codeExampleToggle" onclick="OpenSection(codeExampleToggle)">Example</a> </td> </tr> </table> <table width="100%" id="bottomTable" cellspacing="0" cellpadding="0" style="display:none"> <tr> <td> <span onclick="ExpandCollapseAll(toggleAllImage)" style="cursor:default;" onkeypress="ExpandCollapseAll_CheckKey(toggleAllImage)" tabindex="0"> <img ID="toggleAllImage" class="toggleAll" src="collall.gif" /> <label id="collapseAllLabel" for="toggleAllImage" style="display: none;"> Collapse All </label> <label id="expandAllLabel" for="toggleAllImage" style="display: none;"> Expand All </label> </span> </td> </tr> </table> </div> <div id="mainSection"> <div id="mainBody"> <h1 class="heading"> SQL As Understood By SQLite</h1> <h4> CREATE VIRTUAL TABLE</h4> <p> <table cellpadding="10"> <tr> <td align="right" width="1%" nowrap> <i><font color="#ff3434">sql-command</font></i> ::=</td> <td> <b><font color="#2c2cf0">CREATE VIRTUAL TABLE </font></b>[<b><font color="#2c2cf0"></font></b><i><font color="#ff3434">database-name</font></i><b><font color="#2c2cf0"> <big>.</big></font></b>]<b><font color="#2c2cf0"> </font></b><i><font color="#ff3434">table-name</font></i><b><font color="#2c2cf0"> USING </font></b><i><font color="#ff3434">module-name</font></i><b><font color="#2c2cf0"> </font></b>[<b><font color="#2c2cf0"><big>(</big> </font></b> <i><font color="#ff3434">arguments</font></i><b><font color="#2c2cf0"> <big>)</big></font></b>]<b><font color="#2c2cf0"></font></b></td> </tr> </table> </p> <p> 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.</p> <p> In general, you can do anything with a virtual table that can be done with an ordinary table, except that you cannot create triggers on a virtual table. Some virtual table implementations might impose additional restrictions. For example, many virtual tables are read-only.</p> <p> The <module-name> is the name of an object that implements the virtual table. The <module-name> must be registered with the SQLite database connection using <a href="capi3ref.html#sqlite3_create_module">sqlite3_create_module</a> prior to issuing the CREATE VIRTUAL TABLE statement. The module takes zero or more comma-separated arguments. The arguments can be just about any text as long as it has balanced parentheses. The argument syntax is sufficiently general that the arguments can be made to appear as column definitions in a traditional <a href="lang_createtable.html">CREATE TABLE</a> statement. SQLite passes the module arguments directly to the module without any interpretation. It is the responsibility of the module implementation to parse and interpret its own arguments.</p> <p> A virtual table is destroyed using the ordinary <a href="lang_droptable.html">DROP TABLE</a> statement. There is no DROP VIRTUAL TABLE statement.</p> <p> <hr> </p> <div id="footer"> <p> </p> <p> </p> </div> </div> </div> </body> </html> |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html><head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>SQLite Query Language: CREATE VIRTUAL TABLE</title> <style type="text/css"> body { margin: auto; font-family: Verdana, sans-serif; padding: 8px 1%; } a { color: #044a64 } a:visited { color: #734559 } .logo { position:absolute; margin:3px; } .tagline { float:right; text-align:right; font-style:italic; width:300px; margin:12px; margin-top:58px; } .menubar { clear: both; border-radius: 8px; background: #044a64; padding: 0px; margin: 0px; cell-spacing: 0px; } .toolbar { text-align: center; line-height: 1.6em; margin: 0; padding: 0px 8px; } .toolbar a { color: white; text-decoration: none; padding: 6px 12px; } .toolbar a:visited { color: white; } .toolbar a:hover { color: #044a64; background: white; } .content { margin: 5%; } .content dt { font-weight:bold; } .content dd { margin-bottom: 25px; margin-left:20%; } .content ul { padding:0px; padding-left: 15px; margin:0px; } /* Things for "fancyformat" documents start here. */ .fancy img+p {font-style:italic} .fancy .codeblock i { color: darkblue; } .fancy h1,.fancy h2,.fancy h3,.fancy h4 {font-weight:normal;color:#044a64} .fancy h2 { margin-left: 10px } .fancy h3 { margin-left: 20px } .fancy h4 { margin-left: 30px } .fancy th {white-space:nowrap;text-align:left;border-bottom:solid 1px #444} .fancy th, .fancy td {padding: 0.2em 1ex; vertical-align:top} .fancy #toc a { color: darkblue ; text-decoration: none } .fancy .todo { color: #AA3333 ; font-style : italic } .fancy .todo:before { content: 'TODO:' } .fancy p.todo { border: solid #AA3333 1px; padding: 1ex } .fancy img { display:block; } .fancy :link:hover, .fancy :visited:hover { background: wheat } .fancy p,.fancy ul,.fancy ol { margin: 1em 5ex } .fancy li p { margin: 1em 0 } /* End of "fancyformat" specific rules. */ </style> </head> <body> <div><!-- container div to satisfy validator --> <a href="index.html"> <img class="logo" src="images/sqlite370_banner.gif" alt="SQLite Logo" border="0"></a> <div><!-- IE hack to prevent disappearing logo--></div> <div class="tagline">Small. Fast. Reliable.<br>Choose any three.</div> <table width=100% class="menubar"><tr> <td width=100%> <div class="toolbar"> <a href="about.html">About</a> <a href="sitemap.html">Sitemap</a> <a href="docs.html">Documentation</a> <a href="download.html">Download</a> <a href="copyright.html">License</a> <a href="news.html">News</a> <a href="support.html">Support</a> </div> <script> gMsg = "Search SQLite Docs..." function entersearch() { var q = document.getElementById("q"); if( q.value == gMsg ) { q.value = "" } q.style.color = "black" q.style.fontStyle = "normal" } function leavesearch() { var q = document.getElementById("q"); if( q.value == "" ) { q.value = gMsg q.style.color = "#044a64" q.style.fontStyle = "italic" } } function hideorshow(btn,obj){ var x = document.getElementById(obj); var b = document.getElementById(btn); if( x.style.display!='none' ){ x.style.display = 'none'; b.innerHTML='show'; }else{ x.style.display = ''; b.innerHTML='hide'; } return false; } </script> <td> <div style="padding:0 1em 0px 0;white-space:nowrap"> <form name=f method="GET" action="http://www.sqlite.org/search"> <input id=q name=q type=text onfocus="entersearch()" onblur="leavesearch()" style="width:24ex;padding:1px 1ex; border:solid white 1px; font-size:0.9em ; font-style:italic;color:#044a64;" value="Search SQLite Docs..."> <input type=submit value="Go" style="border:solid white 1px;background-color:#044a64;color:white;font-size:0.9em;padding:0 1ex"> </form> </div> </table> <div class=startsearch></div> <h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>CREATE VIRTUAL TABLE</h2><p><b><a href="syntaxdiagrams.html#create-virtual-table-stmt">create-virtual-table-stmt:</a></b> <button id='x989' onclick='hideorshow("x989","x990")'>hide</button></p> <blockquote id='x990'> <img alt="syntax diagram create-virtual-table-stmt" src="images/syntax/create-virtual-table-stmt.gif" /> </blockquote> <p>A <a href="vtab.html">virtual table</a> 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.</p> <p>In general, you can do anything with a <a href="vtab.html">virtual table</a> that can be done with an ordinary table, except that you cannot create indices or triggers on a virtual table. Some virtual table implementations might impose additional restrictions. For example, many virtual tables are read-only.</p> <p>The <module-name> is the name of an object that implements the virtual table. The <module-name> must be registered with the SQLite database connection using <a href="c3ref/create_module.html">sqlite3_create_module()</a> or <a href="c3ref/create_module.html">sqlite3_create_module_v2()</a> prior to issuing the CREATE VIRTUAL TABLE statement. The module takes zero or more comma-separated arguments. The arguments can be just about any text as long as it has balanced parentheses. The argument syntax is sufficiently general that the arguments can be made to appear as <a href="lang_createtable.html#tablecoldef">column definitions</a> in a traditional <a href="lang_createtable.html">CREATE TABLE</a> statement. SQLite passes the module arguments directly to the <a href="vtab.html#xcreate">xCreate</a> and <a href="vtab.html#xconnect">xConnect</a> methods of the module implementation without any interpretation. It is the responsibility of the module implementation to parse and interpret its own arguments.</p> <p>A virtual table is destroyed using the ordinary <a href="lang_droptable.html">DROP TABLE</a> statement. There is no DROP VIRTUAL TABLE statement.</p> |
Name change from Doc/Extra/Core/lang_datetime.html to Doc/Extra/Core/lang_datefunc.html.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 |
<html dir="LTR" xmlns="http://www.w3.org/1999/xhtml" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:MSHelp="http://msdn.microsoft.com/mshelp" xmlns:tool="http://www.microsoft.com/tooltip" xmlns:ndoc="urn:ndoc-preprocess"> <head> <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252" /> <title>DateTime Functions</title> <link rel="stylesheet" type="text/css" href="../Include/ndoc.css" /> </head> <body> <div id="header"> <table width="100%" id="topTable"> <tr id="headerTableRow1"> <td align="left"> <span id="runningHeaderText">Date and Time Functions</span> </td> </tr> <tr id="headerTableRow2"> <td align="left"> <span id="nsrTitle">SQLite Language Reference Documentation</span> </td> </tr> <tr id="headerTableRow3" style="display:none"> <td> <a id="seeAlsoSectionLink" href="#seeAlsoToggle" onclick="OpenSection(seeAlsoToggle)">See Also</a> <a id="exampleSectionLink" href="#codeExampleToggle" onclick="OpenSection(codeExampleToggle)">Example</a> </td> </tr> </table> <table width="100%" id="bottomTable" cellspacing="0" cellpadding="0" style="display:none"> <tr> <td> <span onclick="ExpandCollapseAll(toggleAllImage)" style="cursor:default;" onkeypress="ExpandCollapseAll_CheckKey(toggleAllImage)" tabindex="0"> <img ID="toggleAllImage" class="toggleAll" src="collall.gif" /> <label id="collapseAllLabel" for="toggleAllImage" style="display: none;"> Collapse All </label> <label id="expandAllLabel" for="toggleAllImage" style="display: none;"> Expand All </label> </span> </td> </tr> </table> </div> <div id="mainSection"> <div id="mainBody"> <h1 class="heading">Date and Time Functions</h1> <p>Five date and time functions are available, as follows: <p><ol> <li>date( <i>timestring</i>, <i>modifier</i>, <i>modifier</i>, ...) <li>time( <i>timestring</i>, <i>modifier</i>, <i>modifier</i>, ...) <li>datetime( <i>timestring</i>, <i>modifier</i>, <i>modifier</i>, ...) <li>julianday( <i>timestring</i>, <i>modifier</i>, <i>modifier</i>, ...) <li>strftime( <i>format</i>, <i>timestring</i>, <i>modifier</i>, <i>modifier</i>, ...) </ol> <p>All five functions take a time string as an argument. This time string may be followed by zero or more modifiers. The <b>strftime()</b> function also takes a format string as its first argument. <p>The <b>date()</b> function returns the date in this format: YYYY-MM-DD. The <b>time()</b> function returns the time as HH:MM:SS. The <b>datetime()</b> function returns "YYYY-MM-DD HH:MM:SS". The <b>julianday()</b> function returns the number of days since noon in Greenwich on November 24, 4714 B.C. The julian day number is the preferred internal representation of dates. The <b>strftime()</b> routine returns the date formatted according to the format string specified as the first argument. The format string supports most, but not all, of the more common substitutions found in the strftime() function from the standard C library: <p><pre> %d day of month %f ** fractional seconds SS.SSS %H hour 00-24 %j day of year 001-366 %J ** Julian day number %m month 01-12 %M minute 00-59 %s seconds since 1970-01-01 %S seconds 00-59 %w day of week 0-6 sunday==0 %W week of year 00-53 %Y year 0000-9999 %% % </pre> <p>The %f and %J conversions are new. Notice that all of the other four functions could be expressed in terms of <b>strftime()</b>. <p><pre> date(...) -> strftime("%Y-%m-%d", ...) time(...) -> strftime("%H:%M:%S", ...) datetime(...) -> strftime("%Y-%m-%d %H:%M:%S", ...) julianday(...) -> strftime("%J", ...) </pre> <p>The only reasons for providing functions other than <b>strftime()</b> is for convenience and for efficiency. <p><b>Time Strings</b> <p>A time string can be in any of the following formats: <p><ol> <li>YYYY-MM-DD <li>YYYY-MM-DD HH:MM <li>YYYY-MM-DD HH:MM:SS <li>YYYY-MM-DD HH:MM:SS.SSS <li>YYYY-MM-DDTHH:MM <li>YYYY-MM-DDTHH:MM:SS <li>YYYY-MM-DDTHH:MM:SS.SSS <li>HH:MM <li>HH:MM:SS <li>HH:MM:SS.SSS <li>now <li>DDDD.DDDD </ol> <p>In formats 5 through 7, the "T" is a literal character separating the date and the time, as required by the ISO-8601 standard. These formats are supported in SQLite 3.2.0 and later. Formats 8 through 10 that specify only a time assume a date of 2000-01-01. Format 11, the string 'now', is converted into the current date and time. Universal Coordinated Time (UTC) is used. Format 12 is the julian day number expressed as a floating point value. <p><b>Modifiers</b> <p>The time string can be followed by zero or more modifiers that alter the date or alter the interpretation of the date. The available modifiers are as follows. <p><ol> <li>NNN days <li>NNN hours <li>NNN minutes <li>NNN.NNNN seconds <li>NNN months (see <a href="tktview?tn=551">#551</a> and <a href="chngview?cn=1163">[1163]</a> ) <li>NNN years (see <a href="tktview?tn=551">#551</a> and <a href="chngview?cn=1163">[1163]</a> ) <li>start of month <li>start of year <li>start of week (withdrawn -- will not be implemented) <li>start of day <li>weekday N (see <a href="tktview?tn=551">#551</a> and <a href="chngview?cn=1163">[1163]</a> ) <li>unixepoch <li>localtime <li>utc </ol> <p>The first six modifiers (1 through 6) simply add the specified amount of time to the date specified by the preceding timestring. <p>The "start of" modifiers (7 through 10) shift the date backwards to the beginning of the current month, year or day. <p>The "weekday" modifier advances the date forward to the next date where the weekday number is N. Sunday is 0, Monday is 1, and so forth. <p>The "unixepoch" modifier (12) only works if it immediately follows a timestring in the DDDDDDDDDD format. This modifier causes the DDDDDDDDDD to be interpreted not as a julian day number as it normally would be, but as the number of seconds since 1970. This modifier allows unix-based times to be converted to julian day numbers easily. <p>The "localtime" modifier (13) adjusts the previous time string so that it displays the correct local time. "utc" undoes this. <p><b>Examples</b> <p>Compute the current date. <p><pre> SELECT date('now'); </pre> <p>Compute the last day of the current month. <p><pre> SELECT date('now','start of month','+1 month','-1 day'); </pre> <p>Compute the date and time given a unix timestamp 1092941466. <p><pre> SELECT datetime(1092941466, 'unixepoch'); </pre> <p>Compute the date and time given a unix timestamp 1092941466, and compensate for your local timezone. <p><pre> SELECT datetime(1092941466, 'unixepoch', 'localtime'); </pre> <p>Compute the current unix timestamp. <p><pre> SELECT strftime('%s','now'); </pre> <p>Compute the number of days since the battle of Hastings. <p><pre> SELECT julianday('now') - julianday('1066-10-14','gregorian'); </pre> <p>Compute the number of seconds between two dates: <p><pre> SELECT julianday('now')*86400 - julianday('2004-01-01 02:34:56')*86400; </pre> <p>Compute the date of the first Tuesday in October (January + 9) for the current year. <p><pre> SELECT date('now','start of year','+9 months','weekday 2'); </pre> <p><b>Caveats And Bugs</b> <p>The computation of local time depends heavily on the whim of local politicians and is thus difficult to get correct for all locales. In this implementation, the standard C library function localtime() is used to assist in the calculation of local time. Note that localtime() is not threadsafe, so use of the "localtime" modifier is not threadsafe. Also, the localtime() C function normally only works for years between 1970 and 2037. For dates outside this range, SQLite attempts to map the year into an equivalent year within this range, do the calculation, then map the year back. <p><i>Please surround uses of localtime() with sqliteOsEnterMutex() and sqliteOsLeaveMutex() so threads using SQLite are protected, at least! -- e</i> It is so. --drh <p><i>[Consider instead, using localtime_r which is reentrant and may be used *without* expensive mutex locking. Although non-standard it's available on most Unixes --hauk]</i> But it is not available on windows, as far as I am aware. --drh On windows localtime() is thread-safe if the MT C runtime is used. The MT runtime uses thread-local storage for the static variables, the kind functions use.--gr <i>[What about using localtime_r, and on systems where it is unavailable defining it as sqliteOsEnterMutext() ; locatime() ; sqliteOsLeaveMutex() so that non-windows systems get the maximum advantage, with almost zero code impact?]</i> The autoconfigury and patch for localtime_r is here: <font color="#a0a0a0">¤</font><a href="http://www.sqlite.org/cvstrac/tktview?tn=1906">http://www.sqlite.org/cvstrac/tktview?tn=1906</a> . I'm curious why this obvious fix is not applied. gmtime() also suffers from this same threadsafety problem. <p>Date computations do not give correct results for dates before Julian day number 0 (-4713-11-24 12:00:00). <p>All internal computations assume the Gregorian calendar system. <p><hr> <i>An anonymous user adds:</i> <br> For my use I added new functions and functionalities to the date functions that come with the sqlite 3.3.0 (can be used in older versions as well with small effort). <p>In main lines they are as follows: <p><ol> <li>NNN days <li>NNN hours <li>NNN minutes <li>NNN.NNNN seconds <li>NNN months (see <a href="tktview?tn=551">#551</a> and <a href="chngview?cn=1163">[1163]</a> ) <li>NNN years (see <a href="tktview?tn=551">#551</a> and <a href="chngview?cn=1163">[1163]</a> ) <li>start of month <li>start of year <li>start of week (!!! implemented) <li>start of day <li>weekday N (see <a href="tktview?tn=551">#551</a> and <a href="chngview?cn=1163">[1163]</a> ) <li>unixepoch <li>localtime <li>utc <li>julian (not implemented as of 2004-01-05) <li>gregorian (not implemented as of 2004-01-05) <li>start of minute <li>start of hour <li>end of minute <li>end of hour <li>end of day <li>end of week <li>end of month <li>end of year <li>group seconds by <li>group minutes by <li>group hours by <li>group days by <li>group weeks by <li>group months by <li>group years by </ol> <p>The "start of" modifiers (7 through 10 and 17 through 18) shift the date backwards to the beginning of the current minute, hour, week, month, year or day. <p>The "end of" modifiers (19 through 24) shift the date forwards to the end of the current minute, hour, week, month, year or day. <p>The "group * by" modifiers (25 through 31) round the date to the closest backward multiple supplied, with some limitations, to the current seconds (1 through 30), minutes (1 through 30), hours (1 through 12), days (1 through 15), weeks (1 through 26), months (1 through 6), years (1 through 100), these limitations are due to dont complicate the calculations when a multiple can span beyound the unit modified. <p>Ex: <p>SELECT datetime('2006-02-04 20:09:23','group hours by 3'); => '2006-02-04 18:00:00' <p>SELECT datetime('2006-02-05 20:09:23','group days by 3'); => '2006-02-04 00:00:00' <p>New functions "week_number(date)" returns the week number of the year on the supplied date parameter, "datetime2seconds(datetime)" return the number of seconds from the supplied datetime parameter. <hr> <div id="footer"> <p> </p> <p> </p> </div> </div> </div> </body> </html> |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html><head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>SQLite Query Language: Date And Time Functions</title> <style type="text/css"> body { margin: auto; font-family: Verdana, sans-serif; padding: 8px 1%; } a { color: #044a64 } a:visited { color: #734559 } .logo { position:absolute; margin:3px; } .tagline { float:right; text-align:right; font-style:italic; width:300px; margin:12px; margin-top:58px; } .menubar { clear: both; border-radius: 8px; background: #044a64; padding: 0px; margin: 0px; cell-spacing: 0px; } .toolbar { text-align: center; line-height: 1.6em; margin: 0; padding: 0px 8px; } .toolbar a { color: white; text-decoration: none; padding: 6px 12px; } .toolbar a:visited { color: white; } .toolbar a:hover { color: #044a64; background: white; } .content { margin: 5%; } .content dt { font-weight:bold; } .content dd { margin-bottom: 25px; margin-left:20%; } .content ul { padding:0px; padding-left: 15px; margin:0px; } /* Things for "fancyformat" documents start here. */ .fancy img+p {font-style:italic} .fancy .codeblock i { color: darkblue; } .fancy h1,.fancy h2,.fancy h3,.fancy h4 {font-weight:normal;color:#044a64} .fancy h2 { margin-left: 10px } .fancy h3 { margin-left: 20px } .fancy h4 { margin-left: 30px } .fancy th {white-space:nowrap;text-align:left;border-bottom:solid 1px #444} .fancy th, .fancy td {padding: 0.2em 1ex; vertical-align:top} .fancy #toc a { color: darkblue ; text-decoration: none } .fancy .todo { color: #AA3333 ; font-style : italic } .fancy .todo:before { content: 'TODO:' } .fancy p.todo { border: solid #AA3333 1px; padding: 1ex } .fancy img { display:block; } .fancy :link:hover, .fancy :visited:hover { background: wheat } .fancy p,.fancy ul,.fancy ol { margin: 1em 5ex } .fancy li p { margin: 1em 0 } /* End of "fancyformat" specific rules. */ </style> </head> <body> <div><!-- container div to satisfy validator --> <a href="index.html"> <img class="logo" src="images/sqlite370_banner.gif" alt="SQLite Logo" border="0"></a> <div><!-- IE hack to prevent disappearing logo--></div> <div class="tagline">Small. Fast. Reliable.<br>Choose any three.</div> <table width=100% class="menubar"><tr> <td width=100%> <div class="toolbar"> <a href="about.html">About</a> <a href="sitemap.html">Sitemap</a> <a href="docs.html">Documentation</a> <a href="download.html">Download</a> <a href="copyright.html">License</a> <a href="news.html">News</a> <a href="support.html">Support</a> </div> <script> gMsg = "Search SQLite Docs..." function entersearch() { var q = document.getElementById("q"); if( q.value == gMsg ) { q.value = "" } q.style.color = "black" q.style.fontStyle = "normal" } function leavesearch() { var q = document.getElementById("q"); if( q.value == "" ) { q.value = gMsg q.style.color = "#044a64" q.style.fontStyle = "italic" } } function hideorshow(btn,obj){ var x = document.getElementById(obj); var b = document.getElementById(btn); if( x.style.display!='none' ){ x.style.display = 'none'; b.innerHTML='show'; }else{ x.style.display = ''; b.innerHTML='hide'; } return false; } </script> <td> <div style="padding:0 1em 0px 0;white-space:nowrap"> <form name=f method="GET" action="http://www.sqlite.org/search"> <input id=q name=q type=text onfocus="entersearch()" onblur="leavesearch()" style="width:24ex;padding:1px 1ex; border:solid white 1px; font-size:0.9em ; font-style:italic;color:#044a64;" value="Search SQLite Docs..."> <input type=submit value="Go" style="border:solid white 1px;background-color:#044a64;color:white;font-size:0.9em;padding:0 1ex"> </form> </div> </table> <div class=startsearch></div> <h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>Date And Time Functions</h2> <p> SQLite supports five date and time functions as follows: </p> <p> <ol> <li> <b>date(</b><i>timestring, modifier, modifier, ...</i><b>)</b> </li> <li> <b>time(</b><i>timestring, modifier, modifier, ...</i><b>)</b> </li> <li> <b>datetime(</b><i>timestring, modifier, modifier, ...</i><b>)</b> </li> <li> <b>julianday(</b><i>timestring, modifier, modifier, ...</i><b>)</b> </li> <li> <b>strftime(</b><i>format, timestring, modifier, modifier, ...</i><b>)</b> </li> </ol> <p> All five date and time functions take a time string as an argument. The time string is followed by zero or more modifiers. The strftime() function also takes a format string as its first argument. </p> <p> The date and time functions use a subset of <a href="http://en.wikipedia.org/wiki/ISO_8601">IS0-8601</a> date and time formats. The date() function returns the date in this format: YYYY-MM-DD. The time() function returns the time as HH:MM:SS. The datetime() function returns "YYYY-MM-DD HH:MM:SS". The julianday() function returns the <a href="http://en.wikipedia.org/wiki/Julian_day">Julian day</a> - the number of days since noon in Greenwich on November 24, 4714 B.C. (<a href="http://en.wikipedia.org/wiki/Proleptic_Gregorian_calendar">Proleptic Gregorian calendar</a>). The strftime() routine returns the date formatted according to the format string specified as the first argument. The format string supports the most common substitutions found in the <a href="http://opengroup.org/onlinepubs/007908799/xsh/strftime.html">strftime() function</a> from the standard C library plus two new substitutions, %f and %J. The following is a complete list of valid strftime() substitutions: </p> <blockquote> <table border="0" cellpadding="0" cellspacing="0"> <tr><td><td width="10"><td></tr> <tr><td> %d <td><td> day of month: 00 <tr><td> %f <td><td> fractional seconds: SS.SSS <tr><td> %H <td><td> hour: 00-24 <tr><td> %j <td><td> day of year: 001-366 <tr><td> %J <td><td> Julian day number <tr><td> %m <td><td> month: 01-12 <tr><td> %M <td><td> minute: 00-59 <tr><td> %s <td><td> seconds since 1970-01-01 <tr><td> %S <td><td> seconds: 00-59 <tr><td> %w <td><td> day of week 0-6 with Sunday==0 <tr><td> %W <td><td> week of year: 00-53 <tr><td> %Y <td><td> year: 0000-9999 <tr><td> %% <td><td> % </table> </blockquote> <p> Notice that all other date and time functions can be expressed in terms of strftime(): </p> <blockquote> <table border="0" cellpadding="0" cellspacing="0"> <tr><td><b>Function</b><td width="30"><td><b>Equivalent strftime()</b> <tr><td> date(...) <td><td> strftime('%Y-%m-%d', ...) <tr><td> time(...) <td><td> strftime('%H:%M:%S', ...) <tr><td> datetime(...) <td><td> strftime('%Y-%m-%d %H:%M:%S', ...) <tr><td> julianday(...) <td><td> strftime('%J', ...) </table> </blockquote> <p> The only reasons for providing functions other than strftime() is for convenience and for efficiency. </p> <h3>Time Strings</h3> <p>A time string can be in any of the following formats:</p> <ol> <li> <i>YYYY-MM-DD</i> <li> <i>YYYY-MM-DD HH:MM</i> <li> <i>YYYY-MM-DD HH:MM:SS</i> <li> <i>YYYY-MM-DD HH:MM:SS.SSS</i> <li> <i>YYYY-MM-DD</i><b>T</b><i>HH:MM</i> <li> <i>YYYY-MM-DD</i><b>T</b><i>HH:MM:SS</i> <li> <i>YYYY-MM-DD</i><b>T</b><i>HH:MM:SS.SSS</i> <li> <i>HH:MM</i> <li> <i>HH:MM:SS</i> <li> <i>HH:MM:SS.SSS</i> <li> <b>now</b> <li> <i>DDDDDDDDDD</i> </ol> <p> In formats 5 through 7, the "T" is a literal character separating the date and the time, as required by <a href="http://www.w3c.org/TR/NOTE-datetime">ISO-8601</a>. Formats 8 through 10 that specify only a time assume a date of 2000-01-01. Format 11, the string 'now', is converted into the current date and time as obtained from the xCurrentTime method of the <a href="c3ref/vfs.html">sqlite3_vfs</a> object in use. The 'now' argument to date and time functions always returns exactly the same value for multiple invocations within the same <a href="c3ref/step.html">sqlite3_step()</a> call. <a href="http://en.wikipedia.org/wiki/Coordinated_Universal_Time">Universal Coordinated Time (UTC)</a> is used. Format 12 is the <a href="http://en.wikipedia.org/wiki/Julian_day">Julian day number</a> expressed as a floating point value. </p> <p> Formats 2 through 10 may be optionally followed by a timezone indicator of the form "<i>[+-]HH:MM</i>" or just "<i>Z</i>". The date and time functions use UTC or "zulu" time internally, and so the "Z" suffix is a no-op. Any non-zero "HH:MM" suffix is subtracted from the indicated date and time in order to compute zulu time. For example, all of the following time strings are equivalent: </p> <blockquote> 2013-10-07 08:23:19.120<br> 2013-10-07T08:23:19.120Z<br> 2013-10-07 08:23:19.120-04:00<br> 2456572.84952685 </blockquote> <p> In formats 4, 7, and 10, the fractional seconds value SS.SSS can have one or more digits following the decimal point. Exactly three digits are shown in the examples because only the first three digits are significant to the result, but the input string can have fewer or more than three digits and the date/time functions will still operate correctly. Similarly, format 12 is shown with 10 significant digits, but the date/time functions will really accept as many or as few digits as are necessary to represent the Julian day number. </p> <h3>Modifiers</h3> <p>The time string can be followed by zero or more modifiers that alter date and/or time. Each modifier is a transformation that is applied to the time value to its left. Modifiers are applied from left to right; order is important. The available modifiers are as follows.</p> <ol> <li> NNN days <li> NNN hours <li> NNN minutes <li> NNN.NNNN seconds <li> NNN months <li> NNN years <li> start of month <li> start of year <li> start of day <li> weekday N <li> unixepoch <li> localtime <li> utc </ol> <p>The first six modifiers (1 through 6) simply add the specified amount of time to the date and time specified by the preceding timestring and modifiers. Note that "±NNN months" works by rendering the original date into the YYYY-MM-DD format, adding the ±NNN to the MM month value, then normalizing the result. Thus, for example, the data 2001-03-31 modified by '+1 month' initially yields 2001-04-31, but April only has 30 days so the date is normalized to 2001-05-01. A similar effect occurs when the original date is February 29 of a leapyear and the modifier is ±N years where N is not a multiple of four.</p> <p>The "start of" modifiers (7 through 9) shift the date backwards to the beginning of the current month, year or day.</p> <p>The "weekday" modifier advances the date forward to the next date where the weekday number is N. Sunday is 0, Monday is 1, and so forth.</p> <p>The "unixepoch" modifier (11) only works if it immediately follows a timestring in the DDDDDDDDDD format. This modifier causes the DDDDDDDDDD to be interpreted not as a Julian day number as it normally would be, but as <a href="http://en.wikipedia.org/wiki/Unix_time">Unix Time</a> - the number of seconds since 1970. If the "unixepoch" modifier does not follow a timestring of the form DDDDDDDDDD which expresses the number of seconds since 1970 or if other modifiers separate the "unixepoch" modifier from prior DDDDDDDDDD then the behavior is undefined. Due to precision limitations imposed by the implementations use of 64-bit integers, the "unixepoch" modifier only works for dates between 0000-01-01 00:00:00 and 5352-11-01 10:52:47 (unix times of -62167219200 through 10675199167).</p> <p>The "localtime" modifier (12) assumes the time string to its left is in Universal Coordinated Time (UTC) and adjusts the time string so that it displays localtime. If "localtime" follows a time that is not UTC, then the behavior is undefined. The "utc" is the opposite of "localtime". "utc" assumes that the string to its left is in the local timezone and adjusts that string to be in UTC. If the prior string is not in localtime, then the result of "utc" is undefined.</p> <h3>Examples</h3> <p>Compute the current date.<p> <blockquote>SELECT date('now');</blockquote> <p>Compute the last day of the current month.</p> <blockquote>SELECT date('now','start of month','+1 month','-1 day'); </blockquote> <p>Compute the date and time given a unix timestamp 1092941466.</p> <blockquote> SELECT datetime(1092941466, 'unixepoch'); </blockquote> <p>Compute the date and time given a unix timestamp 1092941466, and compensate for your local timezone.</p> <blockquote> SELECT datetime(1092941466, 'unixepoch', 'localtime'); </blockquote> <p>Compute the current unix timestamp.</p> <blockquote> SELECT strftime('%s','now'); </blockquote> <p>Compute the number of days since the signing of the US Declaration of Independence.</p> <blockquote> SELECT julianday('now') - julianday('1776-07-04'); </blockquote> <p>Compute the number of seconds since a particular moment in 2004:</p> <blockquote> SELECT strftime('%s','now') - strftime('%s','2004-01-01 02:34:56'); </blockquote> <p> Compute the date of the first Tuesday in October for the current year. </p> <blockquote> SELECT date('now','start of year','+9 months','weekday 2'); </blockquote> <p>Compute the time since the unix epoch in seconds (like strftime('%s','now') except includes fractional part):</p> <blockquote> SELECT (julianday('now') - 2440587.5)*86400.0; </blockquote> <h3>Caveats And Bugs</h3> <p>The computation of local time depends heavily on the whim of politicians and is thus difficult to get correct for all locales. In this implementation, the standard C library function localtime_r() is used to assist in the calculation of local time. The localtime_r() C function normally only works for years between 1970 and 2037. For dates outside this range, SQLite attempts to map the year into an equivalent year within this range, do the calculation, then map the year back.</p> <p>These functions only work for dates between 0000-01-01 00:00:00 and 9999-12-31 23:59:59 (julidan day numbers 1721059.5 through 5373484.5). For dates outside that range, the results of these functions are undefined.</p> <p>Non-Vista Windows platforms only support one set of DST rules. Vista only supports two. Therefore, on these platforms, historical DST calculations will be incorrect. For example, in the US, in 2007 the DST rules changed. Non-Vista Windows platforms apply the new 2007 DST rules to all previous years as well. Vista does somewhat better getting results correct back to 1986, when the rules were also changed.</p> <p>All internal computations assume the <a href="http://en.wikipedia.org/wiki/Gregorian_calendar">Gregorian calendar</a> system. It is also assumed that every day is exactly 86400 seconds in duration.</p> |
Changes to Doc/Extra/Core/lang_delete.html.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
<html dir="LTR" xmlns="http://www.w3.org/1999/xhtml" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:MSHelp="http://msdn.microsoft.com/mshelp" xmlns:tool="http://www.microsoft.com/tooltip" xmlns:ndoc="urn:ndoc-preprocess"> <head> <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252" /> <title>DELETE</title> <link rel="stylesheet" type="text/css" href="../Include/ndoc.css" /> </head> <body> <div id="header"> <table width="100%" id="topTable"> <tr id="headerTableRow1"> <td align="left"> <span id="runningHeaderText">DELETE</span> </td> </tr> <tr id="headerTableRow2"> <td align="left"> <span id="nsrTitle">SQLite Language Reference Documentation</span> </td> </tr> <tr id="headerTableRow3" style="display:none"> <td> <a id="seeAlsoSectionLink" href="#seeAlsoToggle" onclick="OpenSection(seeAlsoToggle)">See Also</a> <a id="exampleSectionLink" href="#codeExampleToggle" onclick="OpenSection(codeExampleToggle)">Example</a> </td> </tr> </table> <table width="100%" id="bottomTable" cellspacing="0" cellpadding="0" style="display:none"> <tr> <td> <span onclick="ExpandCollapseAll(toggleAllImage)" style="cursor:default;" onkeypress="ExpandCollapseAll_CheckKey(toggleAllImage)" tabindex="0"> <img ID="toggleAllImage" class="toggleAll" src="collall.gif" /> <label id="collapseAllLabel" for="toggleAllImage" style="display: none;"> Collapse All </label> <label id="expandAllLabel" for="toggleAllImage" style="display: none;"> Expand All </label> </span> </td> </tr> </table> </div> <div id="mainSection"> <div id="mainBody"> <h1 class="heading"> SQL As Understood By SQLite</h1> <h4> DELETE</h4> <p> <table cellpadding="10"> <tr> <td align="right" width="1%" nowrap> <i><font color="#ff3434">sql-statement</font></i> ::=</td> <td> <b><font color="#2c2cf0">DELETE FROM </font></b>[<b><font color="#2c2cf0"></font></b><i><font color="#ff3434">database-name</font></i><b><font color="#2c2cf0"> <big>.</big></font></b>]<b><font color="#2c2cf0"> </font></b><i><font color="#ff3434">table-name</font></i><b><font color="#2c2cf0"> </font></b>[<b><font color="#2c2cf0">WHERE </font></b><i><font color="#ff3434"> expr</font></i><b><font color="#2c2cf0"></font></b>]<b><font color="#2c2cf0"></font></b></td> </tr> </table> </p> <p> The DELETE command is used to remove records from a table. The command consists of the "DELETE FROM" keywords followed by the name of the table from which records are to be removed. </p> <p> Without a WHERE clause, all rows of the table are removed. If a WHERE clause is supplied, then only those rows that match the expression are removed.</p> <p> <hr> </p> <div id="footer"> <p> </p> <p> </p> </div> </div> </div> </body> </html> |
| | | | | < | > | | < < > > | | < > | | | | | | | | < < > > | | | | | | | < > | | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | < < < > > > > > > > > > > > > > > > > > > > > > | < < < < < < < < < < < > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | < < < < < > > > > > > | | < < < < < < < < < > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | < < < < < < < > > > > > > > > > > > > > > > > > > > > > > > > > | < < < < < > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html><head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>SQLite Query Language: DELETE</title> <style type="text/css"> body { margin: auto; font-family: Verdana, sans-serif; padding: 8px 1%; } a { color: #044a64 } a:visited { color: #734559 } .logo { position:absolute; margin:3px; } .tagline { float:right; text-align:right; font-style:italic; width:300px; margin:12px; margin-top:58px; } .menubar { clear: both; border-radius: 8px; background: #044a64; padding: 0px; margin: 0px; cell-spacing: 0px; } .toolbar { text-align: center; line-height: 1.6em; margin: 0; padding: 0px 8px; } .toolbar a { color: white; text-decoration: none; padding: 6px 12px; } .toolbar a:visited { color: white; } .toolbar a:hover { color: #044a64; background: white; } .content { margin: 5%; } .content dt { font-weight:bold; } .content dd { margin-bottom: 25px; margin-left:20%; } .content ul { padding:0px; padding-left: 15px; margin:0px; } /* Things for "fancyformat" documents start here. */ .fancy img+p {font-style:italic} .fancy .codeblock i { color: darkblue; } .fancy h1,.fancy h2,.fancy h3,.fancy h4 {font-weight:normal;color:#044a64} .fancy h2 { margin-left: 10px } .fancy h3 { margin-left: 20px } .fancy h4 { margin-left: 30px } .fancy th {white-space:nowrap;text-align:left;border-bottom:solid 1px #444} .fancy th, .fancy td {padding: 0.2em 1ex; vertical-align:top} .fancy #toc a { color: darkblue ; text-decoration: none } .fancy .todo { color: #AA3333 ; font-style : italic } .fancy .todo:before { content: 'TODO:' } .fancy p.todo { border: solid #AA3333 1px; padding: 1ex } .fancy img { display:block; } .fancy :link:hover, .fancy :visited:hover { background: wheat } .fancy p,.fancy ul,.fancy ol { margin: 1em 5ex } .fancy li p { margin: 1em 0 } /* End of "fancyformat" specific rules. */ </style> </head> <body> <div><!-- container div to satisfy validator --> <a href="index.html"> <img class="logo" src="images/sqlite370_banner.gif" alt="SQLite Logo" border="0"></a> <div><!-- IE hack to prevent disappearing logo--></div> <div class="tagline">Small. Fast. Reliable.<br>Choose any three.</div> <table width=100% class="menubar"><tr> <td width=100%> <div class="toolbar"> <a href="about.html">About</a> <a href="sitemap.html">Sitemap</a> <a href="docs.html">Documentation</a> <a href="download.html">Download</a> <a href="copyright.html">License</a> <a href="news.html">News</a> <a href="support.html">Support</a> </div> <script> gMsg = "Search SQLite Docs..." function entersearch() { var q = document.getElementById("q"); if( q.value == gMsg ) { q.value = "" } q.style.color = "black" q.style.fontStyle = "normal" } function leavesearch() { var q = document.getElementById("q"); if( q.value == "" ) { q.value = gMsg q.style.color = "#044a64" q.style.fontStyle = "italic" } } function hideorshow(btn,obj){ var x = document.getElementById(obj); var b = document.getElementById(btn); if( x.style.display!='none' ){ x.style.display = 'none'; b.innerHTML='show'; }else{ x.style.display = ''; b.innerHTML='hide'; } return false; } </script> <td> <div style="padding:0 1em 0px 0;white-space:nowrap"> <form name=f method="GET" action="http://www.sqlite.org/search"> <input id=q name=q type=text onfocus="entersearch()" onblur="leavesearch()" style="width:24ex;padding:1px 1ex; border:solid white 1px; font-size:0.9em ; font-style:italic;color:#044a64;" value="Search SQLite Docs..."> <input type=submit value="Go" style="border:solid white 1px;background-color:#044a64;color:white;font-size:0.9em;padding:0 1ex"> </form> </div> </table> <div class=startsearch></div> <h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>DELETE</h2><p><b><a href="syntaxdiagrams.html#delete-stmt">delete-stmt:</a></b> <button id='x991' onclick='hideorshow("x991","x992")'>hide</button></p> <blockquote id='x992'> <img alt="syntax diagram delete-stmt" src="images/syntax/delete-stmt.gif" /> <p><b><a href="syntaxdiagrams.html#expr">expr:</a></b> <button id='x993' onclick='hideorshow("x993","x994")'>show</button></p> <blockquote id='x994' style='display:none;'> <img alt="syntax diagram expr" src="images/syntax/expr.gif" /> <p><b><a href="syntaxdiagrams.html#literal-value">literal-value:</a></b> <button id='x995' onclick='hideorshow("x995","x996")'>show</button></p> <blockquote id='x996' style='display:none;'> <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#raise-function">raise-function:</a></b> <button id='x997' onclick='hideorshow("x997","x998")'>show</button></p> <blockquote id='x998' style='display:none;'> <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#select-stmt">select-stmt:</a></b> <button id='x999' onclick='hideorshow("x999","x1000")'>show</button></p> <blockquote id='x1000' style='display:none;'> <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" /> <p><b><a href="syntaxdiagrams.html#common-table-expression">common-table-expression:</a></b> <button id='x1001' onclick='hideorshow("x1001","x1002")'>show</button></p> <blockquote id='x1002' style='display:none;'> <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#compound-operator">compound-operator:</a></b> <button id='x1003' onclick='hideorshow("x1003","x1004")'>show</button></p> <blockquote id='x1004' style='display:none;'> <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#join-clause">join-clause:</a></b> <button id='x1005' onclick='hideorshow("x1005","x1006")'>show</button></p> <blockquote id='x1006' style='display:none;'> <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" /> <p><b><a href="syntaxdiagrams.html#join-constraint">join-constraint:</a></b> <button id='x1007' onclick='hideorshow("x1007","x1008")'>show</button></p> <blockquote id='x1008' style='display:none;'> <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#join-operator">join-operator:</a></b> <button id='x1009' onclick='hideorshow("x1009","x1010")'>show</button></p> <blockquote id='x1010' style='display:none;'> <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" /> </blockquote> </blockquote> <p><b><a href="syntaxdiagrams.html#ordering-term">ordering-term:</a></b> <button id='x1011' onclick='hideorshow("x1011","x1012")'>show</button></p> <blockquote id='x1012' style='display:none;'> <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#result-column">result-column:</a></b> <button id='x1013' onclick='hideorshow("x1013","x1014")'>show</button></p> <blockquote id='x1014' style='display:none;'> <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#table-or-subquery">table-or-subquery:</a></b> <button id='x1015' onclick='hideorshow("x1015","x1016")'>show</button></p> <blockquote id='x1016' style='display:none;'> <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" /> </blockquote> </blockquote> <p><b><a href="syntaxdiagrams.html#type-name">type-name:</a></b> <button id='x1017' onclick='hideorshow("x1017","x1018")'>show</button></p> <blockquote id='x1018' style='display:none;'> <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" /> <p><b><a href="syntaxdiagrams.html#signed-number">signed-number:</a></b> <button id='x1019' onclick='hideorshow("x1019","x1020")'>show</button></p> <blockquote id='x1020' style='display:none;'> <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" /> </blockquote> </blockquote> </blockquote> <p><b><a href="syntaxdiagrams.html#qualified-table-name">qualified-table-name:</a></b> <button id='x1021' onclick='hideorshow("x1021","x1022")'>show</button></p> <blockquote id='x1022' style='display:none;'> <img alt="syntax diagram qualified-table-name" src="images/syntax/qualified-table-name.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#with-clause">with-clause:</a></b> <button id='x1023' onclick='hideorshow("x1023","x1024")'>show</button></p> <blockquote id='x1024' style='display:none;'> <img alt="syntax diagram with-clause" src="images/syntax/with-clause.gif" /> <p><b><a href="syntaxdiagrams.html#cte-table-name">cte-table-name:</a></b> <button id='x1025' onclick='hideorshow("x1025","x1026")'>show</button></p> <blockquote id='x1026' style='display:none;'> <img alt="syntax diagram cte-table-name" src="images/syntax/cte-table-name.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#select-stmt">select-stmt:</a></b> <button id='x1027' onclick='hideorshow("x1027","x1028")'>show</button></p> <blockquote id='x1028' style='display:none;'> <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" /> <p><b><a href="syntaxdiagrams.html#common-table-expression">common-table-expression:</a></b> <button id='x1029' onclick='hideorshow("x1029","x1030")'>show</button></p> <blockquote id='x1030' style='display:none;'> <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#compound-operator">compound-operator:</a></b> <button id='x1031' onclick='hideorshow("x1031","x1032")'>show</button></p> <blockquote id='x1032' style='display:none;'> <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#join-clause">join-clause:</a></b> <button id='x1033' onclick='hideorshow("x1033","x1034")'>show</button></p> <blockquote id='x1034' style='display:none;'> <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" /> <p><b><a href="syntaxdiagrams.html#join-constraint">join-constraint:</a></b> <button id='x1035' onclick='hideorshow("x1035","x1036")'>show</button></p> <blockquote id='x1036' style='display:none;'> <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#join-operator">join-operator:</a></b> <button id='x1037' onclick='hideorshow("x1037","x1038")'>show</button></p> <blockquote id='x1038' style='display:none;'> <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" /> </blockquote> </blockquote> <p><b><a href="syntaxdiagrams.html#ordering-term">ordering-term:</a></b> <button id='x1039' onclick='hideorshow("x1039","x1040")'>show</button></p> <blockquote id='x1040' style='display:none;'> <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#result-column">result-column:</a></b> <button id='x1041' onclick='hideorshow("x1041","x1042")'>show</button></p> <blockquote id='x1042' style='display:none;'> <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#table-or-subquery">table-or-subquery:</a></b> <button id='x1043' onclick='hideorshow("x1043","x1044")'>show</button></p> <blockquote id='x1044' style='display:none;'> <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" /> </blockquote> </blockquote> </blockquote> </blockquote> <p>The DELETE command removes records from the table identified by the <i>qualified-table-name</i>. <p>If the WHERE clause is not present, all records in the table are deleted. If a WHERE clause is supplied, then only those rows for which the result of evaluating the WHERE clause as a <a href="lang_expr.html#booleanexpr">boolean expression is true</a> are deleted. <h3>Restrictions on DELETE Statements Within CREATE TRIGGER</h3> <p>The following restrictions apply to DELETE statements that occur within the body of a <a href="lang_createtrigger.html">CREATE TRIGGER</a> statement: <ul> <li><p>The <i>table-name</i> specified as part of a DELETE statement within a trigger body must be unqualified. In other words, the <i>database-name</i><b>.</b> prefix on the table name is not allowed within triggers. If the table to which the trigger is attached is not in the temp database, then DELETE statements within the trigger body must operate on tables within the same database as it. If the table to which the trigger is attached is in the TEMP database, then the unqualified name of the table being deleted is resolved in the same way as it is for a top-level statement (by searching first the TEMP database, then the main database, then any other databases in the order they were attached). <li><p>The INDEXED BY and NOT INDEXED clauses are not allowed on DELETE statements within triggers.</p> <li><p>The LIMIT and ORDER BY clauses (described below) are unsupported for DELETE statements within triggers.</p> </ul> <h3>Optional LIMIT and ORDER BY clauses</h3> <p>If SQLite is compiled with the <a href="compile.html#enable_update_delete_limit">SQLITE_ENABLE_UPDATE_DELETE_LIMIT</a> compile-time option, then the syntax of the DELETE statement is extended by the addition of optional ORDER BY and LIMIT clauses:</p> <p><b><a href="syntaxdiagrams.html#delete-stmt-limited">delete-stmt-limited:</a></b></p><blockquote> <img alt="syntax diagram delete-stmt-limited" src="images/syntax/delete-stmt-limited.gif"></img> </blockquote> <p>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 cannot be losslessly converted to an integer value, it is an error. A negative LIMIT value is interpreted as "no limit". If the DELETE statement also has an OFFSET clause, then it is similarly evaluated and cast to an integer value. Again, it is an error if the value cannot be losslessly converted to an integer. If there is no OFFSET clause, or the calculated integer value is negative, the effective OFFSET value is zero. <p>If the DELETE statement has an ORDER BY clause, then all rows that would be deleted in the absence of the LIMIT clause are sorted according to the ORDER BY. The first <i>M</i> rows, where <i>M</i> is the value found by evaluating the OFFSET clause expression, are skipped, and the following <i>N</i>, where <i>N</i> is the value of the LIMIT expression, are deleted. If there are less than <i>N</i> rows remaining after taking the OFFSET clause into account, or if the LIMIT clause evaluated to a negative value, then all remaining rows are deleted. <p>If the DELETE statement has no ORDER BY clause, then all rows that would be deleted in the absence of the LIMIT clause are assembled in an arbitrary order before applying the LIMIT and OFFSET clauses to determine the subset that are actually deleted. <p>The ORDER BY clause on a DELETE statement is used only to determine which rows fall within the LIMIT. The order in which rows are deleted is arbitrary and is not influenced by the ORDER BY clause. <a name="truncateopt"></a> <h3>The Truncate Optimization</h3> <p>When the WHERE is omitted from a DELETE statement and the table being deleted has no triggers, SQLite uses an optimization to erase the entire table content without having to visit each row of the table individually. This "truncate" optimization makes the delete run much faster. Prior to SQLite <a href="releaselog/3_6_5.html">version 3.6.5</a>, the truncate optimization also meant that the <a href="c3ref/changes.html">sqlite3_changes()</a> and <a href="c3ref/total_changes.html">sqlite3_total_changes()</a> interfaces and the <a href="pragma.html#pragma_count_changes">count_changes pragma</a> will not actually return the number of deleted rows. That problem has been fixed as of <a href="releaselog/3_6_5.html">version 3.6.5</a>. <p>The truncate optimization can be permanently disabled for all queries by recompiling SQLite with the <a href="compile.html#omit_truncate_optimization">SQLITE_OMIT_TRUNCATE_OPTIMIZATION</a> compile-time switch.</p> <p>The truncate optimization can also be disabled at runtime using the <a href="c3ref/set_authorizer.html">sqlite3_set_authorizer()</a> interface. If an authorizer callback returns <a href="c3ref/c_deny.html">SQLITE_IGNORE</a> for an <a href="c3ref/c_alter_table.html">SQLITE_DELETE</a> action code, then the DELETE operation will proceed but the truncate optimization will be bypassed and rows will be deleted one by one.</p> |
Changes to Doc/Extra/Core/lang_detach.html.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
<html dir="LTR" xmlns="http://www.w3.org/1999/xhtml" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:MSHelp="http://msdn.microsoft.com/mshelp" xmlns:tool="http://www.microsoft.com/tooltip" xmlns:ndoc="urn:ndoc-preprocess"> <head> <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252" /> <title>DETACH</title> <link rel="stylesheet" type="text/css" href="../Include/ndoc.css" /> </head> <body> <div id="header"> <table width="100%" id="topTable"> <tr id="headerTableRow1"> <td align="left"> <span id="runningHeaderText">DETACH</span> </td> </tr> <tr id="headerTableRow2"> <td align="left"> <span id="nsrTitle">SQLite Language Reference Documentation</span> </td> </tr> <tr id="headerTableRow3" style="display:none"> <td> <a id="seeAlsoSectionLink" href="#seeAlsoToggle" onclick="OpenSection(seeAlsoToggle)">See Also</a> <a id="exampleSectionLink" href="#codeExampleToggle" onclick="OpenSection(codeExampleToggle)">Example</a> </td> </tr> </table> <table width="100%" id="bottomTable" cellspacing="0" cellpadding="0" style="display:none"> <tr> <td> <span onclick="ExpandCollapseAll(toggleAllImage)" style="cursor:default;" onkeypress="ExpandCollapseAll_CheckKey(toggleAllImage)" tabindex="0"> <img ID="toggleAllImage" class="toggleAll" src="collall.gif" /> <label id="collapseAllLabel" for="toggleAllImage" style="display: none;"> Collapse All </label> <label id="expandAllLabel" for="toggleAllImage" style="display: none;"> Expand All </label> </span> </td> </tr> </table> </div> <div id="mainSection"> <div id="mainBody"> <h1 class="heading"> SQL As Understood By SQLite</h1> <h4> DETACH</h4> <p> <table cellpadding="10"> <tr> <td align="right" width="1%" nowrap> <i><font color="#ff3434">sql-command</font></i> ::=</td> <td> <b><font color="#2c2cf0">DETACH </font></b>[<b><font color="#2c2cf0">DATABASE</font></b>]<b><font color="#2c2cf0"> </font></b><i><font color="#ff3434">database-name</font></i><b><font color="#2c2cf0"></font></b></td> </tr> </table> </p> <p> This statement detaches an additional database connection previously attached using the <a href="lang_attach.html">ATTACH DATABASE</a> statement. It is 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> <p> <hr> </p> <div id="footer"> <p> </p> <p> </p> </div> </div> </div> </body> </html> |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html><head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>SQLite Query Language: DETACH DATABASE</title> <style type="text/css"> body { margin: auto; font-family: Verdana, sans-serif; padding: 8px 1%; } a { color: #044a64 } a:visited { color: #734559 } .logo { position:absolute; margin:3px; } .tagline { float:right; text-align:right; font-style:italic; width:300px; margin:12px; margin-top:58px; } .menubar { clear: both; border-radius: 8px; background: #044a64; padding: 0px; margin: 0px; cell-spacing: 0px; } .toolbar { text-align: center; line-height: 1.6em; margin: 0; padding: 0px 8px; } .toolbar a { color: white; text-decoration: none; padding: 6px 12px; } .toolbar a:visited { color: white; } .toolbar a:hover { color: #044a64; background: white; } .content { margin: 5%; } .content dt { font-weight:bold; } .content dd { margin-bottom: 25px; margin-left:20%; } .content ul { padding:0px; padding-left: 15px; margin:0px; } /* Things for "fancyformat" documents start here. */ .fancy img+p {font-style:italic} .fancy .codeblock i { color: darkblue; } .fancy h1,.fancy h2,.fancy h3,.fancy h4 {font-weight:normal;color:#044a64} .fancy h2 { margin-left: 10px } .fancy h3 { margin-left: 20px } .fancy h4 { margin-left: 30px } .fancy th {white-space:nowrap;text-align:left;border-bottom:solid 1px #444} .fancy th, .fancy td {padding: 0.2em 1ex; vertical-align:top} .fancy #toc a { color: darkblue ; text-decoration: none } .fancy .todo { color: #AA3333 ; font-style : italic } .fancy .todo:before { content: 'TODO:' } .fancy p.todo { border: solid #AA3333 1px; padding: 1ex } .fancy img { display:block; } .fancy :link:hover, .fancy :visited:hover { background: wheat } .fancy p,.fancy ul,.fancy ol { margin: 1em 5ex } .fancy li p { margin: 1em 0 } /* End of "fancyformat" specific rules. */ </style> </head> <body> <div><!-- container div to satisfy validator --> <a href="index.html"> <img class="logo" src="images/sqlite370_banner.gif" alt="SQLite Logo" border="0"></a> <div><!-- IE hack to prevent disappearing logo--></div> <div class="tagline">Small. Fast. Reliable.<br>Choose any three.</div> <table width=100% class="menubar"><tr> <td width=100%> <div class="toolbar"> <a href="about.html">About</a> <a href="sitemap.html">Sitemap</a> <a href="docs.html">Documentation</a> <a href="download.html">Download</a> <a href="copyright.html">License</a> <a href="news.html">News</a> <a href="support.html">Support</a> </div> <script> gMsg = "Search SQLite Docs..." function entersearch() { var q = document.getElementById("q"); if( q.value == gMsg ) { q.value = "" } q.style.color = "black" q.style.fontStyle = "normal" } function leavesearch() { var q = document.getElementById("q"); if( q.value == "" ) { q.value = gMsg q.style.color = "#044a64" q.style.fontStyle = "italic" } } function hideorshow(btn,obj){ var x = document.getElementById(obj); var b = document.getElementById(btn); if( x.style.display!='none' ){ x.style.display = 'none'; b.innerHTML='show'; }else{ x.style.display = ''; b.innerHTML='hide'; } return false; } </script> <td> <div style="padding:0 1em 0px 0;white-space:nowrap"> <form name=f method="GET" action="http://www.sqlite.org/search"> <input id=q name=q type=text onfocus="entersearch()" onblur="leavesearch()" style="width:24ex;padding:1px 1ex; border:solid white 1px; font-size:0.9em ; font-style:italic;color:#044a64;" value="Search SQLite Docs..."> <input type=submit value="Go" style="border:solid white 1px;background-color:#044a64;color:white;font-size:0.9em;padding:0 1ex"> </form> </div> </table> <div class=startsearch></div> <h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>DETACH DATABASE</h2><p><b><a href="syntaxdiagrams.html#detach-stmt">detach-stmt:</a></b> <button id='x1045' onclick='hideorshow("x1045","x1046")'>hide</button></p> <blockquote id='x1046'> <img alt="syntax diagram detach-stmt" src="images/syntax/detach-stmt.gif" /> </blockquote> <p>This statement detaches an additional database connection previously attached using the <a href="lang_attach.html">ATTACH</a> statement. When not in <a href="sharedcache.html">shared cache mode</a>, it is 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> In <a href="sharedcache.html">shared cache mode</a>, attempting to attach the same database file more than once results in an error. <p>This statement will fail if SQLite is in the middle of a transaction.</p> |
Changes to Doc/Extra/Core/lang_dropindex.html.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
<html dir="LTR" xmlns="http://www.w3.org/1999/xhtml" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:MSHelp="http://msdn.microsoft.com/mshelp" xmlns:tool="http://www.microsoft.com/tooltip" xmlns:ndoc="urn:ndoc-preprocess"> <head> <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252" /> <title>DROP INDEX</title> <link rel="stylesheet" type="text/css" href="../Include/ndoc.css" /> </head> <body> <div id="header"> <table width="100%" id="topTable"> <tr id="headerTableRow1"> <td align="left"> <span id="runningHeaderText">DROP INDEX</span> </td> </tr> <tr id="headerTableRow2"> <td align="left"> <span id="nsrTitle">SQLite Language Reference Documentation</span> </td> </tr> <tr id="headerTableRow3" style="display:none"> <td> <a id="seeAlsoSectionLink" href="#seeAlsoToggle" onclick="OpenSection(seeAlsoToggle)">See Also</a> <a id="exampleSectionLink" href="#codeExampleToggle" onclick="OpenSection(codeExampleToggle)">Example</a> </td> </tr> </table> <table width="100%" id="bottomTable" cellspacing="0" cellpadding="0" style="display:none"> <tr> <td> <span onclick="ExpandCollapseAll(toggleAllImage)" style="cursor:default;" onkeypress="ExpandCollapseAll_CheckKey(toggleAllImage)" tabindex="0"> <img ID="toggleAllImage" class="toggleAll" src="collall.gif" /> <label id="collapseAllLabel" for="toggleAllImage" style="display: none;"> Collapse All </label> <label id="expandAllLabel" for="toggleAllImage" style="display: none;"> Expand All </label> </span> </td> </tr> </table> </div> <div id="mainSection"> <div id="mainBody"> <h1 class="heading"> SQL As Understood By SQLite</h1> <h4> DROP INDEX</h4> <p> <table cellpadding="10"> <tr> <td align="right" width="1%" nowrap> <i><font color="#ff3434">sql-command</font></i> ::=</td> <td> <b><font color="#2c2cf0">DROP INDEX </font></b>[<b><font color="#2c2cf0">IF EXISTS</font></b>]<b><font color="#2c2cf0"> </font></b>[<b><font color="#2c2cf0"></font></b><i><font color="#ff3434">database-name</font></i><b><font color="#2c2cf0"> <big>.</big></font></b>]<b><font color="#2c2cf0"> </font></b> <i><font color="#ff3434">index-name</font></i><b><font color="#2c2cf0"></font></b></td> </tr> </table> </p> <p> The DROP INDEX statement removes an index added with the <a href="lang_createindex.html"> CREATE INDEX</a> statement. The index named is completely removed from the disk. The only way to recover the index is to reenter the appropriate CREATE INDEX command.</p> <p> The DROP INDEX statement does not reduce the size of the database file in the default mode. Empty space in the database is retained for later INSERTs. To remove free space in the database, use the <a href="lang_vacuum.html"> VACUUM</a> command. If AUTOVACUUM mode is enabled for a database then space will be freed automatically by DROP INDEX.</p> <p> <hr> </p> <div id="footer"> <p> </p> <p> </p> </div> </div> </div> </body> </html> |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html><head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>SQLite Query Language: DROP INDEX</title> <style type="text/css"> body { margin: auto; font-family: Verdana, sans-serif; padding: 8px 1%; } a { color: #044a64 } a:visited { color: #734559 } .logo { position:absolute; margin:3px; } .tagline { float:right; text-align:right; font-style:italic; width:300px; margin:12px; margin-top:58px; } .menubar { clear: both; border-radius: 8px; background: #044a64; padding: 0px; margin: 0px; cell-spacing: 0px; } .toolbar { text-align: center; line-height: 1.6em; margin: 0; padding: 0px 8px; } .toolbar a { color: white; text-decoration: none; padding: 6px 12px; } .toolbar a:visited { color: white; } .toolbar a:hover { color: #044a64; background: white; } .content { margin: 5%; } .content dt { font-weight:bold; } .content dd { margin-bottom: 25px; margin-left:20%; } .content ul { padding:0px; padding-left: 15px; margin:0px; } /* Things for "fancyformat" documents start here. */ .fancy img+p {font-style:italic} .fancy .codeblock i { color: darkblue; } .fancy h1,.fancy h2,.fancy h3,.fancy h4 {font-weight:normal;color:#044a64} .fancy h2 { margin-left: 10px } .fancy h3 { margin-left: 20px } .fancy h4 { margin-left: 30px } .fancy th {white-space:nowrap;text-align:left;border-bottom:solid 1px #444} .fancy th, .fancy td {padding: 0.2em 1ex; vertical-align:top} .fancy #toc a { color: darkblue ; text-decoration: none } .fancy .todo { color: #AA3333 ; font-style : italic } .fancy .todo:before { content: 'TODO:' } .fancy p.todo { border: solid #AA3333 1px; padding: 1ex } .fancy img { display:block; } .fancy :link:hover, .fancy :visited:hover { background: wheat } .fancy p,.fancy ul,.fancy ol { margin: 1em 5ex } .fancy li p { margin: 1em 0 } /* End of "fancyformat" specific rules. */ </style> </head> <body> <div><!-- container div to satisfy validator --> <a href="index.html"> <img class="logo" src="images/sqlite370_banner.gif" alt="SQLite Logo" border="0"></a> <div><!-- IE hack to prevent disappearing logo--></div> <div class="tagline">Small. Fast. Reliable.<br>Choose any three.</div> <table width=100% class="menubar"><tr> <td width=100%> <div class="toolbar"> <a href="about.html">About</a> <a href="sitemap.html">Sitemap</a> <a href="docs.html">Documentation</a> <a href="download.html">Download</a> <a href="copyright.html">License</a> <a href="news.html">News</a> <a href="support.html">Support</a> </div> <script> gMsg = "Search SQLite Docs..." function entersearch() { var q = document.getElementById("q"); if( q.value == gMsg ) { q.value = "" } q.style.color = "black" q.style.fontStyle = "normal" } function leavesearch() { var q = document.getElementById("q"); if( q.value == "" ) { q.value = gMsg q.style.color = "#044a64" q.style.fontStyle = "italic" } } function hideorshow(btn,obj){ var x = document.getElementById(obj); var b = document.getElementById(btn); if( x.style.display!='none' ){ x.style.display = 'none'; b.innerHTML='show'; }else{ x.style.display = ''; b.innerHTML='hide'; } return false; } </script> <td> <div style="padding:0 1em 0px 0;white-space:nowrap"> <form name=f method="GET" action="http://www.sqlite.org/search"> <input id=q name=q type=text onfocus="entersearch()" onblur="leavesearch()" style="width:24ex;padding:1px 1ex; border:solid white 1px; font-size:0.9em ; font-style:italic;color:#044a64;" value="Search SQLite Docs..."> <input type=submit value="Go" style="border:solid white 1px;background-color:#044a64;color:white;font-size:0.9em;padding:0 1ex"> </form> </div> </table> <div class=startsearch></div> <h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>DROP INDEX</h2><p><b><a href="syntaxdiagrams.html#drop-index-stmt">drop-index-stmt:</a></b> <button id='x1047' onclick='hideorshow("x1047","x1048")'>hide</button></p> <blockquote id='x1048'> <img alt="syntax diagram drop-index-stmt" src="images/syntax/drop-index-stmt.gif" /> </blockquote> <p>The DROP INDEX statement removes an index added with the <a href="lang_createindex.html">CREATE INDEX</a> statement. The index is completely removed from the disk. The only way to recover the index is to reenter the appropriate <a href="lang_createindex.html">CREATE INDEX</a> command.</p> |
Changes to Doc/Extra/Core/lang_droptable.html.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
<html dir="LTR" xmlns="http://www.w3.org/1999/xhtml" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:MSHelp="http://msdn.microsoft.com/mshelp" xmlns:tool="http://www.microsoft.com/tooltip" xmlns:ndoc="urn:ndoc-preprocess"> <head> <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252" /> <title>DROP TABLE</title> <link rel="stylesheet" type="text/css" href="../Include/ndoc.css" /> </head> <body> <div id="header"> <table width="100%" id="topTable"> <tr id="headerTableRow1"> <td align="left"> <span id="runningHeaderText">DROP TABLE</span> </td> </tr> <tr id="headerTableRow2"> <td align="left"> <span id="nsrTitle">SQLite Language Reference Documentation</span> </td> </tr> <tr id="headerTableRow3" style="display:none"> <td> <a id="seeAlsoSectionLink" href="#seeAlsoToggle" onclick="OpenSection(seeAlsoToggle)">See Also</a> <a id="exampleSectionLink" href="#codeExampleToggle" onclick="OpenSection(codeExampleToggle)">Example</a> </td> </tr> </table> <table width="100%" id="bottomTable" cellspacing="0" cellpadding="0" style="display:none"> <tr> <td> <span onclick="ExpandCollapseAll(toggleAllImage)" style="cursor:default;" onkeypress="ExpandCollapseAll_CheckKey(toggleAllImage)" tabindex="0"> <img ID="toggleAllImage" class="toggleAll" src="collall.gif" /> <label id="collapseAllLabel" for="toggleAllImage" style="display: none;"> Collapse All </label> <label id="expandAllLabel" for="toggleAllImage" style="display: none;"> Expand All </label> </span> </td> </tr> </table> </div> <div id="mainSection"> <div id="mainBody"> <h1 class="heading"> SQL As Understood By SQLite</h1> <h4> DROP TABLE</h4> <p> <table cellpadding="10"> <tr> <td align="right" width="1%" nowrap> <i><font color="#ff3434">sql-command</font></i> ::=</td> <td> <b><font color="#2c2cf0">DROP TABLE </font></b>[<b><font color="#2c2cf0">IF EXISTS</font></b>]<b><font color="#2c2cf0"> </font></b>[<b><font color="#2c2cf0"></font></b><i><font color="#ff3434">database-name</font></i><b><font color="#2c2cf0"><big>.</big></font></b>]<b><font color="#2c2cf0"> </font></b> <i><font color="#ff3434">table-name</font></i><b><font color="#2c2cf0"></font></b></td> </tr> </table> </p> <p> The DROP TABLE statement removes a table added with the <a href="#createtable">CREATE TABLE</a> statement. The name specified is the table 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.</p> <p> The DROP TABLE statement does not reduce the size of the database file in the default mode. Empty space in the database is retained for later INSERTs. To remove free space in the database, use the <a href="lang_vacuum.html"> VACUUM</a> command. If AUTOVACUUM mode is enabled for a database then space will be freed automatically by DROP TABLE.</p> <p> The optional IF EXISTS clause suppresses the error that would normally result if the table does not exist.</p> <p> <hr> </p> <div id="footer"> <p> </p> <p> </p> </div> </div> </div> </body> </html> |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html><head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>SQLite Query Language: DROP TABLE</title> <style type="text/css"> body { margin: auto; font-family: Verdana, sans-serif; padding: 8px 1%; } a { color: #044a64 } a:visited { color: #734559 } .logo { position:absolute; margin:3px; } .tagline { float:right; text-align:right; font-style:italic; width:300px; margin:12px; margin-top:58px; } .menubar { clear: both; border-radius: 8px; background: #044a64; padding: 0px; margin: 0px; cell-spacing: 0px; } .toolbar { text-align: center; line-height: 1.6em; margin: 0; padding: 0px 8px; } .toolbar a { color: white; text-decoration: none; padding: 6px 12px; } .toolbar a:visited { color: white; } .toolbar a:hover { color: #044a64; background: white; } .content { margin: 5%; } .content dt { font-weight:bold; } .content dd { margin-bottom: 25px; margin-left:20%; } .content ul { padding:0px; padding-left: 15px; margin:0px; } /* Things for "fancyformat" documents start here. */ .fancy img+p {font-style:italic} .fancy .codeblock i { color: darkblue; } .fancy h1,.fancy h2,.fancy h3,.fancy h4 {font-weight:normal;color:#044a64} .fancy h2 { margin-left: 10px } .fancy h3 { margin-left: 20px } .fancy h4 { margin-left: 30px } .fancy th {white-space:nowrap;text-align:left;border-bottom:solid 1px #444} .fancy th, .fancy td {padding: 0.2em 1ex; vertical-align:top} .fancy #toc a { color: darkblue ; text-decoration: none } .fancy .todo { color: #AA3333 ; font-style : italic } .fancy .todo:before { content: 'TODO:' } .fancy p.todo { border: solid #AA3333 1px; padding: 1ex } .fancy img { display:block; } .fancy :link:hover, .fancy :visited:hover { background: wheat } .fancy p,.fancy ul,.fancy ol { margin: 1em 5ex } .fancy li p { margin: 1em 0 } /* End of "fancyformat" specific rules. */ </style> </head> <body> <div><!-- container div to satisfy validator --> <a href="index.html"> <img class="logo" src="images/sqlite370_banner.gif" alt="SQLite Logo" border="0"></a> <div><!-- IE hack to prevent disappearing logo--></div> <div class="tagline">Small. Fast. Reliable.<br>Choose any three.</div> <table width=100% class="menubar"><tr> <td width=100%> <div class="toolbar"> <a href="about.html">About</a> <a href="sitemap.html">Sitemap</a> <a href="docs.html">Documentation</a> <a href="download.html">Download</a> <a href="copyright.html">License</a> <a href="news.html">News</a> <a href="support.html">Support</a> </div> <script> gMsg = "Search SQLite Docs..." function entersearch() { var q = document.getElementById("q"); if( q.value == gMsg ) { q.value = "" } q.style.color = "black" q.style.fontStyle = "normal" } function leavesearch() { var q = document.getElementById("q"); if( q.value == "" ) { q.value = gMsg q.style.color = "#044a64" q.style.fontStyle = "italic" } } function hideorshow(btn,obj){ var x = document.getElementById(obj); var b = document.getElementById(btn); if( x.style.display!='none' ){ x.style.display = 'none'; b.innerHTML='show'; }else{ x.style.display = ''; b.innerHTML='hide'; } return false; } </script> <td> <div style="padding:0 1em 0px 0;white-space:nowrap"> <form name=f method="GET" action="http://www.sqlite.org/search"> <input id=q name=q type=text onfocus="entersearch()" onblur="leavesearch()" style="width:24ex;padding:1px 1ex; border:solid white 1px; font-size:0.9em ; font-style:italic;color:#044a64;" value="Search SQLite Docs..."> <input type=submit value="Go" style="border:solid white 1px;background-color:#044a64;color:white;font-size:0.9em;padding:0 1ex"> </form> </div> </table> <div class=startsearch></div> <h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>DROP TABLE</h2><p><b><a href="syntaxdiagrams.html#drop-table-stmt">drop-table-stmt:</a></b> <button id='x1049' onclick='hideorshow("x1049","x1050")'>hide</button></p> <blockquote id='x1050'> <img alt="syntax diagram drop-table-stmt" src="images/syntax/drop-table-stmt.gif" /> </blockquote> <p>The DROP TABLE statement removes a table added with the <a href="lang_createtable.html">CREATE TABLE</a> statement. The name specified is the table name. The dropped table is completely removed from the database schema and the disk file. The table can not be recovered. All indices and triggers associated with the table are also deleted.</p> <p>The optional IF EXISTS clause suppresses the error that would normally result if the table does not exist.</p> <p>If <a href="foreignkeys.html">foreign key constraints</a> are enabled, a DROP TABLE command performs an implicit <a href="lang_delete.html">DELETE FROM <tbl></a> command before removing the table from the database schema. Any triggers attached to the table are dropped from the database schema before the implicit DELETE FROM <tbl> is executed, so this cannot cause any triggers to fire. By contrast, an implicit DELETE FROM <tbl> does cause any configured <a href="foreignkeys.html#fk_actions">foreign key actions</a> to take place. If the implicit DELETE FROM <tbl> executed as part of a DROP TABLE command violates any immediate foreign key constraints, an error is returned and the table is not dropped. If the implicit DELETE FROM <tbl> causes any deferred foreign key constraints to be violated, and the violations still exist when the transaction is committed, an error is returned at the time of commit. |
Changes to Doc/Extra/Core/lang_droptrigger.html.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
<html dir="LTR" xmlns="http://www.w3.org/1999/xhtml" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:MSHelp="http://msdn.microsoft.com/mshelp" xmlns:tool="http://www.microsoft.com/tooltip" xmlns:ndoc="urn:ndoc-preprocess"> <head> <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252" /> <title>DROP TRIGGER</title> <link rel="stylesheet" type="text/css" href="../Include/ndoc.css" /> </head> <body> <div id="header"> <table width="100%" id="topTable"> <tr id="headerTableRow1"> <td align="left"> <span id="runningHeaderText">DROP TRIGGER</span> </td> </tr> <tr id="headerTableRow2"> <td align="left"> <span id="nsrTitle">SQLite Language Reference Documentation</span> </td> </tr> <tr id="headerTableRow3" style="display:none"> <td> <a id="seeAlsoSectionLink" href="#seeAlsoToggle" onclick="OpenSection(seeAlsoToggle)">See Also</a> <a id="exampleSectionLink" href="#codeExampleToggle" onclick="OpenSection(codeExampleToggle)">Example</a> </td> </tr> </table> <table width="100%" id="bottomTable" cellspacing="0" cellpadding="0" style="display:none"> <tr> <td> <span onclick="ExpandCollapseAll(toggleAllImage)" style="cursor:default;" onkeypress="ExpandCollapseAll_CheckKey(toggleAllImage)" tabindex="0"> <img ID="toggleAllImage" class="toggleAll" src="collall.gif" /> <label id="collapseAllLabel" for="toggleAllImage" style="display: none;"> Collapse All </label> <label id="expandAllLabel" for="toggleAllImage" style="display: none;"> Expand All </label> </span> </td> </tr> </table> </div> <div id="mainSection"> <div id="mainBody"> <h1 class="heading"> SQL As Understood By SQLite</h1> <h4> DROP TRIGGER</h4> <p> <table cellpadding="10"> <tr> <td align="right" width="1%" nowrap> <i><font color="#ff3434">sql-statement</font></i> ::=</td> <td> <b><font color="#2c2cf0">DROP TRIGGER </font></b>[<b><font color="#2c2cf0"></font></b><i><font color="#ff3434">database-name</font></i><b><font color="#2c2cf0"> <big>.</big></font></b>]<b><font color="#2c2cf0"> </font></b><i><font color="#ff3434">trigger-name</font></i><b><font color="#2c2cf0"></font></b></td> </tr> </table> </p> <p> The DROP TRIGGER statement removes a trigger created by the <a href="lang_createtrigger.html"> CREATE TRIGGER</a> statement. The trigger is deleted from the database schema. Note that triggers are automatically dropped when the associated table is dropped.</p> <p> <hr> </p> <div id="footer"> <p> </p> <p> </p> </div> </div> </div> </body> </html> |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html><head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>SQLite Query Language: DROP TRIGGER</title> <style type="text/css"> body { margin: auto; font-family: Verdana, sans-serif; padding: 8px 1%; } a { color: #044a64 } a:visited { color: #734559 } .logo { position:absolute; margin:3px; } .tagline { float:right; text-align:right; font-style:italic; width:300px; margin:12px; margin-top:58px; } .menubar { clear: both; border-radius: 8px; background: #044a64; padding: 0px; margin: 0px; cell-spacing: 0px; } .toolbar { text-align: center; line-height: 1.6em; margin: 0; padding: 0px 8px; } .toolbar a { color: white; text-decoration: none; padding: 6px 12px; } .toolbar a:visited { color: white; } .toolbar a:hover { color: #044a64; background: white; } .content { margin: 5%; } .content dt { font-weight:bold; } .content dd { margin-bottom: 25px; margin-left:20%; } .content ul { padding:0px; padding-left: 15px; margin:0px; } /* Things for "fancyformat" documents start here. */ .fancy img+p {font-style:italic} .fancy .codeblock i { color: darkblue; } .fancy h1,.fancy h2,.fancy h3,.fancy h4 {font-weight:normal;color:#044a64} .fancy h2 { margin-left: 10px } .fancy h3 { margin-left: 20px } .fancy h4 { margin-left: 30px } .fancy th {white-space:nowrap;text-align:left;border-bottom:solid 1px #444} .fancy th, .fancy td {padding: 0.2em 1ex; vertical-align:top} .fancy #toc a { color: darkblue ; text-decoration: none } .fancy .todo { color: #AA3333 ; font-style : italic } .fancy .todo:before { content: 'TODO:' } .fancy p.todo { border: solid #AA3333 1px; padding: 1ex } .fancy img { display:block; } .fancy :link:hover, .fancy :visited:hover { background: wheat } .fancy p,.fancy ul,.fancy ol { margin: 1em 5ex } .fancy li p { margin: 1em 0 } /* End of "fancyformat" specific rules. */ </style> </head> <body> <div><!-- container div to satisfy validator --> <a href="index.html"> <img class="logo" src="images/sqlite370_banner.gif" alt="SQLite Logo" border="0"></a> <div><!-- IE hack to prevent disappearing logo--></div> <div class="tagline">Small. Fast. Reliable.<br>Choose any three.</div> <table width=100% class="menubar"><tr> <td width=100%> <div class="toolbar"> <a href="about.html">About</a> <a href="sitemap.html">Sitemap</a> <a href="docs.html">Documentation</a> <a href="download.html">Download</a> <a href="copyright.html">License</a> <a href="news.html">News</a> <a href="support.html">Support</a> </div> <script> gMsg = "Search SQLite Docs..." function entersearch() { var q = document.getElementById("q"); if( q.value == gMsg ) { q.value = "" } q.style.color = "black" q.style.fontStyle = "normal" } function leavesearch() { var q = document.getElementById("q"); if( q.value == "" ) { q.value = gMsg q.style.color = "#044a64" q.style.fontStyle = "italic" } } function hideorshow(btn,obj){ var x = document.getElementById(obj); var b = document.getElementById(btn); if( x.style.display!='none' ){ x.style.display = 'none'; b.innerHTML='show'; }else{ x.style.display = ''; b.innerHTML='hide'; } return false; } </script> <td> <div style="padding:0 1em 0px 0;white-space:nowrap"> <form name=f method="GET" action="http://www.sqlite.org/search"> <input id=q name=q type=text onfocus="entersearch()" onblur="leavesearch()" style="width:24ex;padding:1px 1ex; border:solid white 1px; font-size:0.9em ; font-style:italic;color:#044a64;" value="Search SQLite Docs..."> <input type=submit value="Go" style="border:solid white 1px;background-color:#044a64;color:white;font-size:0.9em;padding:0 1ex"> </form> </div> </table> <div class=startsearch></div> <h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>DROP TRIGGER</h2><p><b><a href="syntaxdiagrams.html#drop-trigger-stmt">drop-trigger-stmt:</a></b> <button id='x1051' onclick='hideorshow("x1051","x1052")'>hide</button></p> <blockquote id='x1052'> <img alt="syntax diagram drop-trigger-stmt" src="images/syntax/drop-trigger-stmt.gif" /> </blockquote> <p>The DROP TRIGGER statement removes a trigger created by the <a href="lang_createtrigger.html">CREATE TRIGGER</a> statement. Once removed, the trigger definition is no longer present in the sqlite_master (or sqlite_temp_master) table and is not fired by any subsequent INSERT, UPDATE or DELETE statements. <p>Note that triggers are automatically dropped when the associated table is dropped. |
Changes to Doc/Extra/Core/lang_dropview.html.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
<html dir="LTR" xmlns="http://www.w3.org/1999/xhtml" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:MSHelp="http://msdn.microsoft.com/mshelp" xmlns:tool="http://www.microsoft.com/tooltip" xmlns:ndoc="urn:ndoc-preprocess"> <head> <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252" /> <title>DROP VIEW</title> <link rel="stylesheet" type="text/css" href="../Include/ndoc.css" /> </head> <body> <div id="header"> <table width="100%" id="topTable"> <tr id="headerTableRow1"> <td align="left"> <span id="runningHeaderText">DROP VIEW</span> </td> </tr> <tr id="headerTableRow2"> <td align="left"> <span id="nsrTitle">SQLite Language Reference Documentation</span> </td> </tr> <tr id="headerTableRow3" style="display:none"> <td> <a id="seeAlsoSectionLink" href="#seeAlsoToggle" onclick="OpenSection(seeAlsoToggle)">See Also</a> <a id="exampleSectionLink" href="#codeExampleToggle" onclick="OpenSection(codeExampleToggle)">Example</a> </td> </tr> </table> <table width="100%" id="bottomTable" cellspacing="0" cellpadding="0" style="display:none"> <tr> <td> <span onclick="ExpandCollapseAll(toggleAllImage)" style="cursor:default;" onkeypress="ExpandCollapseAll_CheckKey(toggleAllImage)" tabindex="0"> <img ID="toggleAllImage" class="toggleAll" src="collall.gif" /> <label id="collapseAllLabel" for="toggleAllImage" style="display: none;"> Collapse All </label> <label id="expandAllLabel" for="toggleAllImage" style="display: none;"> Expand All </label> </span> </td> </tr> </table> </div> <div id="mainSection"> <div id="mainBody"> <h1 class="heading"> SQL As Understood By SQLite</h1> <h4> DROP VIEW</h4> <p> <table cellpadding="10"> <tr> <td align="right" width="1%" nowrap> <i><font color="#ff3434">sql-command</font></i> ::=</td> <td> <b><font color="#2c2cf0">DROP VIEW </font></b><i><font color="#ff3434">view-name</font></i><b><font color="#2c2cf0"></font></b></td> </tr> </table> </p> <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.</p> <p> <hr> </p> <div id="footer"> <p> </p> <p> </p> </div> </div> </div> </body> </html> |
| | | | | < | > | | < < > > | | < > | | | | | | | | < < > > | | | | | | | < > | | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | < < < > > > > > > > > > > > > > > > > > > > > > | < < < < < < < < < < < > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | < < > > > > > > | | < < > > > > > > > > > > | < | | > > > > > | < < < < < < < < < < < < > > > > > > > |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html><head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>SQLite Query Language: DROP VIEW</title> <style type="text/css"> body { margin: auto; font-family: Verdana, sans-serif; padding: 8px 1%; } a { color: #044a64 } a:visited { color: #734559 } .logo { position:absolute; margin:3px; } .tagline { float:right; text-align:right; font-style:italic; width:300px; margin:12px; margin-top:58px; } .menubar { clear: both; border-radius: 8px; background: #044a64; padding: 0px; margin: 0px; cell-spacing: 0px; } .toolbar { text-align: center; line-height: 1.6em; margin: 0; padding: 0px 8px; } .toolbar a { color: white; text-decoration: none; padding: 6px 12px; } .toolbar a:visited { color: white; } .toolbar a:hover { color: #044a64; background: white; } .content { margin: 5%; } .content dt { font-weight:bold; } .content dd { margin-bottom: 25px; margin-left:20%; } .content ul { padding:0px; padding-left: 15px; margin:0px; } /* Things for "fancyformat" documents start here. */ .fancy img+p {font-style:italic} .fancy .codeblock i { color: darkblue; } .fancy h1,.fancy h2,.fancy h3,.fancy h4 {font-weight:normal;color:#044a64} .fancy h2 { margin-left: 10px } .fancy h3 { margin-left: 20px } .fancy h4 { margin-left: 30px } .fancy th {white-space:nowrap;text-align:left;border-bottom:solid 1px #444} .fancy th, .fancy td {padding: 0.2em 1ex; vertical-align:top} .fancy #toc a { color: darkblue ; text-decoration: none } .fancy .todo { color: #AA3333 ; font-style : italic } .fancy .todo:before { content: 'TODO:' } .fancy p.todo { border: solid #AA3333 1px; padding: 1ex } .fancy img { display:block; } .fancy :link:hover, .fancy :visited:hover { background: wheat } .fancy p,.fancy ul,.fancy ol { margin: 1em 5ex } .fancy li p { margin: 1em 0 } /* End of "fancyformat" specific rules. */ </style> </head> <body> <div><!-- container div to satisfy validator --> <a href="index.html"> <img class="logo" src="images/sqlite370_banner.gif" alt="SQLite Logo" border="0"></a> <div><!-- IE hack to prevent disappearing logo--></div> <div class="tagline">Small. Fast. Reliable.<br>Choose any three.</div> <table width=100% class="menubar"><tr> <td width=100%> <div class="toolbar"> <a href="about.html">About</a> <a href="sitemap.html">Sitemap</a> <a href="docs.html">Documentation</a> <a href="download.html">Download</a> <a href="copyright.html">License</a> <a href="news.html">News</a> <a href="support.html">Support</a> </div> <script> gMsg = "Search SQLite Docs..." function entersearch() { var q = document.getElementById("q"); if( q.value == gMsg ) { q.value = "" } q.style.color = "black" q.style.fontStyle = "normal" } function leavesearch() { var q = document.getElementById("q"); if( q.value == "" ) { q.value = gMsg q.style.color = "#044a64" q.style.fontStyle = "italic" } } function hideorshow(btn,obj){ var x = document.getElementById(obj); var b = document.getElementById(btn); if( x.style.display!='none' ){ x.style.display = 'none'; b.innerHTML='show'; }else{ x.style.display = ''; b.innerHTML='hide'; } return false; } </script> <td> <div style="padding:0 1em 0px 0;white-space:nowrap"> <form name=f method="GET" action="http://www.sqlite.org/search"> <input id=q name=q type=text onfocus="entersearch()" onblur="leavesearch()" style="width:24ex;padding:1px 1ex; border:solid white 1px; font-size:0.9em ; font-style:italic;color:#044a64;" value="Search SQLite Docs..."> <input type=submit value="Go" style="border:solid white 1px;background-color:#044a64;color:white;font-size:0.9em;padding:0 1ex"> </form> </div> </table> <div class=startsearch></div> <h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>DROP VIEW</h2><p><b><a href="syntaxdiagrams.html#drop-view-stmt">drop-view-stmt:</a></b> <button id='x1053' onclick='hideorshow("x1053","x1054")'>hide</button></p> <blockquote id='x1054'> <img alt="syntax diagram drop-view-stmt" src="images/syntax/drop-view-stmt.gif" /> </blockquote> <p>The DROP VIEW statement removes a view created by the <a href="lang_createview.html">CREATE VIEW</a> statement. The view definition is removed from the database schema, but no actual data in the underlying base tables is modified. <p>The view to drop is identified by the view-name and optional database-name specified as part of the DROP VIEW statement. This reference is resolved using the standard procedure for <a href="lang_naming.html">object resolution</a>. <p> If the specified view cannot be found and the IF EXISTS clause is not present, it is an error. If the specified view cannot be found and an IF EXISTS clause is present in the DROP VIEW statement, then the statement is a no-op. |
Changes to Doc/Extra/Core/lang_explain.html.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
<html dir="LTR" xmlns="http://www.w3.org/1999/xhtml" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:MSHelp="http://msdn.microsoft.com/mshelp" xmlns:tool="http://www.microsoft.com/tooltip" xmlns:ndoc="urn:ndoc-preprocess"> <head> <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252" /> <title>EXPLAIN</title> <link rel="stylesheet" type="text/css" href="../Include/ndoc.css" /> </head> <body> <div id="header"> <table width="100%" id="topTable"> <tr id="headerTableRow1"> <td align="left"> <span id="runningHeaderText">EXPLAIN</span> </td> </tr> <tr id="headerTableRow2"> <td align="left"> <span id="nsrTitle">SQLite Language Reference Documentation</span> </td> </tr> <tr id="headerTableRow3" style="display:none"> <td> <a id="seeAlsoSectionLink" href="#seeAlsoToggle" onclick="OpenSection(seeAlsoToggle)">See Also</a> <a id="exampleSectionLink" href="#codeExampleToggle" onclick="OpenSection(codeExampleToggle)">Example</a> </td> </tr> </table> <table width="100%" id="bottomTable" cellspacing="0" cellpadding="0" style="display:none"> <tr> <td> <span onclick="ExpandCollapseAll(toggleAllImage)" style="cursor:default;" onkeypress="ExpandCollapseAll_CheckKey(toggleAllImage)" tabindex="0"> <img ID="toggleAllImage" class="toggleAll" src="collall.gif" /> <label id="collapseAllLabel" for="toggleAllImage" style="display: none;"> Collapse All </label> <label id="expandAllLabel" for="toggleAllImage" style="display: none;"> Expand All </label> </span> </td> </tr> </table> </div> <div id="mainSection"> <div id="mainBody"> <h1 class="heading"> SQL As Understood By SQLite</h1> <h4> EXPLAIN</h4> <p> <table cellpadding="10"> <tr> <td align="right" width="1%" nowrap> <i><font color="#ff3434">sql-statement</font></i> ::=</td> <td> <b><font color="#2c2cf0">EXPLAIN </font></b><i><font color="#ff3434">sql-statement</font></i><b><font color="#2c2cf0"></font></b></td> </tr> </table> </p> <p> The EXPLAIN command modifier is a non-standard extension. The idea comes from a similar command found in PostgreSQL, but the operation is completely different.</p> <p> If the EXPLAIN keyword appears before any other SQLite SQL command then instead of actually executing the command, the SQLite library will report back the sequence of virtual machine instructions it would have used to execute the command had the EXPLAIN keyword not been present. For additional information about virtual machine instructions see the <a href="http://www.sqlite.org/arch.html">architecture description</a> or the documentation on <a href="http://www.sqlite.org/opcode.html">available opcodes</a> for the virtual machine.</p> <p> </p> <hr> <div id="footer"> <p> </p> <p> </p> </div> </div> </div> </body> </html> |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html><head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>SQLite Query Language: EXPLAIN</title> <style type="text/css"> body { margin: auto; font-family: Verdana, sans-serif; padding: 8px 1%; } a { color: #044a64 } a:visited { color: #734559 } .logo { position:absolute; margin:3px; } .tagline { float:right; text-align:right; font-style:italic; width:300px; margin:12px; margin-top:58px; } .menubar { clear: both; border-radius: 8px; background: #044a64; padding: 0px; margin: 0px; cell-spacing: 0px; } .toolbar { text-align: center; line-height: 1.6em; margin: 0; padding: 0px 8px; } .toolbar a { color: white; text-decoration: none; padding: 6px 12px; } .toolbar a:visited { color: white; } .toolbar a:hover { color: #044a64; background: white; } .content { margin: 5%; } .content dt { font-weight:bold; } .content dd { margin-bottom: 25px; margin-left:20%; } .content ul { padding:0px; padding-left: 15px; margin:0px; } /* Things for "fancyformat" documents start here. */ .fancy img+p {font-style:italic} .fancy .codeblock i { color: darkblue; } .fancy h1,.fancy h2,.fancy h3,.fancy h4 {font-weight:normal;color:#044a64} .fancy h2 { margin-left: 10px } .fancy h3 { margin-left: 20px } .fancy h4 { margin-left: 30px } .fancy th {white-space:nowrap;text-align:left;border-bottom:solid 1px #444} .fancy th, .fancy td {padding: 0.2em 1ex; vertical-align:top} .fancy #toc a { color: darkblue ; text-decoration: none } .fancy .todo { color: #AA3333 ; font-style : italic } .fancy .todo:before { content: 'TODO:' } .fancy p.todo { border: solid #AA3333 1px; padding: 1ex } .fancy img { display:block; } .fancy :link:hover, .fancy :visited:hover { background: wheat } .fancy p,.fancy ul,.fancy ol { margin: 1em 5ex } .fancy li p { margin: 1em 0 } /* End of "fancyformat" specific rules. */ </style> </head> <body> <div><!-- container div to satisfy validator --> <a href="index.html"> <img class="logo" src="images/sqlite370_banner.gif" alt="SQLite Logo" border="0"></a> <div><!-- IE hack to prevent disappearing logo--></div> <div class="tagline">Small. Fast. Reliable.<br>Choose any three.</div> <table width=100% class="menubar"><tr> <td width=100%> <div class="toolbar"> <a href="about.html">About</a> <a href="sitemap.html">Sitemap</a> <a href="docs.html">Documentation</a> <a href="download.html">Download</a> <a href="copyright.html">License</a> <a href="news.html">News</a> <a href="support.html">Support</a> </div> <script> gMsg = "Search SQLite Docs..." function entersearch() { var q = document.getElementById("q"); if( q.value == gMsg ) { q.value = "" } q.style.color = "black" q.style.fontStyle = "normal" } function leavesearch() { var q = document.getElementById("q"); if( q.value == "" ) { q.value = gMsg q.style.color = "#044a64" q.style.fontStyle = "italic" } } function hideorshow(btn,obj){ var x = document.getElementById(obj); var b = document.getElementById(btn); if( x.style.display!='none' ){ x.style.display = 'none'; b.innerHTML='show'; }else{ x.style.display = ''; b.innerHTML='hide'; } return false; } </script> <td> <div style="padding:0 1em 0px 0;white-space:nowrap"> <form name=f method="GET" action="http://www.sqlite.org/search"> <input id=q name=q type=text onfocus="entersearch()" onblur="leavesearch()" style="width:24ex;padding:1px 1ex; border:solid white 1px; font-size:0.9em ; font-style:italic;color:#044a64;" value="Search SQLite Docs..."> <input type=submit value="Go" style="border:solid white 1px;background-color:#044a64;color:white;font-size:0.9em;padding:0 1ex"> </form> </div> </table> <div class=startsearch></div> <h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>EXPLAIN</h2><p><b><a href="syntaxdiagrams.html#sql-stmt">sql-stmt:</a></b></p><blockquote> <img alt="syntax diagram sql-stmt" src="images/syntax/sql-stmt.gif"></img> </blockquote> <p>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 how the SQL statement would have operated if the EXPLAIN keyword or phrase had been omitted.</p> <p>The output from EXPLAIN and EXPLAIN QUERY PLAN is intended for interactive analysis and troubleshooting only. The details of the output format are subject to change from one release of SQLite to the next. Applications should not use EXPLAIN or EXPLAIN QUERY PLAN since their exact behavior is variable and only partially documented.</p> <p>When the EXPLAIN keyword appears by itself it causes the statement to behave as a query that returns the sequence of <a href="opcode.html">virtual machine instructions</a> it would have used to execute the command had the EXPLAIN keyword not been present. When the EXPLAIN QUERY PLAN phrase appears, the statement returns high-level information regarding the query plan that would have been used. The EXPLAIN QUERY PLAN command is described in <a href="eqp.html">more detail here</a>. |
Changes to Doc/Extra/Core/lang_expr.html.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 |
<html dir="LTR" xmlns="http://www.w3.org/1999/xhtml" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:MSHelp="http://msdn.microsoft.com/mshelp" xmlns:tool="http://www.microsoft.com/tooltip" xmlns:ndoc="urn:ndoc-preprocess"> <head> <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252" /> <title>expression</title> <link rel="stylesheet" type="text/css" href="../Include/ndoc.css" /> <style type="text/css"> .style1 { height: 70px; } </style> </head> <body> <div id="header"> <table width="100%" id="topTable"> <tr id="headerTableRow1"> <td align="left"> <span id="runningHeaderText">expression</span> </td> </tr> <tr id="headerTableRow2"> <td align="left"> <span id="nsrTitle">SQLite Language Reference Documentation</span> </td> </tr> <tr id="headerTableRow3" style="display:none"> <td> <a id="seeAlsoSectionLink" href="#seeAlsoToggle" onclick="OpenSection(seeAlsoToggle)">See Also</a> <a id="exampleSectionLink" href="#codeExampleToggle" onclick="OpenSection(codeExampleToggle)">Example</a> </td> </tr> </table> <table width="100%" id="bottomTable" cellspacing="0" cellpadding="0" style="display:none"> <tr> <td> <span onclick="ExpandCollapseAll(toggleAllImage)" style="cursor:default;" onkeypress="ExpandCollapseAll_CheckKey(toggleAllImage)" tabindex="0"> <img ID="toggleAllImage" class="toggleAll" src="collall.gif" /> <label id="collapseAllLabel" for="toggleAllImage" style="display: none;"> Collapse All </label> <label id="expandAllLabel" for="toggleAllImage" style="display: none;"> Expand All </label> </span> </td> </tr> </table> </div> <div id="mainSection"> <div id="mainBody"> <h1 class="heading"> SQL As Understood By SQLite</h1> <h4> expression</h4> <p> <table cellpadding="10"> <tr> <td align="right" width="1%" nowrap> <i><font color="#ff3434">expr</font></i> ::=</td> <td> <b><font color="#2c2cf0"></font></b><i><font color="#ff3434">expr</font></i><b><font color="#2c2cf0"> </font></b><i><font color="#ff3434">binary-op</font></i><b><font color="#2c2cf0"> </font></b><i><font color="#ff3434">expr</font></i><b><font color="#2c2cf0"> </font></b><big>|</big><b><font color="#2c2cf0"><br /> </font></b><i><font color="#ff3434">expr</font></i><b><font color="#2c2cf0"> </font> </b>[<b><font color="#2c2cf0">NOT</font></b>]<b><font color="#2c2cf0"> </font></b> <i><font color="#ff3434">like-op</font></i><b><font color="#2c2cf0"> </font></b> <i><font color="#ff3434">expr</font></i><b><font color="#2c2cf0"> </font></b>[<b><font color="#2c2cf0">ESCAPE </font></b><i><font color="#ff3434">expr</font></i><b><font color="#2c2cf0"></font></b>]<b><font color="#2c2cf0"> </font></b><big>|</big><b><font color="#2c2cf0"><br /> </font></b><i><font color="#ff3434">unary-op</font></i><b><font color="#2c2cf0"> </font> </b><i><font color="#ff3434">expr</font></i><b><font color="#2c2cf0"> </font></b> <big>|</big><b><font color="#2c2cf0"><br /> <big>(</big> </font></b><i><font color="#ff3434">expr</font></i><b><font color="#2c2cf0"> <big>)</big> </font></b><big>|</big><b><font color="#2c2cf0"><br /> </font></b><i><font color="#ff3434">column-name</font></i><b><font color="#2c2cf0"> </font></b><big>|</big><b><font color="#2c2cf0"><br /> </font></b><i><font color="#ff3434">table-name</font></i><b><font color="#2c2cf0"> <big>.</big> </font></b><i><font color="#ff3434">column-name</font></i><b><font color="#2c2cf0"> </font></b><big>|</big><b><font color="#2c2cf0"><br /> </font></b><i><font color="#ff3434">database-name</font></i><b><font color="#2c2cf0"> <big>.</big> </font></b><i><font color="#ff3434">table-name</font></i><b><font color="#2c2cf0"> <big>.</big> </font></b><i><font color="#ff3434">column-name</font></i><b><font color="#2c2cf0"> </font></b><big>|</big><b><font color="#2c2cf0"><br /> </font></b><i><font color="#ff3434">literal-value</font></i><b><font color="#2c2cf0"> </font></b><big>|</big><b><font color="#2c2cf0"><br /> </font></b><i><font color="#ff3434">parameter</font></i><b><font color="#2c2cf0"> </font></b><big>|</big><b><font color="#2c2cf0"><br /> </font></b><i><font color="#ff3434">function-name</font></i><b><font color="#2c2cf0"> <big>(</big> </font></b><i><font color="#ff3434">expr-list</font></i><b><font color="#2c2cf0"> </font></b><big>|</big><b><font color="#2c2cf0"> <big>*</big> <big>)</big> </font> </b><big>|</big><b><font color="#2c2cf0"><br /> </font></b><i><font color="#ff3434">expr</font></i><b><font color="#2c2cf0"> ISNULL </font></b><big>|</big><b><font color="#2c2cf0"><br /> </font></b><i><font color="#ff3434">expr</font></i><b><font color="#2c2cf0"> NOTNULL </font></b><big>|</big><b><font color="#2c2cf0"><br /> </font></b><i><font color="#ff3434">expr</font></i><b><font color="#2c2cf0"> </font> </b>[<b><font color="#2c2cf0">NOT</font></b>]<b><font color="#2c2cf0"> BETWEEN </font> </b><i><font color="#ff3434">expr</font></i><b><font color="#2c2cf0"> AND </font></b> <i><font color="#ff3434">expr</font></i><b><font color="#2c2cf0"> </font></b><big> |</big><b><font color="#2c2cf0"><br /> </font></b><i><font color="#ff3434">expr</font></i><b><font color="#2c2cf0"> </font> </b>[<b><font color="#2c2cf0">NOT</font></b>]<b><font color="#2c2cf0"> IN <big>(</big> </font></b><i><font color="#ff3434">value-list</font></i><b><font color="#2c2cf0"> <big>)</big> </font></b><big>|</big><b><font color="#2c2cf0"><br /> </font></b><i><font color="#ff3434">expr</font></i><b><font color="#2c2cf0"> </font> </b>[<b><font color="#2c2cf0">NOT</font></b>]<b><font color="#2c2cf0"> IN <big>(</big> </font></b><i><font color="#ff3434">select-statement</font></i><b><font color="#2c2cf0"> <big>)</big> </font></b><big>|</big><b><font color="#2c2cf0"><br /> </font></b><i><font color="#ff3434">expr</font></i><b><font color="#2c2cf0"> </font> </b>[<b><font color="#2c2cf0">NOT</font></b>]<b><font color="#2c2cf0"> IN </font></b> [<b><font color="#2c2cf0"></font></b><i><font color="#ff3434">database-name</font></i><b><font color="#2c2cf0"> <big>.</big></font></b>]<b><font color="#2c2cf0"> </font></b> <i><font color="#ff3434">table-name</font></i><b><font color="#2c2cf0"> </font></b> <big>|</big><b><font color="#2c2cf0"><br /> </font></b>[<b><font color="#2c2cf0">EXISTS</font></b>]<b><font color="#2c2cf0"> <big> (</big> </font></b><i><font color="#ff3434">select-statement</font></i><b><font color="#2c2cf0"> <big>)</big> </font></b><big>|</big><b><font color="#2c2cf0"><br /> CASE </font></b>[<b><font color="#2c2cf0"></font></b><i><font color="#ff3434">expr</font></i><b><font color="#2c2cf0"></font></b>]<b><font color="#2c2cf0"> </font></b>(<b><font color="#2c2cf0"> WHEN </font></b><i><font color="#ff3434">expr</font></i><b><font color="#2c2cf0"> THEN </font></b><i><font color="#ff3434">expr</font></i><b><font color="#2c2cf0"> </font></b>)+<b><font color="#2c2cf0"> </font></b>[<b><font color="#2c2cf0">ELSE </font> </b><i><font color="#ff3434">expr</font></i><b><font color="#2c2cf0"></font></b>]<b><font color="#2c2cf0"> END </font></b><big>|</big><b><font color="#2c2cf0"><br /> CAST <big>(</big> </font></b><i><font color="#ff3434">expr</font></i><b><font color="#2c2cf0"> AS </font></b><i><font color="#ff3434">type</font></i><b><font color="#2c2cf0"> <big> )</big></font></b></td> </tr> <tr> <td align="right" width="1%" nowrap> <i><font color="#ff3434">like-op</font></i> ::=</td> <td> <b><font color="#2c2cf0">LIKE </font></b><big>|</big><b><font color="#2c2cf0"> GLOB </font></b><big>|</big><b><font color="#2c2cf0"> REGEXP </font></b><big>|</big><b><font color="#2c2cf0"> MATCH</font></b></td> </tr> </table> </p> <p> 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 subcomponents of most other commands.</p> <p> SQLite understands the following binary operators, in order from highest to lowest precedence:</p> <blockquote> <pre><font color="#2c2cf0"><big>|| * / % + - << >> & | < <= > >= = == != <> </big>IN AND OR</font> </pre> </blockquote> <p> Supported unary operators are these:</p> <blockquote> <pre><font color="#2c2cf0"><big>- + ! ~ NOT</big></font> </pre> </blockquote> <p> The unary operator [Operator +] is a no-op. It can be applied to strings, numbers, or blobs and it always gives as its result the value of the operand.</p> <p> Note that there are two variations of the equals and not equals operators. Equals can be either <font color="#2c2cf0"><big>=</big></font> or <font color="#2c2cf0"><big> ==</big></font>. The non-equals operator can be either <font color="#2c2cf0"><big> !=</big></font> or <font color="#2c2cf0"><big><></big></font>. The <font color="#2c2cf0"> <big>||</big></font> operator is "concatenate" - it joins together the two strings of its operands. The operator <font color="#2c2cf0"><big>%</big></font> outputs the remainder of its left operand modulo its right operand.</p> <p> The result of any binary operator is a numeric value, except for the <font color="#2c2cf0"> <big>||</big></font> concatenation operator which gives a string result.</p> <a name="literal_value"></a> <p> A literal value is an integer number or a floating point number. Scientific notation is supported. The "." character is always used as the decimal point even if the locale setting specifies "," for this role - the use of "," for the decimal point would result in syntactic ambiguity. A string constant is formed by enclosing the string in single quotes ('). A single quote within the string can be encoded by putting two single quotes in a row - as in Pascal. C-style escapes using the backslash character are not supported because they are not standard SQL. BLOB literals are string literals containing hexadecimal data and preceded by a single "x" or "X" character. For example:</p> <blockquote> <pre>X'53514697465' </pre> </blockquote> <p> A literal value can also be the token "NULL". </p> <p> A parameter specifies a placeholder in the expression for a literal value that is filled in at runtime using the <a href="capi3ref.html#sqlite3_bind_int">sqlite3_bind</a> API. Parameters can take several forms: </p> <p> <table> <tr> <td align="right" width="1%" nowrap> <b>?</b><i>NNN</i></td> <td width="20"> </td> <td> A question mark followed by a number <i>NNN</i> holds a spot for the NNN-th parameter. NNN must be between 1 and 999.</td> </tr> <tr> <td align="right" width="1%" nowrap> <b>?</b></td> <td width="20"> </td> <td> A question mark that is not followed by a number holds a spot for the next unused parameter.</td> </tr> <tr> <td align="right" width="1%" nowrap> <b>:</b><i>AAAA</i></td> <td width="20"> </td> <td> A colon followed by an identifier name holds a spot for a named parameter with the name AAAA. Named parameters are also numbered. The number assigned is the next unused number. To avoid confusion, it is best to avoid mixing named and numbered parameters.</td> </tr> <tr> <td align="right" width="1%" nowrap> <b>@</b><i>AAAA</i></td> <td width="20"> </td> <td> An "at" sign works exactly like a colon.</td> </tr> <tr> <td align="right" width="1%" nowrap> <b>$</b><i>AAAA</i></td> <td width="20"> </td> <td> A dollar-sign followed by an identifier name also holds a spot for a named parameter with the name AAAA. The identifier name in this case can include one or more occurances of "::" and a suffix enclosed in "(...)" containing any text at all. This syntax is the form of a variable name in the Tcl programming language.</td> </tr> </table> </p> <blockquote> </blockquote> <p> Parameters that are not assigned values using <a href="capi3ref.html#sqlite3_bind_int"> sqlite3_bind</a> are treated as NULL.</p> <a name="like"></a> <p> The LIKE operator does a pattern matching comparison. The operand to the right contains the pattern, the left hand operand contains the string to match against the pattern. A percent symbol <font color="#2c2cf0"><big>%</big></font> in the pattern matches any sequence of zero or more characters in the string. An underscore <font color="#2c2cf0"> <big>_</big></font> in the pattern matches any single character in the string. Any other character matches itself or it's lower/upper case equivalent (i.e. case-insensitive matching). (A bug: SQLite only understands upper/lower case for 7-bit Latin characters. Hence the LIKE operator is case sensitive for 8-bit iso8859 characters or UTF-8 characters. For example, the expression <b>'a' LIKE 'A'</b> is TRUE but <b>'æ' LIKE 'Æ'</b> is FALSE.).</p> <p> If the optional ESCAPE clause is present, then the expression following the ESCAPE keyword must evaluate to a string consisting of a single character. This character may be used in the LIKE pattern to include literal percent or underscore characters. The escape character followed by a percent symbol, underscore or itself matches a literal percent symbol, underscore or escape character in the string, respectively. The infix LIKE operator is implemented by calling the user function <a href="#likeFunc"> like(<i>X</i>,<i>Y</i>)</a>.</p> <p> The LIKE operator is not case sensitive and will match upper case characters on one side against lower case characters on the other. (A bug: SQLite only understands upper/lower case for 7-bit Latin characters. Hence the LIKE operator is case sensitive for 8-bit iso8859 characters or UTF-8 characters. For example, the expression <b>'a' LIKE 'A'</b> is TRUE but <b>'æ' LIKE 'Æ'</b> is FALSE.). </p> <p> </p> <p> The infix LIKE operator is implemented by calling the user function <a href="#likeFunc"> like(<i>X</i>,<i>Y</i>)</a>. If an ESCAPE clause is present, it adds a third parameter to the function call. If the functionality of LIKE can be overridden by defining an alternative implementation of the like() SQL function.</p> <p> </p> <a name="glob"></a> <p> The GLOB operator is similar to LIKE but uses the Unix file globbing syntax for its wildcards. Also, GLOB is case sensitive, unlike LIKE. Both GLOB and LIKE may be preceded by the NOT keyword to invert the sense of the test. The infix GLOB operator is implemented by calling the user function <a href="#globFunc">glob(<i>X</i>,<i>Y</i>)</a> and can be modified by overriding that function.</p> <a name="regexp"></a> <p> The REGEXP operator is a special syntax for the regexp() user function. No regexp() user function is defined by default and so use of the REGEXP operator will normally result in an error message. If a user-defined function named "regexp" is added at run-time, that function will be called in order to implement the REGEXP operator.</p> <a name="match"></a> <p> The MATCH operator is a special syntax for the match() user function. The default match() function implementation raises and exception and is not really useful for anything. But extensions can override the match() function with more helpful logic.</p> <p> A column name can be any of the names defined in the CREATE TABLE statement or one of the following special identifiers: "<b>ROWID</b>", "<b>OID</b>", or "<b>_ROWID_</b>". These special identifiers all describe the unique 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 TABLE statement does not define a real column with the same name. Row keys act like read-only columns. A row key can be used anywhere a regular column can be used, except that you cannot change the value of 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 the right-hand operand of the IN operator, as a scalar quantity, or as the operand of an EXISTS operator. As a scalar quantity or the operand of an IN operator, the SELECT should have only a single column in its result. Compound SELECTs (connected with keywords like UNION or EXCEPT) are allowed. With the EXISTS operator, the columns in the result set of the SELECT are ignored and the expression returns TRUE if one or more rows exist and FALSE if the result set is empty. If no terms in the SELECT expression refer to value in the containing query, then the expression is evaluated once prior to any other processing and the result is reused as necessary. If the SELECT expression does contain variables from the outer query, then the SELECT is reevaluated every time it is needed.</p> <p> When a SELECT is the right operand of the IN operator, the IN operator returns TRUE if the result of the left operand is any of the values generated by the select. The IN operator may be preceded by the NOT keyword to invert the sense of the test.</p> <p> When a SELECT appears within an expression but is not the right operand of an IN operator, then the first row of the result of the SELECT becomes the value used in the expression. If the SELECT yields more than one result row, all rows after the first are ignored. If the SELECT yields no rows, then the value of the SELECT is NULL.</p> <p> A CAST expression changes the datatype of the <expr> </expr> into the type specified by <type>. <type> can be any non-empty type name that is valid for the type in a column definition of a CREATE TABLE statement.</p> <p> Both simple and aggregate functions are supported. A simple function can be used in any expression. Simple functions return a result immediately based on their inputs. Aggregate functions may only be used in a SELECT statement. Aggregate functions compute their result across all rows of the result set.</p> <p> <a name="corefunctions"></a><b>Core Functions</b> </p> <p> The core functions shown below are available by default. Additional functions may be written in C and added to the database engine using the <a href="capi3ref.html#cfunc"> sqlite3_create_function()</a> API.</p> <p> <table border="0" cellpadding="10"> <tr> <td align="right" valign="top" width="1%" nowrap> abs(<i>X</i>)</td> <td valign="top"> Return the absolute value of argument <i>X</i>.</td> </tr> <tr> <td align="right" width="1%" nowrap> acos(<i>X</i>)</td> <td valign="top"> A mathematical function that returns the angle, in radians, whose cosine is the specified <b>double</b> expression</td> </tr> <tr> <td align="right" width="1%" nowrap> acosh(<i>X</i>)</td> <td valign="top"> Inverse hyperbolic cosine</td> </tr> <tr> <td align="right" width="1%" nowrap> asin(<i>X</i>)</td> <td valign="top"> Returns the angle, in radians, whose sine is the specified <b>double</b> expression</td> </tr> <tr> <td align="right" width="1%" nowrap> asinh(<i>X</i>)</td> <td valign="top"> Inverse hyperbolic sine</td> </tr> <tr> <td align="right" width="1%" nowrap> atan(<i>X</i>)</td> <td valign="top"> Returns the angle in radians whose tangent is a specified <b>double</b> expression</td> </tr> <tr> <td align="right" width="1%" nowrap> atanh(<i>X</i>)</td> <td valign="top"> Inverse hyperbolic tangent</td> </tr> <tr> <td align="right" width="1%" nowrap class="style1"> atn2(<i>X</i>,<i>Y</i>)<br /> atan2(<i>X</i>,<i>Y</i>)</td> <td valign="top" class="style1"> Returns the angle, in radians, between the positive x-axis and the ray from the origin to the point (y, x), where x and y are the values of the two specified double expressions</td> </tr> <tr> <td align="right" width="1%" nowrap> ceil(<i>X</i>)<br /> ceiling(<i>X</i>)</td> <td valign="top"> Returns the smallest integer greater than, or equal to, the specified numeric expression</td> </tr> <tr> <td align="right" width="1%" nowrap> charindex(<i>X</i>,<i>Y</i>[,<i>Z</i>])</td> <td valign="top"> Returns the 1-based position of the string <i>X</i> inside the string <i>Y</i> starting at position <i>Z</i>. Returns 0 if not <i>X</i> is not found within <i>Y</i>.</td> </tr> <tr> <td align="right" width="1%" nowrap> coalesce(<i>X</i>,<i>Y</i>,...)</td> <td valign="top"> Return a copy of the first non-NULL argument. If all arguments are NULL then NULL is returned. There must be at least 2 arguments.</td> </tr> <tr> <td align="right" width="1%" nowrap> cos(<i>X</i>)</td> <td valign="top"> a mathematical function that returns the trigonometric cosine of the specified angle, in radians, in the specified expression</td> </tr> <tr> <td align="right" width="1%" nowrap> cosh(<i>X</i>)</td> <td valign="top"> Hyperbolic cosine</td> </tr> <tr> <td align="right" width="1%" nowrap> cot(<i>X</i>)</td> <td valign="top"> A mathematical function that returns the trigonometric cotangent of the specified angle, in radians, in the specified <b>double</b> expression</td> </tr> <tr> <td align="right" width="1%" nowrap> coth(<i>X</i>)</td> <td valign="top"> <span class="h1purpose">Hyperbolic cotangent</span></td> </tr> <tr> <td align="right" width="1%" nowrap> difference(<i>X</i>,<i>Y</i>)</td> <td valign="top"> Returns an integer value that indicates the difference between the SOUNDEX values of two character expressions</td> </tr> <tr> <td align="right" width="1%" nowrap> degrees(<i>X</i>)</td> <td valign="top"> Converts radians to degrees</td> </tr> <tr> <td align="right" width="1%" nowrap> exp(<i>X</i>)</td> <td valign="top"> Returns the exponential value of the specified expression</td> </tr> <tr> <td align="right" width="1%" nowrap> floor(<i>X</i>)</td> <td valign="top"> Returns the largest integer less than or equal to the specified numeric expression</td> </tr> <tr> <a name="globFunc"></a> <td align="right" width="1%" nowrap> glob(<i>X</i>,<i>Y</i>)</td> <td valign="top"> This function is used to implement the "<b>X GLOB Y</b>" syntax of SQLite. The <a href="capi3ref.html#sqlite3_create_function">sqlite3_create_function()</a> interface can be used to override this function and thereby change the operation of the <a href="#globFunc">GLOB</a> operator.</td> </tr> <tr> <td align="right" width="1%" nowrap> ifnull(<i>X</i>,<i>Y</i>)</td> <td valign="top"> Return a copy of the first non-NULL argument. If both arguments are NULL then NULL is returned. This behaves the same as <b>coalesce()</b> above.</td> </tr> <tr> <td align="right" width="1%" nowrap> last_insert_rowid()</td> <td valign="top"> Return the ROWID of the last row insert from this connection to the database. This is the same value that would be returned from the <b>sqlite_last_insert_rowid()</b> API function.</td> </tr> <tr> <td align="right" width="1%" nowrap> last_rows_affected()</td> <td valign="top"> Returns the number of rows affected by the last insert/update operation</td> </tr> <tr> <td align="right" width="1%" nowrap> leftstr(<i>X</i>,<i>Y</i>)</td> <td valign="top"> Returns the leftmost <i>Y</i> characters in string <i>X</i>.</td> </tr> <tr> <td align="right" width="1%" nowrap> 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-8 characters is returned, not the number of bytes.</td> </tr> <tr> <a name="likeFunc"></a> <td align="right" width="1%" nowrap> like(<i>X</i>,<i>Y</i> [,<i>Z</i>])</td> <td valign="top"> This function is used to implement the "<b>X LIKE Y [ESCAPE Z]</b>" syntax of SQL. If the optional ESCAPE clause is present, then the user-function is invoked with three arguments. Otherwise, it is invoked with two arguments only. The <a href="capi3ref.html#sqlite3_create_function"> sqlite_create_function()</a> interface can be used to override this function and thereby change the operation of the <a href="#like">LIKE</a> operator. When doing this, 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.</td> </tr> <tr> <td align="right" width="1%" nowrap> load_extension(<i>X</i>)<br /> load_extension(<i>X</i>,<i>Y</i>)</td> <td valign="top"> Load SQLite extensions out of the shared library file named <i>X</i> using the entry point <i>Y</i>. The result is a NULL. If <i>Y</i> is omitted then the default entry point of <b>sqlite3_extension_init</b> is used. This function raises an exception if the extension fails to load or initialize correctly. </td> </tr> <tr> <td align="right" width="1%" nowrap> log(<i>X</i>)</td> <td valign="top"> Returns the natural logarithm of the specified <b>double</b> expression</td> </tr> <tr> <td align="right" width="1%" nowrap> log10(<i>X</i>)</td> <td valign="top"> Returns the base-10 logarithm of the specified <b>double</b> expression</td> </tr> <tr> <td align="right" width="1%" nowrap> lower(<i>X</i>)</td> <td valign="top"> Return a copy of string <i>X</i> will all characters converted to lower case. The C library <b>tolower()</b> routine is used for the conversion, which means that this function might not work correctly on UTF-8 characters.</td> </tr> <tr> <td align="right" width="1%" nowrap> max(<i>X</i>,<i>Y</i>,...)</td> <td valign="top"> Return the argument with the maximum value. Arguments may be strings in addition to numbers. The maximum value is determined by the usual sort order. Note that <b> max()</b> is a simple function when it has 2 or more arguments but converts to an aggregate function if given only a single argument.</td> </tr> <tr> <td align="right" width="1%" nowrap> min(<i>X</i>,<i>Y</i>,...)</td> <td valign="top"> Return the argument with the minimum value. Arguments may be strings in addition to numbers. The minimum value is determined by the usual sort order. Note that <b> min()</b> is a simple function when it has 2 or more arguments but converts to an aggregate function if given only a single argument.</td> </tr> <tr> <td align="right" width="1%" nowrap> 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 align="right" width="1%" nowrap> padc(<i>X</i>,<i>Y</i>)</td> <td valign="top"> Pads the given string <i>X</i> on the left and the right with spaces until it is the specified length <i>Y</i></td> </tr> <tr> <td align="right" width="1%" nowrap> padl(<i>X</i>,<i>Y</i>)</td> <td valign="top"> Pads the given string <i>X</i> on the left with spaces until it is the specified length <i>Y</i></td> </tr> <tr> <td align="right" width="1%" nowrap> padr(<i>X</i>,<i>Y</i>)</td> <td valign="top"> Pads the given string <i>X</i> on the right with spaces until it is the specified length <i>Y</i></td> </tr> <tr> <td align="right" width="1%" nowrap> pi</td> <td valign="top"> Returns the value of pi</td> </tr> <tr> <td align="right" width="1%" nowrap> power(<i>X</i>,<i>Y</i>)</td> <td valign="top"> Returns the value of the specified expression <i>X</i> to the specified power <i> Y</i></td> </tr> <tr> <td align="right" width="1%" nowrap> proper(<i>X</i>)</td> <td valign="top"> Proper-case the given string <i>X</i></td> </tr> <tr> <td align="right" width="1%" nowrap> quote(<i>X</i>)</td> <td valign="top"> This routine returns a string which is the value of its argument suitable for inclusion into another SQL statement. Strings are surrounded by single-quotes with escapes on interior quotes as needed. BLOBs are encoded as hexadecimal literals. The current implementation of VACUUM uses this function. The function is also useful when writing triggers to implement undo/redo functionality. </td> </tr> <tr> <td align="right" width="1%" nowrap> radians(<i>X</i>)</td> <td valign="top"> Converts degrees to radians</td> </tr> <tr> <td align="right" width="1%" nowrap> random(*)</td> <td valign="top"> Return a pseudo-random integer between -9223372036854775808 and +9223372036854775807.</td> </tr> <tr> <td align="right" width="1%" nowrap> replace(<i>X</i>,<i>Y</i>,<i>Z</i>)</td> <td valign="top"> Replace all occurances of <i>Y</i> inside string <i>X</i> with the replacement text <i>Z</i>. Case-sensitive.</td> </tr> <tr> <td align="right" width="1%" nowrap> replicate(<i>X</i>,<i>Y</i>)</td> <td valign="top"> Return the concatenation of string <i>X</i> repeated <i>Y</i> times</td> </tr> <tr> <td align="right" width="1%" nowrap> reverse(<i>X</i>)</td> <td valign="top"> Returns the string <i>X</i> reversed</td> </tr> <tr> <td align="right" width="1%" nowrap> rightstr(<i>X</i>,<i>Y</i>)</td> <td valign="top"> Returns the right-most <i>Y</i> characters in string <i>X</i>.</td> </tr> <tr> <td align="right" width="1%" nowrap> 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 the right of the decimal point. If the <i>Y</i> argument is omitted, 0 is assumed.</td> </tr> <tr> <td align="right" width="1%" nowrap> sign(<i>X</i>)</td> <td valign="top"> Returns the positive (+1), zero (0), or negative (-1) sign of the specified expression</td> </tr> <tr> <td align="right" width="1%" nowrap> sin(<i>X</i>)</td> <td valign="top"> Returns the trigonometric sine of the specified angle, in radians, and in an approximate numeric, <b>double</b>, expression</td> </tr> <tr> <td align="right" width="1%" nowrap> 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.</td> </tr> <tr> <td align="right" width="1%" nowrap> sqlite_version(*)</td> <td valign="top"> Return the version string for the SQLite library that is running. Example: "3.6.0"</td> </tr> <tr> <td align="right" width="1%" nowrap> sqrt(<i>X</i>)</td> <td valign="top"> Returns the square root of the specified value</td> </tr> <tr> <td align="right" width="1%" nowrap> square(X)</td> <td valign="top"> Returns the square of the specified value</td> </tr> <tr> <td align="right" width="1%" nowrap> strfilter(<i>X</i>,<i>Y</i>)</td> <td valign="top"> Given a source string <i>X</i> and the characters to filter <i>Y</i>, returns <i> X</i> with all characters not found in <i>Y</i> removed.</td> </tr> <tr> <td align="right" width="1%" nowrap> substr(<i>X</i>,<i>Y</i>,<i>Z</i>)</td> <td valign="top"> Return a substring of input string <i>X</i> that begins with 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 negative the the first character of the substring is found by counting from the right 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 align="right" width="1%" nowrap> tan(<i>X</i>)</td> <td valign="top"> Returns the tangent of the input expression</td> </tr> <tr> <td align="right" width="1%" nowrap> tanh(<i>X</i>)</td> <td valign="top"> Hyperbolic tangent</td> </tr> <tr> <td align="right" width="1%" nowrap> typeof(<i>X</i>)</td> <td valign="top"> Return the type of the expression <i>X</i>. The only return values are "null", "integer", "real", "text", and "blob". SQLite's type handling is explained in <a href="http://www.sqlite.org/datatype3.html"> Datatypes in SQLite Version 3</a>.</td> </tr> <tr> <td align="right" width="1%" nowrap> upper(<i>X</i>)</td> <td valign="top"> Return a copy of input string <i>X</i> converted to all upper-case letters. The implementation of this function uses the C library routine <b>toupper()</b> which means it may not work correctly on UTF-8 strings.</td> </tr> </table> </p> <p> <a name="aggregatefunctions"></a><b>Aggregate Functions</b> </p> <p> The aggregate functions shown below are available by default. Additional aggregate functions written in C may be added using the <a href="capi3ref.html#sqlite3_create_function"> sqlite3_create_function()</a> API.</p> <p> In any aggregate function that takes a single argument, that argument can be preceeded by the keyword DISTINCT. In such cases, duplicate elements are filtered before being passed into the aggregate function. 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. </p> <p> <table border="0" cellpadding="10"> <tr> <td align="right" valign="top" width="120"> avg(<i>X</i>)</td> <td valign="top"> Return the average value of all non-NULL <i>X</i> 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 even if all inputs are integers. <p> </p> </td> </tr> <tr> <td align="right" width="1%" nowrap> count(<i>X</i>)<br /> count(*)</td> <td valign="top"> The first form return a count of the number of times that <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 align="right" width="1%" nowrap> lower_quartile(<i>X</i>)</td> <td valign="top"> Returns the lower quartile of the given numbers in the set</td> </tr> <tr> <td align="right" width="1%" nowrap> 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 align="right" width="1%" nowrap> median(<i>X</i>)</td> <td valign="top"> Returns the middle value in a set of ordered numbers. (The medial value is unlike the mean value, which is the sum of a set of numbers divided by the count of numbers in the set). The median value is determined by choosing the smallest value such that at least half of the values in the set are no greater than the chosen value. If the number of values within the set is odd, the median value corresponds to a single value. If the number of values within the set is even, the median value corresponds to the sum of the two middle values divided by two.</td> </tr> <tr> <td align="right" width="1%" nowrap> min(<i>X</i>)</td> <td valign="top"> Return the minimum non-NULL value of all values in the group. The usual sort order is used to determine the minimum. NULL is only returned if all values in the group are NULL.</td> </tr> <tr> <td align="right" width="1%" nowrap> mode(<i>X</i>)</td> <td valign="top"> Computes the most frequently occurring value in a sample set</td> </tr> <tr> <td align="right" width="1%" nowrap> stdev(<i>X</i>)</td> <td valign="top"> Returns the statistical standard deviation of all values in the specified expression</td> </tr> <tr> <td align="right" width="1%" nowrap> sum(<i>X</i>)<br /> total(<i>X</i>)</td> <td valign="top"> Return the numeric 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 but the SQL standard requires it and most other SQL database engines implement sum() that way so SQLite does it in the same way in order to be compatible. The non-standard total() function is provided as a convenient way to work around this design problem in the SQL language. <p> </p> <p> The result of total() is always a floating point value. The result of sum() is an integer value if all non-NULL inputs are integers. If any input to sum() is neither an integer or a NULL then sum() returns a floating point value which might be an approximation to the true sum.</p> <p> 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 exception.</p> </td> </tr> <tr> <td align="right" width="1%" nowrap> upper_quartile(<i>X</i>)</td> <td valign="top"> Returns the upper quartile of the numbers in the given set</td> </tr> </table> </p> <hr> <div id="footer"> <p> </p> <p> </p> </div> </div> </div> </body> </html> |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html><head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>SQLite Query Language: expression</title> <style type="text/css"> body { margin: auto; font-family: Verdana, sans-serif; padding: 8px 1%; } a { color: #044a64 } a:visited { color: #734559 } .logo { position:absolute; margin:3px; } .tagline { float:right; text-align:right; font-style:italic; width:300px; margin:12px; margin-top:58px; } .menubar { clear: both; border-radius: 8px; background: #044a64; padding: 0px; margin: 0px; cell-spacing: 0px; } .toolbar { text-align: center; line-height: 1.6em; margin: 0; padding: 0px 8px; } .toolbar a { color: white; text-decoration: none; padding: 6px 12px; } .toolbar a:visited { color: white; } .toolbar a:hover { color: #044a64; background: white; } .content { margin: 5%; } .content dt { font-weight:bold; } .content dd { margin-bottom: 25px; margin-left:20%; } .content ul { padding:0px; padding-left: 15px; margin:0px; } /* Things for "fancyformat" documents start here. */ .fancy img+p {font-style:italic} .fancy .codeblock i { color: darkblue; } .fancy h1,.fancy h2,.fancy h3,.fancy h4 {font-weight:normal;color:#044a64} .fancy h2 { margin-left: 10px } .fancy h3 { margin-left: 20px } .fancy h4 { margin-left: 30px } .fancy th {white-space:nowrap;text-align:left;border-bottom:solid 1px #444} .fancy th, .fancy td {padding: 0.2em 1ex; vertical-align:top} .fancy #toc a { color: darkblue ; text-decoration: none } .fancy .todo { color: #AA3333 ; font-style : italic } .fancy .todo:before { content: 'TODO:' } .fancy p.todo { border: solid #AA3333 1px; padding: 1ex } .fancy img { display:block; } .fancy :link:hover, .fancy :visited:hover { background: wheat } .fancy p,.fancy ul,.fancy ol { margin: 1em 5ex } .fancy li p { margin: 1em 0 } /* End of "fancyformat" specific rules. */ </style> </head> <body> <div><!-- container div to satisfy validator --> <a href="index.html"> <img class="logo" src="images/sqlite370_banner.gif" alt="SQLite Logo" border="0"></a> <div><!-- IE hack to prevent disappearing logo--></div> <div class="tagline">Small. Fast. Reliable.<br>Choose any three.</div> <table width=100% class="menubar"><tr> <td width=100%> <div class="toolbar"> <a href="about.html">About</a> <a href="sitemap.html">Sitemap</a> <a href="docs.html">Documentation</a> <a href="download.html">Download</a> <a href="copyright.html">License</a> <a href="news.html">News</a> <a href="support.html">Support</a> </div> <script> gMsg = "Search SQLite Docs..." function entersearch() { var q = document.getElementById("q"); if( q.value == gMsg ) { q.value = "" } q.style.color = "black" q.style.fontStyle = "normal" } function leavesearch() { var q = document.getElementById("q"); if( q.value == "" ) { q.value = gMsg q.style.color = "#044a64" q.style.fontStyle = "italic" } } function hideorshow(btn,obj){ var x = document.getElementById(obj); var b = document.getElementById(btn); if( x.style.display!='none' ){ x.style.display = 'none'; b.innerHTML='show'; }else{ x.style.display = ''; b.innerHTML='hide'; } return false; } </script> <td> <div style="padding:0 1em 0px 0;white-space:nowrap"> <form name=f method="GET" action="http://www.sqlite.org/search"> <input id=q name=q type=text onfocus="entersearch()" onblur="leavesearch()" style="width:24ex;padding:1px 1ex; border:solid white 1px; font-size:0.9em ; font-style:italic;color:#044a64;" value="Search SQLite Docs..."> <input type=submit value="Go" style="border:solid white 1px;background-color:#044a64;color:white;font-size:0.9em;padding:0 1ex"> </form> </div> </table> <div class=startsearch></div> <h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>expression</h2><p><b><a href="syntaxdiagrams.html#expr">expr:</a></b> <button id='x1055' onclick='hideorshow("x1055","x1056")'>hide</button></p> <blockquote id='x1056'> <img alt="syntax diagram expr" src="images/syntax/expr.gif" /> <p><b><a href="syntaxdiagrams.html#literal-value">literal-value:</a></b> <button id='x1057' onclick='hideorshow("x1057","x1058")'>show</button></p> <blockquote id='x1058' style='display:none;'> <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#raise-function">raise-function:</a></b> <button id='x1059' onclick='hideorshow("x1059","x1060")'>show</button></p> <blockquote id='x1060' style='display:none;'> <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#select-stmt">select-stmt:</a></b> <button id='x1061' onclick='hideorshow("x1061","x1062")'>show</button></p> <blockquote id='x1062' style='display:none;'> <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" /> <p><b><a href="syntaxdiagrams.html#common-table-expression">common-table-expression:</a></b> <button id='x1063' onclick='hideorshow("x1063","x1064")'>show</button></p> <blockquote id='x1064' style='display:none;'> <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#compound-operator">compound-operator:</a></b> <button id='x1065' onclick='hideorshow("x1065","x1066")'>show</button></p> <blockquote id='x1066' style='display:none;'> <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#join-clause">join-clause:</a></b> <button id='x1067' onclick='hideorshow("x1067","x1068")'>show</button></p> <blockquote id='x1068' style='display:none;'> <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" /> <p><b><a href="syntaxdiagrams.html#join-constraint">join-constraint:</a></b> <button id='x1069' onclick='hideorshow("x1069","x1070")'>show</button></p> <blockquote id='x1070' style='display:none;'> <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#join-operator">join-operator:</a></b> <button id='x1071' onclick='hideorshow("x1071","x1072")'>show</button></p> <blockquote id='x1072' style='display:none;'> <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" /> </blockquote> </blockquote> <p><b><a href="syntaxdiagrams.html#ordering-term">ordering-term:</a></b> <button id='x1073' onclick='hideorshow("x1073","x1074")'>show</button></p> <blockquote id='x1074' style='display:none;'> <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#result-column">result-column:</a></b> <button id='x1075' onclick='hideorshow("x1075","x1076")'>show</button></p> <blockquote id='x1076' style='display:none;'> <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#table-or-subquery">table-or-subquery:</a></b> <button id='x1077' onclick='hideorshow("x1077","x1078")'>show</button></p> <blockquote id='x1078' style='display:none;'> <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" /> </blockquote> </blockquote> <p><b><a href="syntaxdiagrams.html#type-name">type-name:</a></b> <button id='x1079' onclick='hideorshow("x1079","x1080")'>show</button></p> <blockquote id='x1080' style='display:none;'> <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" /> <p><b><a href="syntaxdiagrams.html#signed-number">signed-number:</a></b> <button id='x1081' onclick='hideorshow("x1081","x1082")'>show</button></p> <blockquote id='x1082' style='display:none;'> <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" /> </blockquote> </blockquote> </blockquote> <p>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 subcomponents of most other commands.</p> <a name="binaryops"></a> <h3>Operators</h3> <p>SQLite understands the following binary operators, in order from highest to lowest precedence:</p> <blockquote><pre> <font color="#2c2cf0"><big>|| * / % + - << >> & | < <= > >= = == != <> </big>IS IS NOT IN LIKE GLOB MATCH REGEXP AND OR</font> </pre></blockquote> <p>Supported unary prefix operators are these:</p> <blockquote><pre> <font color="#2c2cf0"><big>- + ~ NOT</big></font> </pre></blockquote> <a name="collateop"></a> <p>The COLLATE operator is a unary postfix operator that assigns a <a href="datatype3.html#collation">collating sequence</a> to an expression. The COLLATE operator has a higher precedence (binds more tightly) than any binary operator and any unary prefix operator except "~". (COLLATE and "~" are associative so their binding order does not matter.) The collating sequence set by the COLLATE operator overrides the collating sequence determined by the COLLATE clause in a table <a href="lang_createtable.html#tablecoldef">column definition</a>. See the <a href="datatype3.html#collation">detailed discussion on collating sequences</a> in the <a href="datatype3.html">Datatype In SQLite3</a> document for additional information. </p> <p>The unary operator <font color="#2c2cf0"><big>+</big></font> is a no-op. It can be applied to strings, numbers, blobs or NULL and it always returns a result with the same value as the operand.</p> <p>Note that there are two variations of the equals and not equals operators. Equals can be either <font color="#2c2cf0"><big>=</big></font> or <font color="#2c2cf0"><big>==</big></font>. The non-equals operator can be either <font color="#2c2cf0"><big>!=</big></font> or <font color="#2c2cf0"><big><></big></font>. The <font color="#2c2cf0"><big>||</big></font> operator is "concatenate" - it joins together the two strings of its operands. The operator <font color="#2c2cf0"><big>%</big></font> outputs the value of its left operand modulo its right operand.</p> <p>The result of any binary operator is either a numeric value or NULL, except for the <font color="#2c2cf0"><big>||</big></font> concatenation operator which always evaluates to either NULL or a text value.</p><a name="isisnot"></a> <p>The <font color="#2c2cf0"><big>IS</big></font> and <font color="#2c2cf0"><big>IS NOT</big></font> operators work like <font color="#2c2cf0"><big>=</big></font> and <font color="#2c2cf0"><big>!=</big></font> except when one or both of the operands are NULL. In this case, if both operands are NULL, then the IS operator evaluates to 1 (true) and the IS NOT operator evaluates to 0 (false). If one operand is NULL and the other is not, then the IS operator evaluates to 0 (false) and the IS NOT operator is 1 (true). It is not possible for an IS or IS NOT expression to evaluate to NULL. Operators <font color="#2c2cf0"><big>IS</big></font> and <font color="#2c2cf0"><big>IS NOT</big></font> have the same precedence as <font color="#2c2cf0"><big>=</big></font>.<a name="litvalue"></a> <h3>Literal Values</h3> <p> A literal value is a constant of some kind. Literal values may be integers, floating point numbers, strings, BLOBs, or NULLs.</p> <p>The syntax for integer and floating point literals (collectively "numeric literals") is shown by the following diagram:</p> <p><b><a href="syntaxdiagrams.html#numeric-literal">numeric-literal:</a></b></p><blockquote> <img alt="syntax diagram numeric-literal" src="images/syntax/numeric-literal.gif"></img> </blockquote> <p> If a numeric literal has a decimal point or an exponentiation clause, then it is a floating point literal. Otherwise is it is an integer literal. The "E" character that begins the exponentiation clause of a floating point literal can be either upper or lower case. The "." character is always used as the decimal point even if the locale setting specifies "," for this role - the use of "," for the decimal point would result in syntactic ambiguity.</p> <p> A string constant is formed by enclosing the string in single quotes ('). A single quote within the string can be encoded by putting two single quotes in a row - as in Pascal. C-style escapes using the backslash character are not supported because they are not standard SQL. BLOB literals are string literals containing hexadecimal data and preceded by a single "x" or "X" character. For example:</p> <blockquote><pre> X'53514C697465' </pre></blockquote> <p> A literal value can also be the token "NULL". </p> <a name="varparam"></a> <h3>Parameters</h3> <p> A "variable" or "parameter" token specifies a placeholder in the expression for a value that is filled in at runtime using the <a href="c3ref/bind_blob.html">sqlite3_bind()</a> family of C/C++ interfaces. Parameters can take several forms: </p> <blockquote> <table> <tr> <td align="right" valign="top"><b>?</b><i>NNN</i></td><td width="20"></td> <td>A question mark followed by a number <i>NNN</i> holds a spot for the NNN-th parameter. NNN must be between 1 and <a href="limits.html#max_variable_number">SQLITE_MAX_VARIABLE_NUMBER</a>. </td> </tr> <tr> <td align="right" valign="top"><b>?</b></td><td width="20"></td> <td>A question mark that is not followed by a number creates a parameter with a number one greater than the largest parameter number already assigned. If this means the parameter number is greater than <a href="limits.html#max_variable_number">SQLITE_MAX_VARIABLE_NUMBER</a>, it is an error. </td> </tr> <tr> <td align="right" valign="top"><b>:</b><i>AAAA</i></td><td width="20"></td> <td>A colon followed by an identifier name holds a spot for a <a href="c3ref/bind_parameter_name.html">named parameter</a> with the name :AAAA. Named parameters are also numbered. The number assigned is one greater than the largest parameter number already assigned. If this means the parameter would be assigned a number greater than <a href="limits.html#max_variable_number">SQLITE_MAX_VARIABLE_NUMBER</a>, it is an error. To avoid confusion, it is best to avoid mixing named and numbered parameters.</td> </tr> <tr> <td align="right" valign="top"><b>@</b><i>AAAA</i></td><td width="20"></td> <td>An "at" sign works exactly like a colon, except that the name of the parameter created is @AAAA.</td> </tr> <tr> <td align="right" valign="top"><b>$</b><i>AAAA</i></td><td width="20"></td> <td>A dollar-sign followed by an identifier name also holds a spot for a named parameter with the name $AAAA. The identifier name in this case can include one or more occurrences of "::" and a suffix enclosed in "(...)" containing any text at all. This syntax is the form of a variable name in the <a href="http://www.tcl.tk/">Tcl programming language</a>. The presence of this syntax results from the fact that SQLite is really a <a href="tclsqlite.html">Tcl extension</a> that has escaped into the wild.</td> </tr> </table> </blockquote> <p>Parameters that are not assigned values using <a href="c3ref/bind_blob.html">sqlite3_bind()</a> are treated as NULL.</p> <p>The maximum parameter number is set at compile-time by the <a href="limits.html#max_variable_number">SQLITE_MAX_VARIABLE_NUMBER</a> macro. An individual <a href="c3ref/sqlite3.html">database connections</a> D can reduce its maximum parameter number below the compile-time maximum using the <a href="c3ref/limit.html">sqlite3_limit</a>(D, <a href="c3ref/c_limit_attached.html#sqlitelimitvariablenumber">SQLITE_LIMIT_VARIABLE_NUMBER</a>,...) interface. </p> <a name="like"></a> <h3>The LIKE and GLOB operators</h3> <p>The LIKE operator does a pattern matching comparison. The operand to the right of the LIKE operator contains the pattern and the left hand operand contains the string to match against the pattern. A percent symbol ("%") in the LIKE pattern matches any sequence of zero or more characters in the string. An underscore ("_") in the LIKE pattern matches any single character in the string. Any other character matches itself or its lower/upper case equivalent (i.e. case-insensitive matching). (A bug: SQLite only understands upper/lower case for ASCII characters by default. The LIKE operator is case sensitive by default for unicode characters that are beyond the ASCII range. For example, the expression <b>'a' LIKE 'A'</b> is TRUE but <b>'æ' LIKE 'Æ'</b> is FALSE.)<p> <p>If the optional ESCAPE clause is present, then the expression following the ESCAPE keyword must evaluate to a string consisting of a single character. This character may be used in the LIKE pattern to include literal percent or underscore characters. The escape character followed by a percent symbol (%), underscore (_), or a second instance of the escape character itself matches a literal percent symbol, underscore, or a single escape character, respectively. <p>The infix LIKE operator is implemented by calling the application-defined SQL functions <a href="lang_corefunc.html#like">like(<i>Y</i>,<i>X</i>)</a> or <a href="lang_corefunc.html#like">like(<i>Y</i>,<i>X</i>,<i>Z</i>)</a></a>.</p> <p>The LIKE operator can be made case sensitive using the <a href="pragma.html#pragma_case_sensitive_like">case_sensitive_like pragma</a>.</p> <a name="glob"></a> <p>The GLOB operator is similar to LIKE but uses the Unix file globbing syntax for its wildcards. Also, GLOB is case sensitive, unlike LIKE. Both GLOB and LIKE may be preceded by the NOT keyword to invert the sense of the test. The infix GLOB operator is implemented by calling the function <a href="lang_corefunc.html#glob">glob(<i>Y</i>,<i>X</i>)</a> and can be modified by overriding that function.</p> <a name="regexp"></a> <p>The REGEXP operator is a special syntax for the regexp() user function. No regexp() user function is defined by default and so use of the REGEXP operator will normally result in an error message. If an <a href="c3ref/create_function.html">application-defined SQL function</a> named "regexp" is added at run-time, then the "<i>X</i> REGEXP <i>Y</i>" operator will be implemented as a call to "regexp(<i>Y</i>,<i>X</i>)".</p> <a name="match"></a> <p>The MATCH operator is a special syntax for the match() application-defined function. The default match() function implementation raises an exception and is not really useful for anything. But extensions can override the match() function with more helpful logic.</p> <a name="between"></a> <h3>The BETWEEN operator</h3> <p>The BETWEEN operator is logically equivalent to a pair of comparisons. "<i>x</i> <b>BETWEEN</b> <i>y</i> <b>AND</b> <i>z</i>" is equivalent to "<i>x</i><b>>=</b><i>y</i> <b>AND</b> <i>x</i><b><=</b><i>z</i>" except that with BETWEEN, the <i>x</i> expression is only evaluated once. The precedence of the BETWEEN operator is the same as the precedence as operators <b>==</b> and <b>!=</b> and <b>LIKE</b> and groups left to right. <a name="case"></a> <h3>The CASE expression</h3> <p>A CASE expression serves a role similar to IF-THEN-ELSE in other programming languages. <p>The optional expression that occurs in between the CASE keyword and the first WHEN keyword is called the "base" expression. There are two basic forms of the CASE expression: those with a base expression and those without. <p>In a CASE without a base expression, each WHEN expression is evaluated and the result treated as a boolean, starting with the leftmost and continuing to the right. The result of the CASE expression is the evaluation of the THEN expression that corresponds to the first WHEN expression that evaluates to true. Or, if none of the WHEN expressions evaluate to true, the result of evaluating the ELSE expression, if any. If there is no ELSE expression and none of the WHEN expressions are true, then the overall result is NULL. <p>A NULL result is considered untrue when evaluating WHEN terms. <p>In a CASE with a base expression, the base expression is evaluated just once and the result is compared against the evaluation of each WHEN expression from left to right. The result of the CASE expression is the evaluation of the THEN expression that corresponds to the first WHEN expression for which the comparison is true. Or, if none of the WHEN expressions evaluate to a value equal to the base expression, the result of evaluating the ELSE expression, if any. If there is no ELSE expression and none of the WHEN expressions produce a result equal to the base expression, the overall result is NULL. <p>When comparing a base expression against a WHEN expression, the same collating sequence, affinity, and NULL-handling rules apply as if the base expression and WHEN expression are respectively the left- and right-hand operands of an <big><b>=</b></big> operator.</p> If the base expression is NULL then the result of the CASE is always the result of evaluating the ELSE expression if it exists, or NULL if it does not. <p>Both forms of the CASE expression use lazy, or short-circuit, evaluation. <p>The only difference between the following two CASE expressions is that the <i>x</i> expression is evaluated exactly once in the first example but might be evaluated multiple times in the second: <ul><pre> <li>CASE x WHEN w1 THEN r1 WHEN w2 THEN r2 ELSE r3 END <li>CASE WHEN x=w1 THEN r1 WHEN x=w2 THEN r2 ELSE r3 END </pre></ul> <a name="in_op"></a> <h3>The IN and NOT IN operators</h3> <p>The IN and NOT IN operators take a single scalar operand on the left and a vector operand on the right formed by an explicit list of zero or more scalars or by a single subquery. When the right operand of an IN or NOT IN operator is a subquery, the subquery must have a single result column. When the right operand is an empty set, the result of IN is false and the result of NOT IN is true, regardless of the left operand and even if the left operand is NULL. The result of an IN or NOT IN operator is determined by the following matrix: <center> <table border=1> <tr> <th>Left operand <br>is NULL <th>Right operand <br>contains NULL <th>Right operand <br>is an empty set <th>Left operand found <br>within right operand <th>Result of <br>IN operator <th>Result of <br>NOT IN operator <tr> <td align="center">no <td align="center">no <td align="center">no <td align="center">no <td align="center">false <td align="center">true <tr> <td align="center">does not matter <td align="center">no <td align="center">yes <td align="center">no <td align="center">false <td align="center">true <tr> <td align="center">no <td align="center">does not matter <td align="center">no <td align="center">yes <td align="center">true <td align="center">false <tr> <td align="center">no <td align="center">yes <td align="center">no <td align="center">no <td align="center">NULL <td align="center">NULL <tr> <td align="center">yes <td align="center">does not matter <td align="center">no <td align="center">does not matter <td align="center">NULL <td align="center">NULL </table> </center> <p>Note that SQLite allows the parenthesized list of scalar values on the right-hand side of an IN or NOT IN operator to be an empty list but most other SQL database database engines and the SQL92 standard require the list to contain at least one element.</p> <a name="in_op"></a> <h3>The EXISTS operator</h3> <p>The EXISTS operator always evaluates to one of the integer values 0 and 1. If executing the SELECT statement specified as the right-hand operand of the EXISTS operator would return one or more rows, then the EXISTS operator evaluates to 1. If executing the SELECT would return no rows at all, then the EXISTS operator evaluates to 0. <p>The number of columns in each row returned by the SELECT statement (if any) and the specific values returned have no effect on the results of the EXISTS operator. In particular, rows containing NULL values are not handled any differently from rows without NULL values. <h3>Scalar Subqueries</h3> <p>A <a href="lang_select.html">SELECT</a> statement enclosed in parentheses may appear as a scalar quantity. A <a href="lang_select.html">SELECT</a> used as a scalar quantity must return a result set with a single column. The result of the expression is the value of the only column in the first row returned by the SELECT statement. If the SELECT yields more than one result row, all rows after the first are ignored. If the SELECT yields no rows, then the value of the expression is NULL. The LIMIT of a scalar subquery is always 1. Any other LIMIT value given in the SQL text is ignored. <p>All types of <a href="lang_select.html">SELECT</a> statement, including aggregate and <a href="lang_select.html#compound">compound SELECT</a> queries (queries with keywords like UNION or EXCEPT) are allowed as scalar subqueries. <h3>Table Column Names</h3> <p>A column name can be any of the names defined in the <a href="lang_createtable.html">CREATE TABLE</a> statement or one of the following special identifiers: "<b>ROWID</b>", "<b>OID</b>", or "<b>_ROWID_</b>". These special identifiers all describe the unique integer key (the <a href="lang_createtable.html#rowid">rowid</a>) associated with every row of every table. The special identifiers only refer to the row key if the <a href="lang_createtable.html">CREATE TABLE</a> statement does not define a real column with the same name. The rowid can be used anywhere a regular column can be used.</p> <p>A <a href="lang_select.html">SELECT</a> statement used as either a scalar subquery or as the right-hand operand of an IN, NOT IN or EXISTS expression may contain references to columns in the outer query. Such a subquery is known as a correlated subquery. A correlated subquery is reevaluated each time its result is required. An uncorrelated subquery is evaluated only once and the result reused as necessary. <a name="castexpr"></a> <h3>CAST expressions</h3> <p>A CAST expression of the form "CAST(<expr> AS <type-name>)" is used to convert the value of <expr> to a different <a href="datatype3.html#storageclasses">storage class</a> specified by <type-name>. A CAST conversion is similar to the conversion that takes place when a <a href="datatype3.html#affinity">column affinity</a> is applied to a value except that with the CAST operator the conversion always takes place even if the conversion lossy and irreversible, whereas column affinity only changes the data type of a value if the change is lossless and reversible. <p>If the value of <expr> is NULL, then the result of the CAST expression is also NULL. Otherwise, the storage class of the result is determined by applying the <a href="datatype3.html#affname">rules for determining column affinity</a> to the <type-name>. <table border=1> <tr> <th> Affinity of <type-name> <th> Conversion Processing <tr> <td> NONE <td> Casting a value to a <type-name> with no affinity causes the value to be converted into a BLOB. Casting to a BLOB consists of first casting the value to TEXT in the <a href="pragma.html#pragma_encoding">encoding</a> of the database connection, then interpreting the resulting byte sequence as a BLOB instead of as TEXT. <tr> <td> TEXT <td> To cast a BLOB value to TEXT, the sequence of bytes that make up the BLOB is interpreted as text encoded using the database encoding. <p> Casting an INTEGER or REAL value into TEXT renders the value as if via <a href="c3ref/mprintf.html">sqlite3_snprintf()</a> except that the resulting TEXT uses the <a href="pragma.html#pragma_encoding">encoding</a> of the database connection. <tr> <td> REAL <td> When casting a BLOB value to a REAL, the value is first converted to TEXT. <p>When casting a TEXT value to REAL, the longest possible prefix of the value that can be interpreted as a real number is extracted from the TEXT value and the remainder ignored. Any leading spaces in the TEXT value are ignored when converging from TEXT to REAL. If there is no prefix that can be interpreted as a real number, the result of the conversion is 0.0. <tr> <td> INTEGER <td> When casting a BLOB value to INTEGER, the value is first converted to TEXT. <p>When casting a TEXT value to INTEGER, the longest possible prefix of the value that can be interpreted as an integer number is extracted from the TEXT value and the remainder ignored. Any leading spaces in the TEXT value when converting from TEXT to INTEGER are ignored. If there is no prefix that can be interpreted as an integer number, the result of the conversion is 0. <p>A cast of a REAL value into an INTEGER results in the integer between the REAL value and zero that is closest to the REAL value. If a REAL is greater than the greatest possible signed integer (+9223372036854775807) then the result is the greatest possible signed integer and if the REAL is less than the least possible signed integer (-9223372036854775808) then the result is the least possible signed integer. <p>Prior to SQLite version 3.8.2, casting a REAL value greater than +9223372036854775807.0 into an integer resulted in the most negative integer, -9223372036854775808. This behavior was meant to emulate the behavior of x86/x64 hardware when doing the equivalent cast. <tr> <td> NUMERIC <td> Casting a TEXT or BLOB value into NUMERIC first does a forced conversion into REAL but then further converts the result into INTEGER if and only if the conversion from REAL to INTEGER is lossless and reversible. This is the only context in SQLite where the NUMERIC and INTEGER <a href="datatype3.html#affinity">affinities</a> behave differently. <p> Casting a REAL or INTEGER value to NUMERIC is a no-op, even if a real value could be losslessly converted to an integer. </tr> </table> <p>Note that the result from casting any non-BLOB value into a BLOB and the result from casting any BLOB value into a non-BLOB value may be different depending on whether the database <a href="pragma.html#pragma_encoding">encoding</a> is UTF-8, UTF-16be, or UTF-16le. <a name="booleanexpr"></a> <h3>Boolean Expressions</h3> <p>The SQL language features several contexts where an expression is evaluated and the result converted to a boolean (true or false) value. These contexts are: <ul> <li> the WHERE clause of a SELECT, UPDATE or DELETE statement, <li> the ON or USING clause of a join in a SELECT statement, <li> the HAVING clause of a SELECT statement, <li> the WHEN clause of an SQL trigger, and <li> the WHEN clause or clauses of some CASE expressions. </ul> <p>To convert the results of an SQL expression to a boolean value, SQLite first casts the result to a NUMERIC value in the same way as a <a href="lang_expr.html#castexpr">CAST expression</a>. A NULL or zero value (integer value 0 or real value 0.0) is considered to be false. All other values are considered true. <p>For example, the values NULL, 0.0, 0, 'english' and '0' are all considered to be false. Values 1, 1.0, 0.1, -0.1 and '1english' are considered to be true. <h3>Functions</h3> <p>Both <a href="lang_corefunc.html">simple</a> and <a href="lang_aggfunc.html">aggregate</a> functions are supported. (For presentation purposes, simple functions are further subdivided into <a href="lang_corefunc.html">core functions</a> and <a href="lang_datefunc.html">date-time functions</a>.) A simple function can be used in any expression. Simple functions return a result immediately based on their inputs. Aggregate functions may only be used in a SELECT statement. Aggregate functions compute their result across all rows of the result set.</p> |
Added Doc/Extra/Core/lang_indexedby.html.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html><head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>SQLite Query Language: INDEXED BY</title> <style type="text/css"> body { margin: auto; font-family: Verdana, sans-serif; padding: 8px 1%; } a { color: #044a64 } a:visited { color: #734559 } .logo { position:absolute; margin:3px; } .tagline { float:right; text-align:right; font-style:italic; width:300px; margin:12px; margin-top:58px; } .menubar { clear: both; border-radius: 8px; background: #044a64; padding: 0px; margin: 0px; cell-spacing: 0px; } .toolbar { text-align: center; line-height: 1.6em; margin: 0; padding: 0px 8px; } .toolbar a { color: white; text-decoration: none; padding: 6px 12px; } .toolbar a:visited { color: white; } .toolbar a:hover { color: #044a64; background: white; } .content { margin: 5%; } .content dt { font-weight:bold; } .content dd { margin-bottom: 25px; margin-left:20%; } .content ul { padding:0px; padding-left: 15px; margin:0px; } /* Things for "fancyformat" documents start here. */ .fancy img+p {font-style:italic} .fancy .codeblock i { color: darkblue; } .fancy h1,.fancy h2,.fancy h3,.fancy h4 {font-weight:normal;color:#044a64} .fancy h2 { margin-left: 10px } .fancy h3 { margin-left: 20px } .fancy h4 { margin-left: 30px } .fancy th {white-space:nowrap;text-align:left;border-bottom:solid 1px #444} .fancy th, .fancy td {padding: 0.2em 1ex; vertical-align:top} .fancy #toc a { color: darkblue ; text-decoration: none } .fancy .todo { color: #AA3333 ; font-style : italic } .fancy .todo:before { content: 'TODO:' } .fancy p.todo { border: solid #AA3333 1px; padding: 1ex } .fancy img { display:block; } .fancy :link:hover, .fancy :visited:hover { background: wheat } .fancy p,.fancy ul,.fancy ol { margin: 1em 5ex } .fancy li p { margin: 1em 0 } /* End of "fancyformat" specific rules. */ </style> </head> <body> <div><!-- container div to satisfy validator --> <a href="index.html"> <img class="logo" src="images/sqlite370_banner.gif" alt="SQLite Logo" border="0"></a> <div><!-- IE hack to prevent disappearing logo--></div> <div class="tagline">Small. Fast. Reliable.<br>Choose any three.</div> <table width=100% class="menubar"><tr> <td width=100%> <div class="toolbar"> <a href="about.html">About</a> <a href="sitemap.html">Sitemap</a> <a href="docs.html">Documentation</a> <a href="download.html">Download</a> <a href="copyright.html">License</a> <a href="news.html">News</a> <a href="support.html">Support</a> </div> <script> gMsg = "Search SQLite Docs..." function entersearch() { var q = document.getElementById("q"); if( q.value == gMsg ) { q.value = "" } q.style.color = "black" q.style.fontStyle = "normal" } function leavesearch() { var q = document.getElementById("q"); if( q.value == "" ) { q.value = gMsg q.style.color = "#044a64" q.style.fontStyle = "italic" } } function hideorshow(btn,obj){ var x = document.getElementById(obj); var b = document.getElementById(btn); if( x.style.display!='none' ){ x.style.display = 'none'; b.innerHTML='show'; }else{ x.style.display = ''; b.innerHTML='hide'; } return false; } </script> <td> <div style="padding:0 1em 0px 0;white-space:nowrap"> <form name=f method="GET" action="http://www.sqlite.org/search"> <input id=q name=q type=text onfocus="entersearch()" onblur="leavesearch()" style="width:24ex;padding:1px 1ex; border:solid white 1px; font-size:0.9em ; font-style:italic;color:#044a64;" value="Search SQLite Docs..."> <input type=submit value="Go" style="border:solid white 1px;background-color:#044a64;color:white;font-size:0.9em;padding:0 1ex"> </form> </div> </table> <div class=startsearch></div> <h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>INDEXED BY</h2> <p>The INDEXED BY phrase forces the <a href="optoverview.html">SQLite query planner</a> to use a particular named index on a <a href="lang_delete.html">DELETE</a>, <a href="lang_select.html">SELECT</a>, or <a href="lang_update.html">UPDATE</a> statement. The INDEXED BY phrase is an extension that is particular to SQLite and is not portable to other SQL database engines. The INDEXED BY phrase can be seen in the following syntax diagrams:</p> <p><b><a href="syntaxdiagrams.html#qualified-table-name">qualified-table-name:</a></b> <button id='x1417' onclick='hideorshow("x1417","x1418")'>hide</button></p> <blockquote id='x1418'> <img alt="syntax diagram qualified-table-name" src="images/syntax/qualified-table-name.gif" /> </blockquote> <p>The "INDEXED BY index-name" phrase specifies that the named index must be used in order to look up values on the preceding table. If index-name does not exist or cannot be used for the query, then the preparation of the SQL statement fails. The "NOT INDEXED" clause specifies that no index shall be used when accessing the preceding table, including implied indices create by UNIQUE and PRIMARY KEY constraints. However, the INTEGER PRIMARY KEY can still be used to look up entries even when "NOT INDEXED" is specified.</p> <p>Some SQL database engines provide non-standard "hint" mechanisms which can be used to give the query optimizer clues about what indices it should use for a particular statement. The INDEX BY clause of SQLite is <em>not</em> a hinting mechanism and it should not be used as such. The INDEXED BY clause does not give the optimizer hints about which index to use; it gives the optimizer a requirement of which index to use. If the query optimizer is unable to use the index specified by the INDEX BY clause, then the query will fail with an error.</p> <p>The INDEXED BY clause is <em>not</em> intended for use in tuning the performance of a query. The intent of the INDEXED BY clause is to raise a run-time error if a schema change, such as dropping or creating an index, causes the query plan for a time-sensitive query to change. The INDEXED BY clause is designed to help detect undesirable query plan changes during regression testing. Developers are admonished to omit all use of INDEXED BY during application design, implementation, testing, and tuning. If INDEXED BY is to be used at all, it should be inserted at the very end of the development process when "locking down" a design.</p> <h3>See Also:</h3> <ol> <li><p>The <a href="queryplanner-ng.html#howtofix">query planner checklist</a> describes steps that application developers should following to help resolve query planner problems. Notice the that the use of INDEXED BY is a last resort, to be used only when all other measures fail.</p> <li><p><a href="optoverview.html#uplus">The unary "+" operator</a> can be used to disqualify terms in the WHERE clause from use by indices. Careful use of unary + can sometimes help prevent the query planner from choosing a poor index without restricting it to using one specific index. Careful placement of unary + operators is a better method for controlling which indices are used by a query.</p> <li><p>The <a href="c3ref/stmt_status.html">sqlite3_stmt_status()</a> C/C++ interface together with the <a href="c3ref/c_stmtstatus_counter.html#sqlitestmtstatusfullscanstep">SQLITE_STMTSTATUS_FULLSCAN_STEP</a> and <a href="c3ref/c_stmtstatus_counter.html#sqlitestmtstatussort">SQLITE_STMTSTATUS_SORT</a> verbs can be used to detect at run-time when an SQL statement is not making effective use of indices. Many applications may prefer to use the <a href="c3ref/stmt_status.html">sqlite3_stmt_status()</a> interface to detect index misuse rather than the INDEXED BY phrase described here.</p> </ol> <DIV class="pdf_section"> |
Changes to Doc/Extra/Core/lang_insert.html.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
<html dir="LTR" xmlns="http://www.w3.org/1999/xhtml" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:MSHelp="http://msdn.microsoft.com/mshelp" xmlns:tool="http://www.microsoft.com/tooltip" xmlns:ndoc="urn:ndoc-preprocess"> <head> <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252" /> <title>INSERT</title> <link rel="stylesheet" type="text/css" href="../Include/ndoc.css" /> </head> <body> <div id="header"> <table width="100%" id="topTable"> <tr id="headerTableRow1"> <td align="left"> <span id="runningHeaderText">INSERT</span> </td> </tr> <tr id="headerTableRow2"> <td align="left"> <span id="nsrTitle">SQLite Language Reference Documentation</span> </td> </tr> <tr id="headerTableRow3" style="display:none"> <td> <a id="seeAlsoSectionLink" href="#seeAlsoToggle" onclick="OpenSection(seeAlsoToggle)">See Also</a> <a id="exampleSectionLink" href="#codeExampleToggle" onclick="OpenSection(codeExampleToggle)">Example</a> </td> </tr> </table> <table width="100%" id="bottomTable" cellspacing="0" cellpadding="0" style="display:none"> <tr> <td> <span onclick="ExpandCollapseAll(toggleAllImage)" style="cursor:default;" onkeypress="ExpandCollapseAll_CheckKey(toggleAllImage)" tabindex="0"> <img ID="toggleAllImage" class="toggleAll" src="collall.gif" /> <label id="collapseAllLabel" for="toggleAllImage" style="display: none;"> Collapse All </label> <label id="expandAllLabel" for="toggleAllImage" style="display: none;"> Expand All </label> </span> </td> </tr> </table> </div> <div id="mainSection"> <div id="mainBody"> <h1 class="heading"> SQL As Understood By SQLite</h1> <h4> INSERT</h4> <p> <table cellpadding="10"> <tr> <td align="right" width="1%" nowrap> <i><font color="#ff3434">sql-statement</font></i> ::=</td> <td> <b><font color="#2c2cf0">INSERT </font></b>[<b><font color="#2c2cf0">OR </font></b> <i><font color="#ff3434">conflict-algorithm</font></i><b><font color="#2c2cf0"></font></b>]<b><font color="#2c2cf0"> INTO </font></b>[<b><font color="#2c2cf0"></font></b><i><font color="#ff3434">database-name</font></i><b><font color="#2c2cf0"> <big>.</big></font></b>]<b><font color="#2c2cf0"> </font></b> <i><font color="#ff3434">table-name</font></i><b><font color="#2c2cf0"> </font></b> [<b><font color="#2c2cf0"><big>(</big></font></b><i><font color="#ff3434">column-list</font></i><b><font color="#2c2cf0"><big>)</big></font></b>]<b><font color="#2c2cf0"> VALUES<big>(</big></font></b><i><font color="#ff3434">value-list</font></i><b><font color="#2c2cf0"><big>)</big> </font> </b><big>|</big><b><font color="#2c2cf0"><br /> INSERT </font></b>[<b><font color="#2c2cf0">OR </font></b><i><font color="#ff3434"> conflict-algorithm</font></i><b><font color="#2c2cf0"></font></b>]<b><font color="#2c2cf0"> INTO </font></b>[<b><font color="#2c2cf0"></font></b><i><font color="#ff3434">database-name</font></i><b><font color="#2c2cf0"> <big>.</big></font></b>]<b><font color="#2c2cf0"> </font></b> <i><font color="#ff3434">table-name</font></i><b><font color="#2c2cf0"> </font></b> [<b><font color="#2c2cf0"><big>(</big></font></b><i><font color="#ff3434">column-list</font></i><b><font color="#2c2cf0"><big>)</big></font></b>]<b><font color="#2c2cf0"> </font></b><i><font color="#ff3434">select-statement</font></i><b><font color="#2c2cf0"></font></b></td> </tr> </table> </p> <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 must be the same as the number of columns in the table. If a column-list is specified, then the number of values must match the number of specified columns. Columns of the table that do not appear in the column list are filled with the default value, or with NULL if not default value is specified. </p> <p> The second form of the INSERT statement takes it data from a SELECT statement. The number of columns in the result of the SELECT must exactly match the number of columns in the table if no column list is specified, or it must match the number of columns name in the column list. A new entry is made in the table for every row of the SELECT result. The SELECT may be simple or 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 alternative constraint conflict resolution algorithm to use during this one command. See the section titled <a href="lang_conflict.html">ON CONFLICT</a> for additional information. For compatibility with MySQL, the parser allows the use of the single keyword <a href="lang_replace.html"> REPLACE</a> as an alias for "INSERT OR REPLACE". </p> <p> <hr> </p> <div id="footer"> <p> </p> <p> </p> </div> </div> </div> </body> </html> |
| | | | | < | > | | < < > > | | < > | | | | | | | | < < > > | | | | | | | < > | | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | < < < > > > > > > > > > > > > > > > > > > > > > | < < < < < < < < < < < > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | < < < < < < < < < < < < < < < < < > > > > > > | | < < > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > | > | > > > | > > > | > | < < > | < > > | < < < < < > > > > > > > > > > > > > > | > > | | > | < > > > > > > > | < < < < < < < < < < < < > > |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html><head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>SQLite Query Language: INSERT</title> <style type="text/css"> body { margin: auto; font-family: Verdana, sans-serif; padding: 8px 1%; } a { color: #044a64 } a:visited { color: #734559 } .logo { position:absolute; margin:3px; } .tagline { float:right; text-align:right; font-style:italic; width:300px; margin:12px; margin-top:58px; } .menubar { clear: both; border-radius: 8px; background: #044a64; padding: 0px; margin: 0px; cell-spacing: 0px; } .toolbar { text-align: center; line-height: 1.6em; margin: 0; padding: 0px 8px; } .toolbar a { color: white; text-decoration: none; padding: 6px 12px; } .toolbar a:visited { color: white; } .toolbar a:hover { color: #044a64; background: white; } .content { margin: 5%; } .content dt { font-weight:bold; } .content dd { margin-bottom: 25px; margin-left:20%; } .content ul { padding:0px; padding-left: 15px; margin:0px; } /* Things for "fancyformat" documents start here. */ .fancy img+p {font-style:italic} .fancy .codeblock i { color: darkblue; } .fancy h1,.fancy h2,.fancy h3,.fancy h4 {font-weight:normal;color:#044a64} .fancy h2 { margin-left: 10px } .fancy h3 { margin-left: 20px } .fancy h4 { margin-left: 30px } .fancy th {white-space:nowrap;text-align:left;border-bottom:solid 1px #444} .fancy th, .fancy td {padding: 0.2em 1ex; vertical-align:top} .fancy #toc a { color: darkblue ; text-decoration: none } .fancy .todo { color: #AA3333 ; font-style : italic } .fancy .todo:before { content: 'TODO:' } .fancy p.todo { border: solid #AA3333 1px; padding: 1ex } .fancy img { display:block; } .fancy :link:hover, .fancy :visited:hover { background: wheat } .fancy p,.fancy ul,.fancy ol { margin: 1em 5ex } .fancy li p { margin: 1em 0 } /* End of "fancyformat" specific rules. */ </style> </head> <body> <div><!-- container div to satisfy validator --> <a href="index.html"> <img class="logo" src="images/sqlite370_banner.gif" alt="SQLite Logo" border="0"></a> <div><!-- IE hack to prevent disappearing logo--></div> <div class="tagline">Small. Fast. Reliable.<br>Choose any three.</div> <table width=100% class="menubar"><tr> <td width=100%> <div class="toolbar"> <a href="about.html">About</a> <a href="sitemap.html">Sitemap</a> <a href="docs.html">Documentation</a> <a href="download.html">Download</a> <a href="copyright.html">License</a> <a href="news.html">News</a> <a href="support.html">Support</a> </div> <script> gMsg = "Search SQLite Docs..." function entersearch() { var q = document.getElementById("q"); if( q.value == gMsg ) { q.value = "" } q.style.color = "black" q.style.fontStyle = "normal" } function leavesearch() { var q = document.getElementById("q"); if( q.value == "" ) { q.value = gMsg q.style.color = "#044a64" q.style.fontStyle = "italic" } } function hideorshow(btn,obj){ var x = document.getElementById(obj); var b = document.getElementById(btn); if( x.style.display!='none' ){ x.style.display = 'none'; b.innerHTML='show'; }else{ x.style.display = ''; b.innerHTML='hide'; } return false; } </script> <td> <div style="padding:0 1em 0px 0;white-space:nowrap"> <form name=f method="GET" action="http://www.sqlite.org/search"> <input id=q name=q type=text onfocus="entersearch()" onblur="leavesearch()" style="width:24ex;padding:1px 1ex; border:solid white 1px; font-size:0.9em ; font-style:italic;color:#044a64;" value="Search SQLite Docs..."> <input type=submit value="Go" style="border:solid white 1px;background-color:#044a64;color:white;font-size:0.9em;padding:0 1ex"> </form> </div> </table> <div class=startsearch></div> <h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>INSERT</h2><p><b><a href="syntaxdiagrams.html#insert-stmt">insert-stmt:</a></b> <button id='x1083' onclick='hideorshow("x1083","x1084")'>hide</button></p> <blockquote id='x1084'> <img alt="syntax diagram insert-stmt" src="images/syntax/insert-stmt.gif" /> <p><b><a href="syntaxdiagrams.html#expr">expr:</a></b> <button id='x1085' onclick='hideorshow("x1085","x1086")'>show</button></p> <blockquote id='x1086' style='display:none;'> <img alt="syntax diagram expr" src="images/syntax/expr.gif" /> <p><b><a href="syntaxdiagrams.html#literal-value">literal-value:</a></b> <button id='x1087' onclick='hideorshow("x1087","x1088")'>show</button></p> <blockquote id='x1088' style='display:none;'> <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#raise-function">raise-function:</a></b> <button id='x1089' onclick='hideorshow("x1089","x1090")'>show</button></p> <blockquote id='x1090' style='display:none;'> <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#type-name">type-name:</a></b> <button id='x1091' onclick='hideorshow("x1091","x1092")'>show</button></p> <blockquote id='x1092' style='display:none;'> <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" /> <p><b><a href="syntaxdiagrams.html#signed-number">signed-number:</a></b> <button id='x1093' onclick='hideorshow("x1093","x1094")'>show</button></p> <blockquote id='x1094' style='display:none;'> <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" /> </blockquote> </blockquote> </blockquote> <p><b><a href="syntaxdiagrams.html#select-stmt">select-stmt:</a></b> <button id='x1095' onclick='hideorshow("x1095","x1096")'>show</button></p> <blockquote id='x1096' style='display:none;'> <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" /> <p><b><a href="syntaxdiagrams.html#common-table-expression">common-table-expression:</a></b> <button id='x1097' onclick='hideorshow("x1097","x1098")'>show</button></p> <blockquote id='x1098' style='display:none;'> <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#compound-operator">compound-operator:</a></b> <button id='x1099' onclick='hideorshow("x1099","x1100")'>show</button></p> <blockquote id='x1100' style='display:none;'> <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#join-clause">join-clause:</a></b> <button id='x1101' onclick='hideorshow("x1101","x1102")'>show</button></p> <blockquote id='x1102' style='display:none;'> <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" /> <p><b><a href="syntaxdiagrams.html#join-constraint">join-constraint:</a></b> <button id='x1103' onclick='hideorshow("x1103","x1104")'>show</button></p> <blockquote id='x1104' style='display:none;'> <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#join-operator">join-operator:</a></b> <button id='x1105' onclick='hideorshow("x1105","x1106")'>show</button></p> <blockquote id='x1106' style='display:none;'> <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" /> </blockquote> </blockquote> <p><b><a href="syntaxdiagrams.html#ordering-term">ordering-term:</a></b> <button id='x1107' onclick='hideorshow("x1107","x1108")'>show</button></p> <blockquote id='x1108' style='display:none;'> <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#result-column">result-column:</a></b> <button id='x1109' onclick='hideorshow("x1109","x1110")'>show</button></p> <blockquote id='x1110' style='display:none;'> <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" /> </blockquote> <p><b><a href="syntaxdiagrams.html#table-or-subquery">table-or-subquery:</a></b> <button id='x1111' onclick='hideorshow("x1111","x1112")'>show</button></p> <blockquote id='x1112' style='display:none;'> <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" /> </blockquote> </blockquote> <p><b><a href="syntaxdiagrams.html#with-clause">with-clause:</a></b> <button id='x1113' onclick='hideorshow("x1113","x1114")'>show</button></p> <blockquote id='x1114' style='display:none;'> <img alt="syntax diagram with-clause" src="images/syntax/with-clause.gif" /> <p><b><a href="syntaxdiagrams.html#cte-table-name">cte-table-name:</a></b> <button id='x1115' onclick='hideorshow("x1115","x1116")'>show</button></p> <blockquote id='x1116' style='display:none;'> <img alt="syntax diagram cte-table-name" src="images/syntax/cte-table-name.gif" /> </blockquote> </blockquote> </blockquote> <p>The INSERT statement comes in three basic forms. <ul> <li><p>The first form (with the "VALUES" keyword) creates one or more new rows in an existing table. If no column-list is specified then the number of values inserted into each row must be the same as the number of columns in the table. In this case the result of evaluating the left-most expression in each term of the VALUES list is inserted into the left-most column of the each new row, and forth for each subsequent expression. If a column-list is specified, then the number of values in each term of the VALUE list must match the number of specified columns. Each of the named columns of the new row is populated with the results of evaluating the corresponding VALUES expression. Table columns that do not appear in the column list are populated with the default column value (specified as part of the CREATE TABLE statement), or with NULL if no default value is specified. <li><p>The second form of the INSERT statement contains a SELECT statement instead of a VALUES clause. A new entry is inserted into the table for each row of data returned by executing the SELECT statement. If a column-list is specified, the number of columns in the result of the SELECT must be the same as the number of items in the column-list. Otherwise, if no column-list is specified, the number of columns in the result of the SELECT must be the same as the number of columns in the table. Any SELECT statement, including <a href="lang_select.html#compound">compound SELECTs</a> and SELECT statements with <a href="lang_select.html#orderby">ORDER BY</a> and/or <a href="lang_select.html#limitoffset">LIMIT</a> clauses, may be used in an INSERT statement of this form. <li><p>The third form of an INSERT statement is with DEFAULT VALUES. The INSERT ... DEFAULT VALUES statement inserts a single new row into the named table. Each column of the new row is populated with its default value, or with a NULL if no default value is specified as part of the column definition in the CREATE TABLE statement. </ul> <p>The optional conflict-clause allows the specification of an alternative constraint conflict resolution algorithm to use during this one INSERT command. See the section titled <a href="lang_conflict.html">ON CONFLICT</a> for additional information. For compatibility with MySQL, the parser allows the use of the single keyword <a href="lang_replace.html">REPLACE</a> as an alias for "INSERT OR REPLACE". <p>The optional "<i>database-name</i><b>.</b>" prefix on the <i>table-name</i> is support for top-level INSERT statements only. The table name must be unqualified for INSERT statements that occur within <a href="lang_createtrigger.html">CREATE TRIGGER</a> statements. Similarly, the "DEFAULT VALUES" form of the INSERT statement is supported for top-level INSERT statements only and not for INSERT statements within triggers. <p> |
Added Doc/Extra/Core/lang_keywords.html.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html><head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>SQLite Query Language: SQLite Keywords</title> <style type="text/css"> body { margin: auto; font-family: Verdana, sans-serif; padding: 8px 1%; } a { color: #044a64 } a:visited { color: #734559 } .logo { position:absolute; margin:3px; } .tagline { float:right; text-align:right; font-style:italic; width:300px; margin:12px; margin-top:58px; } .menubar { clear: both; border-radius: 8px; background: #044a64; padding: 0px; margin: 0px; cell-spacing: 0px; } .toolbar { text-align: center; line-height: 1.6em; margin: 0; padding: 0px 8px; } .toolbar a { color: white; text-decoration: none; padding: 6px 12px; } .toolbar a:visited { color: white; } .toolbar a:hover { color: #044a64; background: white; } .content { margin: 5%; } .content dt { font-weight:bold; } .content dd { margin-bottom: 25px; margin-left:20%; } .content ul { padding:0px; padding-left: 15px; margin:0px; } /* Things for "fancyformat" documents start here. */ .fancy img+p {font-style:italic} .fancy .codeblock i { color: darkblue; } .fancy h1,.fancy h2,.fancy h3,.fancy h4 {font-weight:normal;color:#044a64} .fancy h2 { margin-left: 10px } .fancy h3 { margin-left: 20px } .fancy h4 { margin-left: 30px } .fancy th {white-space:nowrap;text-align:left;border-bottom:solid 1px #444} .fancy th, .fancy td {padding: 0.2em 1ex; vertical-align:top} .fancy #toc a { color: darkblue ; text-decoration: none } .fancy .todo { color: #AA3333 ; font-style : italic } .fancy .todo:before { content: 'TODO:' } .fancy p.todo { border: solid #AA3333 1px; padding: 1ex } .fancy img { display:block; } .fancy :link:hover, .fancy :visited:hover { background: wheat } .fancy p,.fancy ul,.fancy ol { margin: 1em 5ex } .fancy li p { margin: 1em 0 } /* End of "fancyformat" specific rules. */ </style> </head> <body> <div><!-- container div to satisfy validator --> <a href="index.html"> <img class="logo" src="images/sqlite370_banner.gif" alt="SQLite Logo" border="0"></a> <div><!-- IE hack to prevent disappearing logo--></div> <div class="tagline">Small. Fast. Reliable.<br>Choose any three.</div> <table width=100% class="menubar"><tr> <td width=100%> <div class="toolbar"> <a href="about.html">About</a> <a href="sitemap.html">Sitemap</a> <a href="docs.html">Documentation</a> <a href="download.html">Download</a> <a href="copyright.html">License</a> <a href="news.html">News</a> <a href="support.html">Support</a> </div> <script> gMsg = "Search SQLite Docs..." function entersearch() { var q = document.getElementById("q"); if( q.value == gMsg ) { q.value = "" } q.style.color = "black" q.style.fontStyle = "normal" } function leavesearch() { var q = document.getElementById("q"); if( q.value == "" ) { q.value = gMsg q.style.color = "#044a64" q.style.fontStyle = "italic" } } function hideorshow(btn,obj){ var x = document.getElementById(obj); var b = document.getElementById(btn); if( x.style.display!='none' ){ x.style.display = 'none'; b.innerHTML='show'; }else{ x.style.display = ''; b.innerHTML='hide'; } return false; } </script> <td> <div style="padding:0 1em 0px 0;white-space:nowrap"> <form name=f method="GET" action="http://www.sqlite.org/search"> <input id=q name=q type=text onfocus="entersearch()" onblur="leavesearch()" style="width:24ex;padding:1px 1ex; border:solid white 1px; font-size:0.9em ; font-style:italic;color:#044a64;" value="Search SQLite Docs..."> <input type=submit value="Go" style="border:solid white 1px;background-color:#044a64;color:white;font-size:0.9em;padding:0 1ex"> </form> </div> </table> <div class=startsearch></div> <h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>SQLite Keywords</h2></DIV> <p>The SQL standard specifies a huge number of keywords which may not be used as the names of tables, indices, columns, databases, user-defined functions, collations, virtual table modules, or any other named object. The list of keywords is so long that few people can remember them all. For most SQL code, your safest bet is to never use any English language word as the name of a user-defined object.</p> <p>If you want to use a keyword as a name, you need to quote it. There are four ways of quoting keywords in SQLite:</p> <p> <blockquote> <table> <tr> <td valign="top"><b>'keyword'</b></td><td width="20"></td> <td>A keyword in single quotes is a string literal.</td></tr> <tr> <td valign="top"><b>"keyword"</b></td><td></td> <td>A keyword in double-quotes is an identifier.</td></tr> <tr> <td valign="top"><b>[keyword]</b></td><td></td> <td>A keyword enclosed in square brackets is an identifier. This is not standard SQL. This quoting mechanism is used by MS Access and SQL Server and is included in SQLite for compatibility.</td></tr> <tr> <td valign="top"><b>`keyword`</b></td><td></td> <td>A keyword enclosed in grave accents (ASCII code 96) is an identifier. This is not standard SQL. This quoting mechanism is used by MySQL and is included in SQLite for compatibility.</td></tr> </table> </blockquote> </p> <p>For resilience when confronted with historical SQL statements, SQLite will sometimes bend the quoting rules above:</p> <ul> <li><p>If a keyword in single quotes (ex: <b>'key'</b> or <b>'glob'</b>) is used in a context where an identifier is allowed but where a string literal is not allowed, then the token is understood to be an identifier instead of a string literal. </p></li> <li><p>If a keyword in double quotes (ex: <b>"key"</b> or <b>"glob"</b>) is used in a context where it cannot be resolved to an identifier but where a string literal is allowed, then the token is understood to be a string literal instead of an identifier.</p></li> </ul> <p>Programmers are cautioned not to use the two exceptions described in the previous bullets. We emphasize that they exist only so that old and ill-formed SQL statements will run correctly. Future versions of SQLite might raise errors instead of accepting the malformed statements covered by the exceptions above.</p> <p> SQLite adds new keywords from time to time when it takes on new features. So to prevent your code from being broken by future enhancements, you should normally quote any identifier that is an English language word, even if you do not have to. </p> <p> The list below shows all possible keywords used by any build of SQLite regardless of <a href="compile.html">compile-time options</a>. Most reasonable configurations use most or all of these keywords, but some keywords may be omitted when SQL language features are disabled. Regardless of the compile-time configuration, any identifier that is not on the following 124 element list is not a keyword to the SQL parser in SQLite: </p> <blockquote> <table width="100%"><tr> <td align="left" valign="top" width="20%"> ABORT<br> ACTION<br> ADD<br> AFTER<br> ALL<br> ALTER<br> ANALYZE<br> AND<br> AS<br> ASC<br> ATTACH<br> AUTOINCREMENT<br> BEFORE<br> BEGIN<br> BETWEEN<br> BY<br> CASCADE<br> CASE<br> CAST<br> CHECK<br> COLLATE<br> COLUMN<br> COMMIT<br> CONFLICT<br> CONSTRAINT<br> </td><td valign="top" align="left" width="20%">CREATE<br> CROSS<br> CURRENT_DATE<br> CURRENT_TIME<br> CURRENT_TIMESTAMP<br> DATABASE<br> DEFAULT<br> DEFERRABLE<br> DEFERRED<br> DELETE<br> DESC<br> DETACH<br> DISTINCT<br> DROP<br> EACH<br> ELSE<br> END<br> ESCAPE<br> EXCEPT<br> EXCLUSIVE<br> EXISTS<br> EXPLAIN<br> FAIL<br> FOR<br> FOREIGN<br> </td><td valign="top" align="left" width="20%">FROM<br> FULL<br> GLOB<br> GROUP<br> HAVING<br> IF<br> IGNORE<br> IMMEDIATE<br> IN<br> INDEX<br> INDEXED<br> INITIALLY<br> INNER<br> INSERT<br> INSTEAD<br> INTERSECT<br> INTO<br> IS<br> ISNULL<br> JOIN<br> KEY<br> LEFT<br> LIKE<br> LIMIT<br> MATCH<br> </td><td valign="top" align="left" width="20%">NATURAL<br> NO<br> NOT<br> NOTNULL<br> NULL<br> OF<br> OFFSET<br> ON<br> OR<br> ORDER<br> OUTER<br> PLAN<br> PRAGMA<br> PRIMARY<br> QUERY<br> RAISE<br> RECURSIVE<br> REFERENCES<br> REGEXP<br> REINDEX<br> RELEASE<br> RENAME<br> REPLACE<br> RESTRICT<br> RIGHT<br> </td><td valign="top" align="left" width="20%">ROLLBACK<br> ROW<br> SAVEPOINT<br> SELECT<br> SET<br> TABLE<br> TEMP<br> TEMPORARY<br> THEN<br> TO<br> TRANSACTION<br> TRIGGER<br> UNION<br> UNIQUE<br> UPDATE<br> USING<br> VACUUM<br> VALUES<br> VIEW<br> VIRTUAL<br> WHEN<br> WHERE<br> WITH<br> WITHOUT<br> </td></tr></table></blockquote> |
Added Doc/Extra/Core/lang_naming.html.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html><head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>SQLite Query Language: Database Object Name Resolution</title> <style type="text/css"> body { margin: auto; font-family: Verdana, sans-serif; padding: 8px 1%; } a { color: #044a64 } a:visited { color: #734559 } .logo { position:absolute; margin:3px; } .tagline { float:right; text-align:right; font-style:italic; width:300px; margin:12px; margin-top:58px; } .menubar { clear: both; border-radius: 8px; background: #044a64; padding: 0px; margin: 0px; cell-spacing: 0px; } .toolbar { text-align: center; line-height: 1.6em; margin: 0; padding: 0px 8px; } .toolbar a { color: white; text-decoration: none; padding: 6px 12px; } .toolbar a:visited { color: white; } .toolbar a:hover { color: #044a64; background: white; } .content { margin: 5%; } .content dt { font-weight:bold; } .content dd { margin-bottom: 25px; margin-left:20%; } .content ul { padding:0px; padding-left: 15px; margin:0px; } /* Things for "fancyformat" documents start here. */ .fancy img+p {font-style:italic} .fancy .codeblock i { color: darkblue; } .fancy h1,.fancy h2,.fancy h3,.fancy h4 {font-weight:normal;color:#044a64} .fancy h2 { margin-left: 10px } .fancy h3 { margin-left: 20px } .fancy h4 { margin-left: 30px } .fancy th {white-space:nowrap;text-align:left;border-bottom:solid 1px #444} .fancy th, .fancy td {padding: 0.2em 1ex; vertical-align:top} .fancy #toc a { color: darkblue ; text-decoration: none } .fancy .todo { color: #AA3333 ; font-style : italic } .fancy .todo:before { content: 'TODO:' } .fancy p.todo { border: solid #AA3333 1px; padding: 1ex } .fancy img { display:block; } .fancy :link:hover, .fancy :visited:hover { background: wheat } .fancy p,.fancy ul,.fancy ol { margin: 1em 5ex } .fancy li p { margin: 1em 0 } /* End of "fancyformat" specific rules. */ </style> </head> <body> <div><!-- container div to satisfy validator --> <a href="index.html"> <img class="logo" src="images/sqlite370_banner.gif" alt="SQLite Logo" border="0"></a> <div><!-- IE hack to prevent disappearing logo--></div> <div class="tagline">Small. Fast. Reliable.<br>Choose any three.</div> <table width=100% class="menubar"><tr> <td width=100%> <div class="toolbar"> <a href="about.html">About</a> <a href="sitemap.html">Sitemap</a> <a href="docs.html">Documentation</a> <a href="download.html">Download</a> <a href="copyright.html">License</a> <a href="news.html">News</a> <a href="support.html">Support</a> </div> <script> gMsg = "Search SQLite Docs..." function entersearch() { var q = document.getElementById("q"); if( q.value == gMsg ) { q.value = "" } q.style.color = "black" q.style.fontStyle = "normal" } function leavesearch() { var q = document.getElementById("q"); if( q.value == "" ) { q.value = gMsg q.style.color = "#044a64" q.style.fontStyle = "italic" } } function hideorshow(btn,obj){ var x = document.getElementById(obj); var b = document.getElementById(btn); if( x.style.display!='none' ){ x.style.display = 'none'; b.innerHTML='show'; }else{ x.style.display = ''; b.innerHTML='hide'; } return false; } </script> <td> <div style="padding:0 1em 0px 0;white-space:nowrap"> <form name=f method="GET" action="http://www.sqlite.org/search"> <input id=q name=q type=text onfocus="entersearch()" onblur="leavesearch()" style="width:24ex;padding:1px 1ex; border:solid white 1px; font-size:0.9em ; font-style:italic;color:#044a64;" value="Search SQLite Docs..."> <input type=submit value="Go" style="border:solid white 1px;background-color:#044a64;color:white;font-size:0.9em;padding:0 1ex"> </form> </div> </table> <div class=startsearch></div> <h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>Database Object Name Resolution</h2> <p> In SQLite, a database object (a table, index, trigger or view) is identified by the name of the object and the name of the database that it resides in. Database objects may reside in the main database, the temp database, or in an <a href="lang_attach.html">attached database</a>. <p> The syntax of the <a href="lang_droptable.html">DROP TABLE</a>, <a href="lang_dropindex.html">DROP INDEX</a>, <a href="lang_dropview.html">DROP VIEW</a>, <a href="lang_droptrigger.html">DROP TRIGGER</a>, <a href="lang_reindex.html">REINDEX</a>, <a href="lang_altertable.html">ALTER TABLE</a> and many other commands all permit the user to specify a database object either by its name alone, or by a combination of its name and the name of its database. If no database is specified as part of the object reference, then SQLite searches the main, temp and all attached databases for an object with a matching name. The temp database is searched first, followed by the main database, followed all attached databases in the order that they were attached. The reference resolves to the first match found. For example: <pre> /* Add a table named 't1' to the temp, main and an attached database */ ATTACH 'file.db' AS aux; CREATE TABLE t1(x, y); CREATE TEMP TABLE t1(x, y); CREATE TABLE aux.t1(x, y); DROP TABLE t1; /* Drop table in temp database */ DROP TABLE t1; /* Drop table in main database */ DROP TABLE t1; /* Drop table in aux database */ </pre> <p> If a database name is specified as part of an object reference, it must be either "main", or "temp" or the name of an attached database. Like other SQL identifiers, database names are case-insensitive. If a database name is specified, then only the named database is searched for the named object. <p> Most object references may only resolve to a specific type of object (for example a reference that is part of a DROP TABLE statement may only resolve to a table object, not an index, trigger or view). However in some contexts (e.g. <a href="lang_reindex.html">REINDEX</a>) an object reference may be resolve to more than one type of object. When searching database schemas for a named object, objects of types that cannot be used in the context of the reference are always ignored. |
Changes to Doc/Extra/Core/lang_reindex.html.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
<html dir="LTR" xmlns="http://www.w3.org/1999/xhtml" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:MSHelp="http://msdn.microsoft.com/mshelp" xmlns:tool="http://www.microsoft.com/tooltip" xmlns:ndoc="urn:ndoc-preprocess"> <head> <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252" /> <title>REINDEX</title> <link rel="stylesheet" type="text/css" href="../Include/ndoc.css" /> </head> <body> <div id="header"> <table width="100%" id="topTable"> <tr id="headerTableRow1"> <td align="left"> <span id="runningHeaderText">REINDEX</span> </td> </tr> <tr id="headerTableRow2"> <td align="left"> <span id="nsrTitle">SQLite Language Reference Documentation</span> </td> </tr> <tr id="headerTableRow3" style="display:none"> <td> <a id="seeAlsoSectionLink" href="#seeAlsoToggle" onclick="OpenSection(seeAlsoToggle)">See Also</a> <a id="exampleSectionLink" href="#codeExampleToggle" onclick="OpenSection(codeExampleToggle)">Example</a> </td> </tr> </table> <table width="100%" id="bottomTable" cellspacing="0" cellpadding="0" style="display:none"> <tr> <td> <span onclick="ExpandCollapseAll(toggleAllImage)" style="cursor:default;" onkeypress="ExpandCollapseAll_CheckKey(toggleAllImage)" tabindex="0"> <img ID="toggleAllImage" class="toggleAll" src="collall.gif" /> <label id="collapseAllLabel" for="toggleAllImage" style="display: none;"> Collapse All </label> <label id="expandAllLabel" for="toggleAllImage" style="display: none;"> Expand All </label> </span> </td> </tr> </table> </div> <div id="mainSection"> <div id="mainBody"> <h1 class="heading"> SQL As Understood By SQLite</h1> <h4> REINDEX</h4> <p> <table cellpadding="10"> <tr> <td align="right" width="1%" nowrap> <i><font color="#ff3434">sql-statement</font></i> ::=</td> <td> <b><font color="#2c2cf0">REINDEX </font></b><i><font color="#ff3434">collation name</font></i><b><font color="#2c2cf0"></font></b></td> </tr> </table> <table cellpadding="10"> <tr> <td align="right" width="1%" nowrap> <i><font color="#ff3434">sql-statement</font></i> ::=</td> <td> <b><font color="#2c2cf0">REINDEX </font></b>[<b><font color="#2c2cf0"></font></b><i><font color="#ff3434">database-name</font></i><b><font color="#2c2cf0"> <big>.</big></font></b>]<b><font color="#2c2cf0"> </font></b><i><font color="#ff3434">table/index-name</font></i><b><font color="#2c2cf0"></font></b></td> </tr> </table> </p> <p> The REINDEX command is used to delete and recreate indices from scratch. This is useful when the definition of a collation sequence has changed. </p> <p> In the first form, all indices in all attached databases that use the named collation sequence are recreated. In the second form, if <i>[database-name.]table/index-name</i> identifies a table, then all indices associated with the table are rebuilt. If an index is identified, then only this specific index is deleted and recreated. </p> <p> If no <i>database-name</i> is specified and there exists both a table or index and a collation sequence of the specified name, then indices associated with the collation sequence only are reconstructed. This ambiguity may be dispelled by always specifying a <i>database-name</i> when reindexing a specific table or index. </p> <p> <hr> </p> <div id="footer"> <p> </p> <p> </p> </div> </div> </div> </body> </html> |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html><head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>SQLite Query Language: REINDEX</title> <style type="text/css"> body { margin: auto; font-family: Verdana, sans-serif; padding: 8px 1%; } a { color: #044a64 } a:visited { color: #734559 } .logo { position:absolute; margin:3px; } .tagline { float:right; text-align:right; font-style:italic; width:300px; margin:12px; margin-top:58px; } .menubar { clear: both; border-radius: 8px; background: #044a64; padding: 0px; margin: 0px; cell-spacing: 0px; } .toolbar { text-align: center; line-height: 1.6em; margin: 0; padding: 0px 8px; } .toolbar a { color: white; text-decoration: none; padding: 6px 12px; } .toolbar a:visited { color: white; } .toolbar a:hover { color: #044a64; background: white; } .content { margin: 5%; } .content dt { font-weight:bold; } .content dd { margin-bottom: 25px; margin-left:20%; } .content ul { padding:0px; padding-left: 15px; margin:0px; } /* Things for "fancyformat" documents start here. */ .fancy img+p {font-style:italic} .fancy .codeblock i { color: darkblue; } .fancy h1,.fancy h2,.fancy h3,.fancy h4 {font-weight:normal;color:#044a64} .fancy h2 { margin-left: 10px } .fancy h3 { margin-left: 20px } .fancy h4 { margin-left: 30px } .fancy th {white-space:nowrap;text-align:left;border-bottom:solid 1px #444} .fancy th, .fancy td {padding: 0.2em 1ex; vertical-align:top} .fancy #toc a { color: darkblue ; text-decoration: none } .fancy .todo { color: #AA3333 ; font-style : italic } .fancy .todo:before { content: 'TODO:' } .fancy p.todo { border: solid #AA3333 1px; padding: 1ex } .fancy img { display:block; } .fancy :link:hover, .fancy :visited:hover { background: wheat } .fancy p,.fancy ul,.fancy ol { margin: 1em 5ex } .fancy li p { margin: 1em 0 } /* End of "fancyformat" specific rules. */ </style> </head> <body> <div><!-- container div to satisfy validator --> <a href="index.html"> <img class="logo" src="images/sqlite370_banner.gif" alt="SQLite Logo" border="0"></a> <div><!-- IE hack to prevent disappearing logo--></div> <div class="tagline">Small. Fast. Reliable.<br>Choose any three.</div> <table width=100% class="menubar"><tr> <td width=100%> <div class="toolbar"> <a href="about.html">About</a> <a href="sitemap.html">Sitemap</a> <a href="docs.html">Documentation</a> <a href="download.html">Download</a> <a href="copyright.html">License</a> <a href="news.html">News</a> <a href="support.html">Support</a> </div> <script> gMsg = "Search SQLite Docs..." function entersearch() { var q = document.getElementById("q"); if( q.value == gMsg ) { q.value = "" } q.style.color = "black" q.style.fontStyle = "normal" } function leavesearch() { var q = document.getElementById("q"); if( q.value == "" ) { q.value = gMsg q.style.color = "#044a64" q.style.fontStyle = "italic" } } function hideorshow(btn,obj){ var x = document.getElementById(obj); var b = document.getElementById(btn); if( x.style.display!='none' ){ x.style.display = 'none'; b.innerHTML='show'; }else{ x.style.display = ''; b.innerHTML='hide'; } return false; } </script> <td> <div style="padding:0 1em 0px 0;white-space:nowrap"> <form name=f method="GET" action="http://www.sqlite.org/search"> <input id=q name=q type=text onfocus="entersearch()" onblur="leavesearch()" style="width:24ex;padding:1px 1ex; border:solid white 1px; font-size:0.9em ; font-style:italic;color:#044a64;" value="Search SQLite Docs..."> <input type=submit value="Go" style="border:solid white 1px;background-color:#044a64;color:white;font-size:0.9em;padding:0 1ex"> </form> </div> </table> <div class=startsearch></div> <h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>REINDEX</h2><p><b><a href="syntaxdiagrams.html#reindex-stmt">reindex-stmt:</a></b> <button id='x1119' onclick='hideorshow("x1119","x1120")'>hide</button></p> <blockquote id='x1120'> <img alt="syntax diagram reindex-stmt" src="images/syntax/reindex-stmt.gif" /> </blockquote> <p>The REINDEX command is used to delete and recreate indices from scratch. This is useful when the definition of a collation sequence has changed. </p> <p>If the REINDEX keyword is not followed by a collation-sequence or database object identifier, then all indices in all attached databases are rebuilt. <p>If the REINDEX keyword is followed by a collation-sequence name, then all indices in all attached databases that use the named collation sequences are recreated. <p>Or, if the argument attached to the REINDEX identifies a specific database table, then all indices attached to the database table are rebuilt. If it identifies a specific database index, then just that index is recreated. <p>If no <i>database-name</i> is specified and there exists both a table or index and a collation sequence of the specified name, SQLite interprets this as a request to rebuild the indices that use the named collation sequence. This ambiguity in the syntax may be avoided by always specifying a <i>database-name</i> when reindexing a specific table or index. |
Changes to Doc/Extra/Core/lang_replace.html.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
<html dir="LTR" xmlns="http://www.w3.org/1999/xhtml" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:MSHelp="http://msdn.microsoft.com/mshelp" xmlns:tool="http://www.microsoft.com/tooltip" xmlns:ndoc="urn:ndoc-preprocess"> <head> <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252" /> <title>REPLACE</title> <link rel="stylesheet" type="text/css" href="../Include/ndoc.css" /> </head> <body> <div id="header"> <table width="100%" id="topTable"> <tr id="headerTableRow1"> <td align="left"> <span id="runningHeaderText">REPLACE</span> </td> </tr> <tr id="headerTableRow2"> <td align="left"> <span id="nsrTitle">SQLite Language Reference Documentation</span> </td> </tr> <tr id="headerTableRow3" style="display:none"> <td> <a id="seeAlsoSectionLink" href="#seeAlsoToggle" onclick="OpenSection(seeAlsoToggle)">See Also</a> <a id="exampleSectionLink" href="#codeExampleToggle" onclick="OpenSection(codeExampleToggle)">Example</a> </td> </tr> </table> <table width="100%" id="bottomTable" cellspacing="0" cellpadding="0" style="display:none"> <tr> <td> <span onclick="ExpandCollapseAll(toggleAllImage)" style="cursor:default;" onkeypress="ExpandCollapseAll_CheckKey(toggleAllImage)" tabindex="0"> <img ID="toggleAllImage" class="toggleAll" src="collall.gif" /> <label id="collapseAllLabel" for="toggleAllImage" style="display: none;"> Collapse All </label> <label id="expandAllLabel" for="toggleAllImage" style="display: none;"> Expand All </label> </span> </td> </tr> </table> </div> <div id="mainSection"> <div id="mainBody"> <h1 class="heading"> SQL As Understood By SQLite</h1> <h4> REPLACE</h4> <p> <table cellpadding="10"> <tr> <td align="right" width="1%" nowrap> <i><font color="#ff3434">sql-statement</font></i> ::=</td> <td> <b><font color="#2c2cf0">REPLACE INTO </font></b>[<b><font color="#2c2cf0"></font></b><i><font color="#ff3434">database-name</font></i><b><font color="#2c2cf0"> <big>.</big></font></b>]<b><font color="#2c2cf0"> </font></b><i><font color="#ff3434">table-name</font></i><b><font color="#2c2cf0"> </font></b>[<b><font color="#2c2cf0"><big>(</big> </font></b> <i><font color="#ff3434">column-list</font></i><b><font color="#2c2cf0"> <big>)</big></font></b>]<b><font color="#2c2cf0"> VALUES <big>(</big> </font></b><i><font color="#ff3434">value-list</font></i><b><font color="#2c2cf0"> <big>)</big> </font></b><big>|</big><b><font color="#2c2cf0"><br /> REPLACE INTO </font></b>[<b><font color="#2c2cf0"></font></b><i><font color="#ff3434">database-name</font></i><b><font color="#2c2cf0"> <big>.</big></font></b>]<b><font color="#2c2cf0"> </font></b> <i><font color="#ff3434">table-name</font></i><b><font color="#2c2cf0"> </font></b> [<b><font color="#2c2cf0"><big>(</big> </font></b><i><font color="#ff3434">column-list</font></i><b><font color="#2c2cf0"> <big>)</big></font></b>]<b><font color="#2c2cf0"> </font></b> <i><font color="#ff3434">select-statement</font></i><b><font color="#2c2cf0"></font></b></td> </tr> </table> </p> <p> The REPLACE command is an alias for the "INSERT OR REPLACE" variant of the <a href="lang_insert.html"> INSERT</a> command. This alias is provided for compatibility with MySQL. See the <a href="lang_insert.html">INSERT</a> command documentation for additional information.</p> <p> <hr> </p> <div id="footer"> <p> </p> <p> </p> </div> </div> </div> </body> </html> |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html><head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>SQLite Query Language: REPLACE</title> <style type="text/css"> body { margin: auto; font-family: Verdana, sans-serif; padding: 8px 1%; } a { color: #044a64 } a:visited { color: #734559 } .logo { position:absolute; margin:3px; } .tagline { float:right; text-align:right; font-style:italic; width:300px; margin:12px; margin-top:58px; } .menubar { clear: both; border-radius: 8px; background: #044a64; padding: 0px; margin: 0px; cell-spacing: 0px; } .toolbar { text-align: center; line-height: 1.6em; margin: 0; padding: 0px 8px; } .toolbar a { color: white; text-decoration: none; padding: 6px 12px; } .toolbar a:visited { color: white; } .toolbar a:hover { color: #044a64; background: white; } .content { margin: 5%; } .content dt { font-weight:bold; } .content dd { margin-bottom: 25px; margin-left:20%; } .content ul { padding:0px; padding-left: 15px; margin:0px; } /* Things for "fancyformat" documents start here. */ .fancy img+p {font-style:italic} .fancy .codeblock i { color: darkblue; } .fancy h1,.fancy h2,.fancy h3,.fancy h4 {font-weight:normal;color:#044a64} .fancy h2 { margin-left: 10px } .fancy h3 { margin-left: 20px } .fancy h4 { margin-left: 30px } .fancy th {white-space:nowrap;text-align:left;border-bottom:solid 1px #444} .fancy th, .fancy td {padding: 0.2em 1ex; vertical-align:top} .fancy #toc a { color: darkblue ; text-decoration: none } .fancy .todo { color: #AA3333 ; font-style : italic } .fancy .todo:before { content: 'TODO:' } .fancy p.todo { border: solid #AA3333 1px; padding: 1ex } .fancy img { display:block; } .fancy :link:hover, .fancy :visited:hover { background: wheat } .fancy p,.fancy ul,.fancy ol { margin: 1em 5ex } .fancy li p { margin: 1em 0 } /* End of "fancyformat" specific rules. */ </style> </head> <body> <div><!-- container div to satisfy validator --> <a href="index.html"> <img class="logo" src="images/sqlite370_banner.gif" alt="SQLite Logo" border="0"></a> <div><!-- IE hack to prevent disappearing logo--></div> <div class="tagline">Small. Fast. Reliable.<br>Choose any three.</div> <table width=100% class="menubar"><tr> <td width=100%> <div class="toolbar"> <a href="about.html">About</a> <a href="sitemap.html">Sitemap</a> <a href="docs.html">Documentation</a> <a href="download.html">Download</a> <a href="copyright.html">License</a> <a href="news.html">News</a> <a href="support.html">Support</a> </div> <script> gMsg = "Search SQLite Docs..." function entersearch() { var q = document.getElementById("q"); if( q.value == gMsg ) { q.value = "" } q.style.color = "black" q.style.fontStyle = "normal" } function leavesearch() { var q = document.getElementById("q"); if( q.value == "" ) { q.value = gMsg q.style.color = "#044a64" q.style.fontStyle = "italic" } } function hideorshow(btn,obj){ var x = document.getElementById(obj); var b = document.getElementById(btn); if( x.style.display!='none' ){ x.style.display = 'none'; b.innerHTML='show'; }else{ x.style.display = ''; b.innerHTML='hide'; } return false; } </script> <td> <div style="padding:0 1em 0px 0;white-space:nowrap"> <form name=f method="GET" action="http://www.sqlite.org/search"> <input id=q name=q type=text onfocus="entersearch()" onblur="leavesearch()" style="width:24ex;padding:1px 1ex; border:solid white 1px; font-size:0.9em ; font-style:italic;color:#044a64;" value="Search SQLite Docs..."> <input type=submit value="Go" style="border:solid white 1px;background-color:#044a64;color:white;font-size:0.9em;padding:0 1ex"> </form> </div> </table> <div class=startsearch></div> <h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>REPLACE</h2> <p>The REPLACE command is an alias for the "<a href="lang_conflict.html">INSERT OR REPLACE</a>" variant of the <a href="lang_insert.html">INSERT</a> command. This alias is provided for compatibility other SQL database engines. See the <a href="lang_insert.html">INSERT</a> command documentation for additional information.</p> |
Added Doc/Extra/Core/lang_savepoint.html.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html><head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>SQLite Query Language: SAVEPOINT</title> <style type="text/css"> body { margin: auto; font-family: Verdana, sans-serif; padding: 8px 1%; } a { color: #044a64 } a:visited { color: #734559 } .logo { position:absolute; margin:3px; } .tagline { float:right; text-align:right; font-style:italic; width:300px; margin:12px; margin-top:58px; } .menubar { clear: both; border-radius: 8px; background: #044a64; padding: 0px; margin: 0px; cell-spacing: 0px; } .toolbar { text-align: center; line-height: 1.6em; margin: 0; padding: 0px 8px; } .toolbar a { color: white; text-decoration: none; padding: 6px 12px; } .toolbar a:visited { color: white; } .toolbar a:hover { color: #044a64; background: white; } .content { margin: 5%; } .content dt { font-weight:bold; } .content dd { margin-bottom: 25px; margin-left:20%; } .content ul { padding:0px; padding-left: 15px; margin:0px; } /* Things for "fancyformat" documents start here. */ .fancy img+p {font-style:italic} .fancy .codeblock i { color: darkblue; } .fancy h1,.fancy h2,.fancy h3,.fancy h4 {font-weight:normal;color:#044a64} .fancy h2 { margin-left: 10px } .fancy h3 { margin-left: 20px } .fancy h4 { margin-left: 30px } .fancy th {white-space:nowrap;text-align:left;border-bottom:solid 1px #444} .fancy th, .fancy td {padding: 0.2em 1ex; vertical-align:top} .fancy #toc a { color: darkblue ; text-decoration: none } .fancy .todo { color: #AA3333 ; font-style : italic } .fancy .todo:before { content: 'TODO:' } .fancy p.todo { border: solid #AA3333 1px; padding: 1ex } .fancy img { display:block; } .fancy :link:hover, .fancy :visited:hover { background: wheat } .fancy p,.fancy ul,.fancy ol { margin: 1em 5ex } .fancy li p { margin: 1em 0 } /* End of "fancyformat" specific rules. */ </style> </head> <body> <div><!-- container div to satisfy validator --> <a href="index.html"> <img class="logo" src="images/sqlite370_banner.gif" alt="SQLite Logo" border="0"></a> <div><!-- IE hack to prevent disappearing logo--></div> <div class="tagline">Small. Fast. Reliable.<br>Choose any three.</div> <table width=100% class="menubar"><tr> <td width=100%> <div class="toolbar"> <a href="about.html">About</a> <a href="sitemap.html">Sitemap</a> <a href="docs.html">Documentation</a> <a href="download.html">Download</a> <a href="copyright.html">License</a> <a href="news.html">News</a> <a href="support.html">Support</a> </div> <script> gMsg = "Search SQLite Docs..." function entersearch() { var q = document.getElementById("q"); if( q.value == gMsg ) { q.value = "" } q.style.color = "black" q.style.fontStyle = "normal" } function leavesearch() { var q = document.getElementById("q"); if( q.value == "" ) { q.value = gMsg q.style.color = "#044a64" q.style.fontStyle = "italic" } } function hideorshow(btn,obj){ var x = document.getElementById(obj); var b = document.getElementById(btn); if( x.style.display!='none' ){ x.style.display = 'none'; b.innerHTML='show'; }else{ x.style.display = ''; b.innerHTML='hide'; } return false; } </script> <td> <div style="padding:0 1em 0px 0;white-space:nowrap"> <form name=f method="GET" action="http://www.sqlite.org/search"> <input id=q name=q type=text onfocus="entersearch()" onblur="leavesearch()" style="width:24ex;padding:1px 1ex; border:solid white 1px; font-size:0.9em ; font-style:italic;color:#044a64;" value="Search SQLite Docs..."> <input type=submit value="Go" style="border:solid white 1px;background-color:#044a64;color:white;font-size:0.9em;padding:0 1ex"> </form> </div> </table> <div class=startsearch></div> <h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>SAVEPOINT</h2><p><b><a href="syntaxdiagrams.html#savepoint-stmt">savepoint-stmt:</a></b> <button id='x803' onclick='hideorshow("x803","x804")'>hide</button></p> <blockquote id='x804'> <img alt="syntax diagram savepoint-stmt" src="images/syntax/savepoint-stmt.gif" /> </blockquote> <p> SAVEPOINTs are a method of creating transactions, similar to <a href="lang_transaction.html">BEGIN</a> and <a href="lang_transaction.html">COMMIT</a>, except that the SAVEPOINT and RELEASE commands are named and may be nested.</p> <p> The SAVEPOINT command starts a new transaction with a name. The transaction names need not be unique. A SAVEPOINT can be started either within or outside of a <a href="lang_transaction.html">BEGIN</a>...<a href="lang_transaction.html">COMMIT</a>. When a SAVEPOINT is the outer-most savepoint and it is not within a <a href="lang_transaction.html">BEGIN</a>...<a href="lang_transaction.html">COMMIT</a> then the behavior is the same as BEGIN DEFERRED TRANSACTION.</p> <p>The ROLLBACK TO command reverts the state of the database back to what it was just after the corresponding SAVEPOINT. Note that unlike that plain <a href="lang_transaction.html">ROLLBACK</a> command (without the TO keyword) the ROLLBACK TO command does not cancel the transaction. Instead of cancelling the transaction, the ROLLBACK TO command restarts the transaction again at the beginning. All intervening SAVEPOINTs are canceled, however.</p> <p>The RELEASE command is like a <a href="lang_transaction.html">COMMIT</a> for a SAVEPOINT. The RELEASE command causes all savepoints back to and including the most recent savepoint with a matching name to be removed from the transaction stack. The RELEASE of an inner transaction does not cause any changes to be written to the database file; it merely removes savepoints from the transaction stack such that it is no longer possible to ROLLBACK TO those savepoints. If a RELEASE command releases the outermost savepoint, so that the transaction stack becomes empty, then RELEASE is the same as <a href="lang_transaction.html">COMMIT</a>. The <a href="lang_transaction.html">COMMIT</a> command may be used to release all savepoints and commit the transaction even if the transaction was originally started by a SAVEPOINT command instead of a <a href="lang_transaction.html">BEGIN</a> command.</p> <p>If the savepoint-name in a RELEASE command does not match any savepoint currently in the transaction stack, then no savepoints are released, the database is unchanged, and the RELEASE command returns an error.</p> <p>Note that an inner transaction might commit (using the RELEASE command) but then later have its work undone by a ROLLBACK in an outer transaction. A power failure or program crash or OS crash will cause the outer-most transaction to rollback, undoing all changes that have occurred within that outer transaction, even changes that have supposedly been "committed" by the RELEASE command. Content is not actually committed on the disk until the outermost transaction commits.</p> <p>There are several ways of thinking about the RELEASE command:</p> <ul> <li><p> Some people view RELEASE as the equivalent of COMMIT for a SAVEPOINT. This is an acceptable point of view as long as one remembers that the changes committed by an inner transaction might later be undone by a rollback in an outer transaction.</p></li> <li><p> Another view of RELEASE is that it merges a named transaction into its parent transaction, so that the named transaction and its parent become the same transaction. After RELEASE, the named transaction and its parent will commit or rollback together, whatever their fate may be. </p></li> <li><p> One can also think of savepoints as "marks" in the transaction timeline. In this view, the SAVEPOINT command creates a new mark, the ROLLBACK TO command rewinds the timeline back to a point just after the named mark, and the RELEASE command erases marks from the timeline without actually making any changes to the database. </p></li> </ul> <h3>Transaction Nesting Rules</h3> <p>The last transaction started will be the first transaction committed or rolled back.</p> <p>The <a href="lang_transaction.html">BEGIN</a> command only works if the transaction stack is empty, or in other words if there are no pending transactions. If the transaction stack is not empty when the <a href="lang_transaction.html">BEGIN</a> command is invoked, then the command fails with an error.</p> <p>The <a href="lang_transaction.html">COMMIT</a> command commits all outstanding transactions and leaves the transaction stack empty.</p> <p>The RELEASE command starts with the most recent addition to the transaction stack and releases savepoints backwards in time until it releases a savepoint with a matching savepoint-name. Prior savepoints, even savepoints with matching savepoint-names, are unchanged. If the RELEASE command causes the transaction stack to become empty (if the RELEASE command releases the outermost transaction from the stack) then the transaction commits.</p> <p>The <a href="lang_transaction.html">ROLLBACK</a> command without a TO clause rolls backs all transactions and leaves the transaction stack empty.</p> <p>The ROLLBACK command with a TO clause rolls back transactions going backwards in time back to the most recent SAVEPOINT with a matching name. The SAVEPOINT with the matching name remains on the transaction stack, but all database changes that occurred after that SAVEPOINT was created are rolled back. If the savepoint-name in a ROLLBACK TO command does not match any SAVEPOINT on the stack, then the ROLLBACK command fails with an error and leaves the state of the database unchanged.</p> |
Changes to Doc/Extra/Core/lang_select.html.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 |
<html dir="LTR" xmlns="http://www.w3.org/1999/xhtml" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:MSHelp="http://msdn.microsoft.com/mshelp" xmlns:tool="http://www.microsoft.com/tooltip" xmlns:ndoc="urn:ndoc-preprocess"> <head> <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252" /> <title>SELECT</title> <link rel="stylesheet" type="text/css" href="../Include/ndoc.css" /> </head> <body> <div id="header"> <table width="100%" id="topTable"> <tr id="headerTableRow1"> <td align="left"> <span id="runningHeaderText">SELECT</span> </td> </tr> <tr id="headerTableRow2"> <td align="left"> <span id="nsrTitle">SQLite Language Reference Documentation</span> </td> </tr> <tr id="headerTableRow3" style="display:none"> <td> <a id="seeAlsoSectionLink" href="#seeAlsoToggle" onclick="OpenSection(seeAlsoToggle)">See Also</a> <a id="exampleSectionLink" href="#codeExampleToggle" onclick="OpenSection(codeExampleToggle)">Example</a> </td> </tr> </table> <table width="100%" id="bottomTable" cellspacing="0" cellpadding="0" style="display:none"> <tr> <td> <span onclick="ExpandCollapseAll(toggleAllImage)" style="cursor:default;" onkeypress="ExpandCollapseAll_CheckKey(toggleAllImage)" tabindex="0"> <img ID="toggleAllImage" class="toggleAll" src="collall.gif" /> <label id="collapseAllLabel" for="toggleAllImage" style="display: none;"> Collapse All </label> <label id="expandAllLabel" for="toggleAllImage" style="display: none;"> Expand All </label> </span> </td> </tr> </table> </div> <div id="mainSection"> <div id="mainBody"> <h1 class="heading"> SQL As Understood By SQLite</h1> <h4> SELECT</h4> <p> <table cellpadding="10"> <tr> <td align="right" width="1%" nowrap> <i><font color="#ff3434">sql-statement</font></i> ::=</td> <td> <b><font color="#2c2cf0">SELECT </font></b>[<b><font color="#2c2cf0">ALL </font></b> <big>|</big><b><font color="#2c2cf0"> DISTINCT</font></b>]<b><font color="#2c2cf0"> </font></b><i><font color="#ff3434">result</font></i><b><font color="#2c2cf0"> </font> </b>[<b><font color="#2c2cf0">FROM </font></b><i><font color="#ff3434">table-list</font></i><b><font color="#2c2cf0"></font></b>]<b><font color="#2c2cf0"><br /> </font></b>[<b><font color="#2c2cf0">WHERE </font></b><i><font color="#ff3434">expr</font></i><b><font color="#2c2cf0"></font></b>]<b><font color="#2c2cf0"><br /> </font></b>[<b><font color="#2c2cf0">GROUP BY </font></b><i><font color="#ff3434"> expr-list</font></i><b><font color="#2c2cf0"></font></b>]<b><font color="#2c2cf0"><br /> </font></b>[<b><font color="#2c2cf0">HAVING </font></b><i><font color="#ff3434">expr</font></i><b><font color="#2c2cf0"></font></b>]<b><font color="#2c2cf0"><br /> </font></b>[<b><font color="#2c2cf0"></font></b><i><font color="#ff3434">compound-op</font></i><b><font color="#2c2cf0"> </font></b><i><font color="#ff3434">select</font></i><b><font color="#2c2cf0"></font></b>]<b><font color="#2c2cf0"></font></b><big>*</big><b><font color="#2c2cf0"><br /> </font></b>[<b><font color="#2c2cf0">ORDER BY </font></b><i><font color="#ff3434"> sort-expr-list</font></i><b><font color="#2c2cf0"></font></b>]<b><font color="#2c2cf0"><br /> </font></b>[<b><font color="#2c2cf0">LIMIT </font></b><i><font color="#ff3434">integer</font></i><b><font color="#2c2cf0"> </font></b>[<b><font color="#2c2cf0"></font></b>(<b><font color="#2c2cf0"> OFFSET </font></b><big>|</big><b><font color="#2c2cf0"> <big>,</big> </font></b> )<b><font color="#2c2cf0"> </font></b><i><font color="#ff3434">integer</font></i><b><font color="#2c2cf0"></font></b>]<b><font color="#2c2cf0"></font></b>]<b><font color="#2c2cf0"></font></b></td> </tr> <tr> <td align="right" width="1%" nowrap> <i><font color="#ff3434">result</font></i> ::=</td> <td> <b><font color="#2c2cf0"></font></b><i><font color="#ff3434">result-column</font></i><b><font color="#2c2cf0"> </font></b>[<b><font color="#2c2cf0"><big>,</big> </font></b> <i><font color="#ff3434">result-column</font></i><b><font color="#2c2cf0"></font></b>]<b><font color="#2c2cf0"></font></b><big>*</big><b><font color="#2c2cf0"></font></b></td> </tr> <tr> <td align="right" width="1%" nowrap> <i><font color="#ff3434">result-column</font></i> ::=</td> <td> <b><font color="#2c2cf0"><big>*</big> </font></b><big>|</big><b><font color="#2c2cf0"> </font></b><i><font color="#ff3434">table-name</font></i><b><font color="#2c2cf0"> <big>.</big> <big>*</big> </font></b><big>|</big><b><font color="#2c2cf0"> </font> </b><i><font color="#ff3434">expr</font></i><b><font color="#2c2cf0"> </font></b> [<b><font color="#2c2cf0"> </font></b>[<b><font color="#2c2cf0">AS</font></b>]<b><font color="#2c2cf0"> </font></b><i><font color="#ff3434">string</font></i><b><font color="#2c2cf0"> </font></b>]<b><font color="#2c2cf0"></font></b></td> </tr> <tr> <td align="right" width="1%" nowrap> <i><font color="#ff3434">table-list</font></i> ::=</td> <td> <b><font color="#2c2cf0"></font></b><i><font color="#ff3434">table</font></i><b><font color="#2c2cf0"> </font></b>[<b><font color="#2c2cf0"></font></b><i><font color="#ff3434">join-op</font></i><b><font color="#2c2cf0"> </font></b><i><font color="#ff3434">table</font></i><b><font color="#2c2cf0"> </font></b><i><font color="#ff3434">join-args</font></i><b><font color="#2c2cf0"></font></b>]<b><font color="#2c2cf0"></font></b><big>*</big><b><font color="#2c2cf0"></font></b></td> </tr> <tr> <td align="right" width="1%" nowrap> <i><font color="#ff3434">table</font></i> ::=</td> <td> <b><font color="#2c2cf0"></font></b><i><font color="#ff3434">table-name</font></i><b><font color="#2c2cf0"> </font></b>[<b><font color="#2c2cf0">AS </font></b><i><font color="#ff3434"> alias</font></i><b><font color="#2c2cf0"></font></b>]<b><font color="#2c2cf0"> </font> </b><big>|</big><b><font color="#2c2cf0"><br /> <big>(</big> </font></b><i><font color="#ff3434">select</font></i><b><font color="#2c2cf0"> <big>)</big> </font></b>[<b><font color="#2c2cf0">AS </font></b><i><font color="#ff3434"> alias</font></i><b><font color="#2c2cf0"></font></b>]<b><font color="#2c2cf0"></font></b></td> </tr> <tr> <td align="right" width="1%" nowrap> <i><font color="#ff3434">join-op</font></i> ::=</td> <td> <b><font color="#2c2cf0"><big>,</big> </font></b><big>|</big><b><font color="#2c2cf0"> </font></b>[<b><font color="#2c2cf0">NATURAL</font></b>]<b><font color="#2c2cf0"> </font></b>[<b><font color="#2c2cf0">LEFT </font></b><big>|</big><b><font color="#2c2cf0"> RIGHT </font></b><big>|</big><b><font color="#2c2cf0"> FULL</font></b>]<b><font color="#2c2cf0"> </font></b>[<b><font color="#2c2cf0">OUTER </font></b><big>|</big><b><font color="#2c2cf0"> INNER </font></b><big>|</big><b><font color="#2c2cf0"> CROSS</font></b>]<b><font color="#2c2cf0"> JOIN</font></b></td> </tr> <tr> <td align="right" width="1%" nowrap> <i><font color="#ff3434">join-args</font></i> ::=</td> <td> <b><font color="#2c2cf0"></font></b>[<b><font color="#2c2cf0">ON </font></b><i><font color="#ff3434">expr</font></i><b><font color="#2c2cf0"></font></b>]<b><font color="#2c2cf0"> </font></b>[<b><font color="#2c2cf0">USING <big>(</big> </font></b><i><font color="#ff3434"> id-list</font></i><b><font color="#2c2cf0"> <big>)</big></font></b>]<b><font color="#2c2cf0"></font></b></td> </tr> <tr> <td align="right" width="1%" nowrap> <i><font color="#ff3434">sort-expr-list</font></i> ::=</td> <td> <b><font color="#2c2cf0"></font></b><i><font color="#ff3434">expr</font></i><b><font color="#2c2cf0"> </font></b>[<b><font color="#2c2cf0"></font></b><i><font color="#ff3434">sort-order</font></i><b><font color="#2c2cf0"></font></b>]<b><font color="#2c2cf0"> </font></b>[<b><font color="#2c2cf0"><big>,</big> </font></b><i><font color="#ff3434">expr</font></i><b><font color="#2c2cf0"> </font> </b>[<b><font color="#2c2cf0"></font></b><i><font color="#ff3434">sort-order</font></i><b><font color="#2c2cf0"></font></b>]<b><font color="#2c2cf0"></font></b>]<b><font color="#2c2cf0"></font></b><big>*</big><b><font color="#2c2cf0"></font></b></td> </tr> <tr> <td align="right" width="1%" nowrap> <i><font color="#ff3434">sort-order</font></i> ::=</td> <td> <b><font color="#2c2cf0"></font></b>[<b><fo |