System.Data.SQLite
Changes On Branch trunk
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Changes In Branch trunk Excluding Merge-Ins

This is equivalent to a diff from 555d0d530d to 7727af784b

2019-10-27
20:40
Final updates for release 1.0.112.0. Leaf check-in: 7727af784b user: mistachkin tags: trunk, release, release-1.0.112.0
20:34
Updates to the downloads page for the 1.0.112.0 release. Closed-Leaf check-in: 3e703548c9 user: mistachkin tags: preRelease
06:22
Stop using table elements on the main page. check-in: c6e0a65015 user: mistachkin tags: trunk
2010-11-24
14:29
Remove a duplicate DLL whose name differs only in case. check-in: 7f9e634bf5 user: drh tags: trunk
2010-08-15
22:10
Fix guid type Closed-Leaf check-in: 555d0d530d user: rmsimpson tags: sourceforge
2010-08-11
16:17
Updates for take and skip check-in: fc483e780a user: rmsimpson tags: sourceforge

Added .fossil-settings/crnl-glob.

            1  +*

Added .fossil-settings/ignore-glob.

            1  +Externals/Eagle/bin/netFramework40/Eagle*.pdb
            2  +Externals/Eagle/bin/netFramework40/x64/Spilornis.pdb
            3  +Externals/Eagle/bin/netFramework40/x86/Spilornis.pdb
            4  +Externals/Eagle/bin/netStandard20/Eagle*.pdb
            5  +Externals/Eagle/bin/netStandard21/Eagle*.pdb

Added Doc/Extra/Core/images/sqlite370_banner.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/column-name-list.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/foreign-key-clause.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-operator.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/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/upsert-clause.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  +<!DOCTYPE html>
            2  +<html><head>
            3  +<meta name="viewport" content="width=device-width, initial-scale=1.0">
            4  +<meta http-equiv="content-type" content="text/html; charset=UTF-8">
            5  +<link href="sqlite.css" rel="stylesheet">
            6  +<title>Query Language Understood by SQLite</title>
            7  +<!-- path= -->
            8  +</head>
            9  +<body>
           10  +<div class=nosearch>
           11  +<a href="index.html">
           12  +<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
           13  +</a>
           14  +<div><!-- IE hack to prevent disappearing logo --></div>
           15  +<div class="tagline desktoponly">
           16  +Small. Fast. Reliable.<br>Choose any three.
           17  +</div>
           18  +<div class="menu mainmenu">
           19  +<ul>
           20  +<li><a href="index.html">Home</a>
           21  +<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
           22  +<li class='wideonly'><a href='about.html'>About</a>
           23  +<li class='desktoponly'><a href="docs.html">Documentation</a>
           24  +<li class='desktoponly'><a href="download.html">Download</a>
           25  +<li class='wideonly'><a href='copyright.html'>License</a>
           26  +<li class='desktoponly'><a href="support.html">Support</a>
           27  +<li class='desktoponly'><a href="prosupport.html">Purchase</a>
           28  +<li class='search' id='search_menubutton'>
           29  +<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
           30  +</ul>
           31  +</div>
           32  +<div class="menu submenu" id="submenu">
           33  +<ul>
           34  +<li><a href='about.html'>About</a>
           35  +<li><a href='docs.html'>Documentation</a>
           36  +<li><a href='download.html'>Download</a>
           37  +<li><a href='support.html'>Support</a>
           38  +<li><a href='prosupport.html'>Purchase</a>
           39  +</ul>
           40  +</div>
           41  +<div class="searchmenu" id="searchmenu">
           42  +<form method="GET" action="search">
           43  +<select name="s" id="searchtype">
           44  +<option value="d">Search Documentation</option>
           45  +<option value="c">Search Changelog</option>
           46  +</select>
           47  +<input type="text" name="q" id="searchbox" value="">
           48  +<input type="submit" value="Go">
           49  +</form>
           50  +</div>
           51  +</div>
           52  +<script>
           53  +function toggle_div(nm) {
           54  +var w = document.getElementById(nm);
           55  +if( w.style.display=="block" ){
           56  +w.style.display = "none";
           57  +}else{
           58  +w.style.display = "block";
           59  +}
           60  +}
           61  +function toggle_search() {
           62  +var w = document.getElementById("searchmenu");
           63  +if( w.style.display=="block" ){
           64  +w.style.display = "none";
           65  +} else {
           66  +w.style.display = "block";
           67  +setTimeout(function(){
           68  +document.getElementById("searchbox").focus()
           69  +}, 30);
           70  +}
           71  +}
           72  +function div_off(nm){document.getElementById(nm).style.display="none";}
           73  +window.onbeforeunload = function(e){div_off("submenu");}
           74  +/* Disable the Search feature if we are not operating from CGI, since */
           75  +/* Search is accomplished using CGI and will not work without it. */
           76  +if( !location.origin.match || !location.origin.match(/http/) ){
           77  +document.getElementById("search_menubutton").style.display = "none";
           78  +}
           79  +/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
           80  +function hideorshow(btn,obj){
           81  +var x = document.getElementById(obj);
           82  +var b = document.getElementById(btn);
           83  +if( x.style.display!='none' ){
           84  +x.style.display = 'none';
           85  +b.innerHTML='show';
           86  +}else{
           87  +x.style.display = '';
           88  +b.innerHTML='hide';
           89  +}
           90  +return false;
           91  +}
           92  +</script>
           93  +</div>
           94  +
           95  +
           96  +<h1 align=center>SQL As Understood By SQLite</h1>
           97  +
           98  +<p>SQLite understands most of the standard SQL
           99  +language.  But it does <a href="omitted.html">omit some features</a>
          100  +while at the same time
          101  +adding a few features of its own.  This document attempts to
          102  +describe precisely what parts of the SQL language SQLite does
          103  +and does not support.  A list of <a href="lang_keywords.html">SQL keywords</a> is 
          104  +also provided.  The SQL language syntax is described by
          105  +<a href="syntaxdiagrams.html">syntax diagrams</a>.
          106  +
          107  +<p>The following syntax documentation topics are available:</p>
          108  +
          109  +<table width="100%" cellpadding="5" border="0">
          110  +<tr><td valign="top"><ul>
          111  +
          112  +<style>
          113  +#listtab31 tr td {vertical-align:top;}
          114  +</style>
          115  +<table id='listtab31' width='100%'></table>
          116  +<script>
          117  +var listitems31 = [{"u":"lang_aggfunc.html","x":"aggregate functions","s":0},
          118  +{"u":"lang_altertable.html","x":"ALTER TABLE","s":0},
          119  +{"u":"lang_analyze.html","x":"ANALYZE","s":0},
          120  +{"u":"lang_attach.html","x":"ATTACH DATABASE","s":0},
          121  +{"u":"lang_transaction.html","x":"BEGIN TRANSACTION","s":0},
          122  +{"u":"lang_comment.html","x":"comment","s":0},
          123  +{"u":"lang_transaction.html","x":"COMMIT TRANSACTION","s":0},
          124  +{"u":"lang_corefunc.html","x":"core functions","s":0},
          125  +{"u":"lang_createindex.html","x":"CREATE INDEX","s":0},
          126  +{"u":"lang_createtable.html","x":"CREATE TABLE","s":0},
          127  +{"u":"lang_createtrigger.html","x":"CREATE TRIGGER","s":0},
          128  +{"u":"lang_createview.html","x":"CREATE VIEW","s":0},
          129  +{"u":"lang_createvtab.html","x":"CREATE VIRTUAL TABLE","s":0},
          130  +{"u":"lang_datefunc.html","x":"date and time functions","s":0},
          131  +{"u":"lang_delete.html","x":"DELETE","s":0},
          132  +{"u":"lang_detach.html","x":"DETACH DATABASE","s":0},
          133  +{"u":"lang_dropindex.html","x":"DROP INDEX","s":0},
          134  +{"u":"lang_droptable.html","x":"DROP TABLE","s":0},
          135  +{"u":"lang_droptrigger.html","x":"DROP TRIGGER","s":0},
          136  +{"u":"lang_dropview.html","x":"DROP VIEW","s":0},
          137  +{"u":"lang_transaction.html","x":"END TRANSACTION","s":0},
          138  +{"u":"lang_explain.html","x":"EXPLAIN","s":0},
          139  +{"u":"lang_expr.html","x":"expression","s":0},
          140  +{"u":"lang_indexedby.html","x":"INDEXED BY","s":0},
          141  +{"u":"lang_insert.html","x":"INSERT","s":0},
          142  +{"u":"lang_keywords.html","x":"keywords","s":0},
          143  +{"u":"lang_conflict.html","x":"ON CONFLICT clause","s":0},
          144  +{"u":"pragma.html#syntax","x":"PRAGMA","s":0},
          145  +{"u":"lang_reindex.html","x":"REINDEX","s":0},
          146  +{"u":"lang_savepoint.html","x":"RELEASE SAVEPOINT","s":0},
          147  +{"u":"lang_replace.html","x":"REPLACE","s":0},
          148  +{"u":"lang_transaction.html","x":"ROLLBACK TRANSACTION","s":0},
          149  +{"u":"lang_savepoint.html","x":"SAVEPOINT","s":0},
          150  +{"u":"lang_select.html","x":"SELECT","s":0},
          151  +{"u":"lang_update.html","x":"UPDATE","s":0},
          152  +{"u":"lang_UPSERT.html","x":"UPSERT","s":0},
          153  +{"u":"lang_vacuum.html","x":"VACUUM","s":0},
          154  +{"u":"lang_with.html","x":"WITH clause","s":0}];
          155  +var j = 0;
          156  +var w = Math.max(document.documentElement.clientWidth,  window.innerWidth || 0);
          157  +var nCol = Math.floor(w/340);
          158  +if(nCol<=0) nCol=1;
          159  +var nRow = Math.ceil((listitems31.length+1)/nCol);
          160  +var h="<tr><td><ul class='multicol_list'>"
          161  +var ea
          162  +for(var i=0; i<listitems31.length; i++){
          163  +  if( (++j)>nRow ){
          164  +    h += "</ul></td>\n<td><ul class='multicol_list'>\n";
          165  +    j = 1;
          166  +  }
          167  +  if(listitems31[i].u=="" || listitems31[i].s==2){
          168  +    h += "<li>"
          169  +    ea = ""
          170  +  }else{
          171  +    h += "<li><a href='";
          172  +    h += listitems31[i].u;
          173  +    h += "'>";
          174  +    ea = "</a>"
          175  +  }
          176  +  if(listitems31[i].s==2 || listitems31[i].s==3) h += "<s>"
          177  +  h += listitems31[i].x;
          178  +  if(listitems31[i].s==2 || listitems31[i].s==3) h += "</s>"
          179  +  h += ea
          180  +  if(listitems31[i].s==1) h += "<small><i>(exp)</i></small>\n";
          181  +  if(listitems31[i].s==3) h += "&sup1\n";
          182  +  if(listitems31[i].s==4) h += "&sup2\n";
          183  +  if(listitems31[i].s==5) h += "&sup3\n";
          184  +}
          185  +document.getElementById("listtab31").innerHTML = h;
          186  +</script>
          187  +
          188  +</ul></td></tr></table>
          189  +
          190  +<p>The routines <a href="c3ref/prepare.html">sqlite3_prepare_v2()</a>, <a href="c3ref/prepare.html">sqlite3_prepare()</a>,
          191  +<a href="c3ref/prepare.html">sqlite3_prepare16()</a>, <a href="c3ref/prepare.html">sqlite3_prepare16_v2()</a>, 
          192  +<a href="c3ref/exec.html">sqlite3_exec()</a>, and <a href="c3ref/free_table.html">sqlite3_get_table()</a> accept
          193  +an SQL statement list (sql-stmt-list) which is a semicolon-separated
          194  +list of statements.</p>
          195  +
          196  +<p><b><a href="syntax/sql-stmt-list.html">sql-stmt-list:</a></b></p><div class='imgcontainer'>
          197  + <img alt="syntax diagram sql-stmt-list" src="images/syntax/sql-stmt-list.gif"></img>
          198  + </div>
          199  +
          200  +
          201  +<p>Each SQL statement in the statement list is an instance of the
          202  +following:</p>
          203  +
          204  +<p><b><a href="syntax/sql-stmt.html">sql-stmt:</a></b></p><div class='imgcontainer'>
          205  + <img alt="syntax diagram sql-stmt" src="images/syntax/sql-stmt.gif"></img>
          206  + </div>
          207  +
          208  +
          209  +

Added Doc/Extra/Core/lang_UPSERT.html.

            1  +<!DOCTYPE html>
            2  +<html><head>
            3  +<meta name="viewport" content="width=device-width, initial-scale=1.0">
            4  +<meta http-equiv="content-type" content="text/html; charset=UTF-8">
            5  +<link href="sqlite.css" rel="stylesheet">
            6  +<title>SQLite Query Language: upsert</title>
            7  +<!-- path= -->
            8  +</head>
            9  +<body>
           10  +<div class=nosearch>
           11  +<a href="index.html">
           12  +<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
           13  +</a>
           14  +<div><!-- IE hack to prevent disappearing logo --></div>
           15  +<div class="tagline desktoponly">
           16  +Small. Fast. Reliable.<br>Choose any three.
           17  +</div>
           18  +<div class="menu mainmenu">
           19  +<ul>
           20  +<li><a href="index.html">Home</a>
           21  +<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
           22  +<li class='wideonly'><a href='about.html'>About</a>
           23  +<li class='desktoponly'><a href="docs.html">Documentation</a>
           24  +<li class='desktoponly'><a href="download.html">Download</a>
           25  +<li class='wideonly'><a href='copyright.html'>License</a>
           26  +<li class='desktoponly'><a href="support.html">Support</a>
           27  +<li class='desktoponly'><a href="prosupport.html">Purchase</a>
           28  +<li class='search' id='search_menubutton'>
           29  +<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
           30  +</ul>
           31  +</div>
           32  +<div class="menu submenu" id="submenu">
           33  +<ul>
           34  +<li><a href='about.html'>About</a>
           35  +<li><a href='docs.html'>Documentation</a>
           36  +<li><a href='download.html'>Download</a>
           37  +<li><a href='support.html'>Support</a>
           38  +<li><a href='prosupport.html'>Purchase</a>
           39  +</ul>
           40  +</div>
           41  +<div class="searchmenu" id="searchmenu">
           42  +<form method="GET" action="search">
           43  +<select name="s" id="searchtype">
           44  +<option value="d">Search Documentation</option>
           45  +<option value="c">Search Changelog</option>
           46  +</select>
           47  +<input type="text" name="q" id="searchbox" value="">
           48  +<input type="submit" value="Go">
           49  +</form>
           50  +</div>
           51  +</div>
           52  +<script>
           53  +function toggle_div(nm) {
           54  +var w = document.getElementById(nm);
           55  +if( w.style.display=="block" ){
           56  +w.style.display = "none";
           57  +}else{
           58  +w.style.display = "block";
           59  +}
           60  +}
           61  +function toggle_search() {
           62  +var w = document.getElementById("searchmenu");
           63  +if( w.style.display=="block" ){
           64  +w.style.display = "none";
           65  +} else {
           66  +w.style.display = "block";
           67  +setTimeout(function(){
           68  +document.getElementById("searchbox").focus()
           69  +}, 30);
           70  +}
           71  +}
           72  +function div_off(nm){document.getElementById(nm).style.display="none";}
           73  +window.onbeforeunload = function(e){div_off("submenu");}
           74  +/* Disable the Search feature if we are not operating from CGI, since */
           75  +/* Search is accomplished using CGI and will not work without it. */
           76  +if( !location.origin.match || !location.origin.match(/http/) ){
           77  +document.getElementById("search_menubutton").style.display = "none";
           78  +}
           79  +/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
           80  +function hideorshow(btn,obj){
           81  +var x = document.getElementById(obj);
           82  +var b = document.getElementById(btn);
           83  +if( x.style.display!='none' ){
           84  +x.style.display = 'none';
           85  +b.innerHTML='show';
           86  +}else{
           87  +x.style.display = '';
           88  +b.innerHTML='hide';
           89  +}
           90  +return false;
           91  +}
           92  +</script>
           93  +</div>
           94  +<div class=nosearch><h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>upsert</h2></div><p><b><a href="syntax/upsert-clause.html">upsert-clause:</a></b>
           95  +<button id='x1767' onclick='hideorshow("x1767","x1768")'>hide</button></p>
           96  + <div id='x1768' class='imgcontainer'>
           97  + <img alt="syntax diagram upsert-clause" src="images/syntax/upsert-clause.gif" />
           98  +<p><b><a href="syntax/column-name-list.html">column-name-list:</a></b>
           99  +<button id='x1769' onclick='hideorshow("x1769","x1770")'>show</button></p>
          100  + <div id='x1770' style='display:none;' class='imgcontainer'>
          101  + <img alt="syntax diagram column-name-list" src="images/syntax/column-name-list.gif" />
          102  +</div>
          103  +<p><b><a href="syntax/expr.html">expr:</a></b>
          104  +<button id='x1771' onclick='hideorshow("x1771","x1772")'>show</button></p>
          105  + <div id='x1772' style='display:none;' class='imgcontainer'>
          106  + <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
          107  +<p><b><a href="syntax/filter-clause.html">filter-clause:</a></b>
          108  +<button id='x1773' onclick='hideorshow("x1773","x1774")'>show</button></p>
          109  + <div id='x1774' style='display:none;' class='imgcontainer'>
          110  + <img alt="syntax diagram filter-clause" src="images/syntax/filter-clause.gif" />
          111  +</div>
          112  +<p><b><a href="syntax/literal-value.html">literal-value:</a></b>
          113  +<button id='x1775' onclick='hideorshow("x1775","x1776")'>show</button></p>
          114  + <div id='x1776' style='display:none;' class='imgcontainer'>
          115  + <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
          116  +</div>
          117  +<p><b><a href="syntax/over-clause.html">over-clause:</a></b>
          118  +<button id='x1777' onclick='hideorshow("x1777","x1778")'>show</button></p>
          119  + <div id='x1778' style='display:none;' class='imgcontainer'>
          120  + <img alt="syntax diagram over-clause" src="images/syntax/over-clause.gif" />
          121  +<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
          122  +<button id='x1779' onclick='hideorshow("x1779","x1780")'>show</button></p>
          123  + <div id='x1780' style='display:none;' class='imgcontainer'>
          124  + <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
          125  +</div>
          126  +<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
          127  +<button id='x1781' onclick='hideorshow("x1781","x1782")'>show</button></p>
          128  + <div id='x1782' style='display:none;' class='imgcontainer'>
          129  + <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
          130  +</div>
          131  +</div>
          132  +<p><b><a href="syntax/raise-function.html">raise-function:</a></b>
          133  +<button id='x1783' onclick='hideorshow("x1783","x1784")'>show</button></p>
          134  + <div id='x1784' style='display:none;' class='imgcontainer'>
          135  + <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
          136  +</div>
          137  +<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
          138  +<button id='x1785' onclick='hideorshow("x1785","x1786")'>show</button></p>
          139  + <div id='x1786' style='display:none;' class='imgcontainer'>
          140  + <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
          141  +<p><b><a href="syntax/common-table-expression.html">common-table-expression:</a></b>
          142  +<button id='x1787' onclick='hideorshow("x1787","x1788")'>show</button></p>
          143  + <div id='x1788' style='display:none;' class='imgcontainer'>
          144  + <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
          145  +</div>
          146  +<p><b><a href="syntax/compound-operator.html">compound-operator:</a></b>
          147  +<button id='x1789' onclick='hideorshow("x1789","x1790")'>show</button></p>
          148  + <div id='x1790' style='display:none;' class='imgcontainer'>
          149  + <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
          150  +</div>
          151  +<p><b><a href="syntax/join-clause.html">join-clause:</a></b>
          152  +<button id='x1791' onclick='hideorshow("x1791","x1792")'>show</button></p>
          153  + <div id='x1792' style='display:none;' class='imgcontainer'>
          154  + <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
          155  +<p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
          156  +<button id='x1793' onclick='hideorshow("x1793","x1794")'>show</button></p>
          157  + <div id='x1794' style='display:none;' class='imgcontainer'>
          158  + <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
          159  +</div>
          160  +<p><b><a href="syntax/join-operator.html">join-operator:</a></b>
          161  +<button id='x1795' onclick='hideorshow("x1795","x1796")'>show</button></p>
          162  + <div id='x1796' style='display:none;' class='imgcontainer'>
          163  + <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
          164  +</div>
          165  +</div>
          166  +<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
          167  +<button id='x1797' onclick='hideorshow("x1797","x1798")'>show</button></p>
          168  + <div id='x1798' style='display:none;' class='imgcontainer'>
          169  + <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
          170  +</div>
          171  +<p><b><a href="syntax/result-column.html">result-column:</a></b>
          172  +<button id='x1799' onclick='hideorshow("x1799","x1800")'>show</button></p>
          173  + <div id='x1800' style='display:none;' class='imgcontainer'>
          174  + <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
          175  +</div>
          176  +<p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
          177  +<button id='x1801' onclick='hideorshow("x1801","x1802")'>show</button></p>
          178  + <div id='x1802' style='display:none;' class='imgcontainer'>
          179  + <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
          180  +</div>
          181  +<p><b><a href="syntax/window-defn.html">window-defn:</a></b>
          182  +<button id='x1803' onclick='hideorshow("x1803","x1804")'>show</button></p>
          183  + <div id='x1804' style='display:none;' class='imgcontainer'>
          184  + <img alt="syntax diagram window-defn" src="images/syntax/window-defn.gif" />
          185  +<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
          186  +<button id='x1805' onclick='hideorshow("x1805","x1806")'>show</button></p>
          187  + <div id='x1806' style='display:none;' class='imgcontainer'>
          188  + <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
          189  +</div>
          190  +</div>
          191  +</div>
          192  +<p><b><a href="syntax/type-name.html">type-name:</a></b>
          193  +<button id='x1807' onclick='hideorshow("x1807","x1808")'>show</button></p>
          194  + <div id='x1808' style='display:none;' class='imgcontainer'>
          195  + <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
          196  +<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
          197  +<button id='x1809' onclick='hideorshow("x1809","x1810")'>show</button></p>
          198  + <div id='x1810' style='display:none;' class='imgcontainer'>
          199  + <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
          200  +</div>
          201  +</div>
          202  +</div>
          203  +<p><b><a href="syntax/indexed-column.html">indexed-column:</a></b>
          204  +<button id='x1811' onclick='hideorshow("x1811","x1812")'>show</button></p>
          205  + <div id='x1812' style='display:none;' class='imgcontainer'>
          206  + <img alt="syntax diagram indexed-column" src="images/syntax/indexed-column.gif" />
          207  +</div>
          208  +</div>
          209  +
          210  +
          211  +<p>UPSERT is a special syntax addition to <a href="lang_insert.html">INSERT</a> that causes the
          212  +INSERT to behave as an <a href="lang_update.html">UPDATE</a> or a no-op if the INSERT would violate
          213  +a uniqueness constraint.
          214  +UPSERT is not standard SQL.  UPSERT in SQLite follows the
          215  +syntax established by PostgreSQL.
          216  +UPSERT syntax was added to SQLite with version 3.24.0 (2018-06-04).
          217  +
          218  +<p>An UPSERT is an ordinary <a href="lang_insert.html">INSERT</a> statement that is followed by
          219  +the special ON CONFLICT clause shown above.
          220  +
          221  +<p>The syntax that occurs in between the "ON CONFLICT" and "DO" keywords
          222  +is called the "conflict target".  The conflict target specifies a specific
          223  +uniqueness constraint that will trigger the upsert.  The conflict target
          224  +is required for DO UPDATE upserts, but is optional for DO NOTHING.  When
          225  +the conflict target is omitted, the upsert behavior is triggered by a
          226  +violation of any uniqueness constraint on the table of the INSERT.
          227  +
          228  +<p>If the insert operation would cause the uniqueness constraint identified
          229  +by the conflict-target clause to fail, then the insert is omitted and
          230  +either the DO NOTHING or DO UPDATE operation is performed instead.
          231  +In the case of a multi-row insert, this decision is made separately
          232  +for each row of the insert.
          233  +
          234  +<p>The special UPSERT processing happens only for uniqueness constraint on
          235  +the table that is receiving the INSERT. A "uniqueness constraint"
          236  +is an explicit UNIQUE or PRIMARY KEY constraint within
          237  +the CREATE TABLE statement, or a <a href="lang_createindex.html#uniqueidx">unique index</a>.
          238  +UPSERT does not intervene for failed NOT NULL or foreign key constraints
          239  +or for constraints that are implemented using triggers.
          240  +
          241  +<p>Column names in the expressions of a DO UPDATE refer to the original
          242  +unchanged value of the column, before the attempted INSERT.  To use the
          243  +value that would have been inserted had the constraint not failed,
          244  +add the special "excluded." table qualifier to the column name.
          245  +
          246  +<p>Some examples will help illustrate the difference:
          247  +
          248  +<blockquote><pre>
          249  +CREATE TABLE vocabulary(word TEXT PRIMARY KEY, count INT DEFAULT 1);
          250  +INSERT INTO vocabulary(word) VALUES('jovial')
          251  +  ON CONFLICT(word) DO UPDATE SET count=count+1;
          252  +</pre></blockquote>
          253  +
          254  +<p>The upsert above inserts the new vocabulary word "jovial" if that
          255  +word is not already in the dictionary, or if it is already in the
          256  +dictionary, it increments the counter.  The "count+1" expression
          257  +could also be written as "vocabulary.count".  PostgreSQL requires the
          258  +second form, but SQLite accepts either.
          259  +
          260  +<blockquote><pre>
          261  +CREATE TABLE phonebook(name TEXT PRIMARY KEY, phonenumber TEXT);
          262  +INSERT INTO phonebook(name,phonenumber) VALUES('Alice','704-555-1212')
          263  +  ON CONFLICT(name) DO UPDATE SET phonenumber=excluded.phonenumber;
          264  +</pre></blockquote>
          265  +
          266  +<p>In the second example, the expression in the DO UPDATE clause is
          267  +of the form "excluded.phonenumber".  The "excluded." prefix causes the
          268  +"phonenumber" to refer to the value for phonenumber that would have been
          269  +inserted had there been no conflict.  Hence, the effect of the upsert
          270  +is to insert a phonenumber of Alice if none exists, or to overwrite
          271  +any prior phonenumber for Alice with the new one.
          272  +
          273  +<p>Note that the DO UPDATE clause acts only on the single row
          274  +that experienced the constraint error during INSERT.  It is not
          275  +necessary to include a WHERE clause that restrictions the action
          276  +to that one row.  The only use for the WHERE clause at
          277  +the end of the DO UPDATE is to optionally change the DO UPDATE
          278  +into a no-op depending on the original and/or new values.
          279  +For example:
          280  +
          281  +<blockquote><pre>
          282  +CREATE TABLE phonebook2(
          283  +  name TEXT PRIMARY KEY,
          284  +  phonenumber TEXT,
          285  +  validDate DATE
          286  +);
          287  +INSERT INTO phonebook2(name,phonenumber,validDate)
          288  +  VALUES('Alice','704-555-1212','2018-05-08')
          289  +  ON CONFLICT(name) DO UPDATE SET
          290  +    phonenumber=excluded.phonenumber,
          291  +    validDate=excluded.validDate
          292  +  WHERE excluded.validDate>phonebook2.validDate;
          293  +</pre></blockquote>
          294  +
          295  +<p>In this last example, the phonebook2 entry is only
          296  +updated if the validDate for the newly inserted value is
          297  +newer than the entry already in the table.  If the table already
          298  +contains an entry with the same name and a current validDate,
          299  +then the WHERE clause causes the DO UPDATE to become a no-op.
          300  +
          301  +<a name="parseambig"></a>
          302  +
          303  +<h3>Parsing Ambiguity</h3>
          304  +
          305  +<p>When the <a href="lang_insert.html">INSERT</a> statement to which the UPSERT is attached
          306  +takes its values from a <a href="lang_select.html">SELECT</a> statement, there is a potential
          307  +parsing ambiguity.  The parser might not be able to tell if the
          308  +"ON" keyword is introducing the UPSERT or if it is the ON clause
          309  +of a join.  To work around this, the SELECT statement should always
          310  +include a WHERE clause, even if that WHERE clause is just
          311  +"WHERE true".
          312  +
          313  +<p>Ambiguous use of ON:
          314  +
          315  +<blockquote><pre>
          316  +INSERT INTO t1 SELECT * FROM t2
          317  +ON CONFLICT(x) DO UPDATE SET y=excluded.y;
          318  +</pre></blockquote>
          319  +
          320  +<p>Ambiguity resolved using a WHERE clause:
          321  +
          322  +<blockquote><pre>
          323  +INSERT INTO t1 SELECT * FROM t2 <font color="blue">WHERE true</font>
          324  +ON CONFLICT(x) DO UPDATE SET y=excluded.y;
          325  +</pre></blockquote>
          326  +
          327  +<h3>Limitations</h3>
          328  +
          329  +<p>UPSERT does not currently work for <a href="vtab.html">virtual tables</a>.
          330  +
          331  +
          332  +

Added Doc/Extra/Core/lang_aggfunc.html.

            1  +<!DOCTYPE html>
            2  +<html><head>
            3  +<meta name="viewport" content="width=device-width, initial-scale=1.0">
            4  +<meta http-equiv="content-type" content="text/html; charset=UTF-8">
            5  +<link href="sqlite.css" rel="stylesheet">
            6  +<title>SQLite Query Language: Aggregate Functions</title>
            7  +<!-- path= -->
            8  +</head>
            9  +<body>
           10  +<div class=nosearch>
           11  +<a href="index.html">
           12  +<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
           13  +</a>
           14  +<div><!-- IE hack to prevent disappearing logo --></div>
           15  +<div class="tagline desktoponly">
           16  +Small. Fast. Reliable.<br>Choose any three.
           17  +</div>
           18  +<div class="menu mainmenu">
           19  +<ul>
           20  +<li><a href="index.html">Home</a>
           21  +<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
           22  +<li class='wideonly'><a href='about.html'>About</a>
           23  +<li class='desktoponly'><a href="docs.html">Documentation</a>
           24  +<li class='desktoponly'><a href="download.html">Download</a>
           25  +<li class='wideonly'><a href='copyright.html'>License</a>
           26  +<li class='desktoponly'><a href="support.html">Support</a>
           27  +<li class='desktoponly'><a href="prosupport.html">Purchase</a>
           28  +<li class='search' id='search_menubutton'>
           29  +<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
           30  +</ul>
           31  +</div>
           32  +<div class="menu submenu" id="submenu">
           33  +<ul>
           34  +<li><a href='about.html'>About</a>
           35  +<li><a href='docs.html'>Documentation</a>
           36  +<li><a href='download.html'>Download</a>
           37  +<li><a href='support.html'>Support</a>
           38  +<li><a href='prosupport.html'>Purchase</a>
           39  +</ul>
           40  +</div>
           41  +<div class="searchmenu" id="searchmenu">
           42  +<form method="GET" action="search">
           43  +<select name="s" id="searchtype">
           44  +<option value="d">Search Documentation</option>
           45  +<option value="c">Search Changelog</option>
           46  +</select>
           47  +<input type="text" name="q" id="searchbox" value="">
           48  +<input type="submit" value="Go">
           49  +</form>
           50  +</div>
           51  +</div>
           52  +<script>
           53  +function toggle_div(nm) {
           54  +var w = document.getElementById(nm);
           55  +if( w.style.display=="block" ){
           56  +w.style.display = "none";
           57  +}else{
           58  +w.style.display = "block";
           59  +}
           60  +}
           61  +function toggle_search() {
           62  +var w = document.getElementById("searchmenu");
           63  +if( w.style.display=="block" ){
           64  +w.style.display = "none";
           65  +} else {
           66  +w.style.display = "block";
           67  +setTimeout(function(){
           68  +document.getElementById("searchbox").focus()
           69  +}, 30);
           70  +}
           71  +}
           72  +function div_off(nm){document.getElementById(nm).style.display="none";}
           73  +window.onbeforeunload = function(e){div_off("submenu");}
           74  +/* Disable the Search feature if we are not operating from CGI, since */
           75  +/* Search is accomplished using CGI and will not work without it. */
           76  +if( !location.origin.match || !location.origin.match(/http/) ){
           77  +document.getElementById("search_menubutton").style.display = "none";
           78  +}
           79  +/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
           80  +function hideorshow(btn,obj){
           81  +var x = document.getElementById(obj);
           82  +var b = document.getElementById(btn);
           83  +if( x.style.display!='none' ){
           84  +x.style.display = 'none';
           85  +b.innerHTML='show';
           86  +}else{
           87  +x.style.display = '';
           88  +b.innerHTML='hide';
           89  +}
           90  +return false;
           91  +}
           92  +</script>
           93  +</div>
           94  +<div class=nosearch><h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>Aggregate Functions</h2></div>
           95  +
           96  +
           97  +<p><b><a href="syntax/aggregate-function-invocation.html">aggregate-function-invocation:</a></b>
           98  +<button id='x1673' onclick='hideorshow("x1673","x1674")'>hide</button></p>
           99  + <div id='x1674' class='imgcontainer'>
          100  + <img alt="syntax diagram aggregate-function-invocation" src="images/syntax/aggregate-function-invocation.gif" />
          101  +<p><b><a href="syntax/expr.html">expr:</a></b>
          102  +<button id='x1675' onclick='hideorshow("x1675","x1676")'>show</button></p>
          103  + <div id='x1676' style='display:none;' class='imgcontainer'>
          104  + <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
          105  +<p><b><a href="syntax/literal-value.html">literal-value:</a></b>
          106  +<button id='x1677' onclick='hideorshow("x1677","x1678")'>show</button></p>
          107  + <div id='x1678' style='display:none;' class='imgcontainer'>
          108  + <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
          109  +</div>
          110  +<p><b><a href="syntax/over-clause.html">over-clause:</a></b>
          111  +<button id='x1679' onclick='hideorshow("x1679","x1680")'>show</button></p>
          112  + <div id='x1680' style='display:none;' class='imgcontainer'>
          113  + <img alt="syntax diagram over-clause" src="images/syntax/over-clause.gif" />
          114  +<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
          115  +<button id='x1681' onclick='hideorshow("x1681","x1682")'>show</button></p>
          116  + <div id='x1682' style='display:none;' class='imgcontainer'>
          117  + <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
          118  +</div>
          119  +<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
          120  +<button id='x1683' onclick='hideorshow("x1683","x1684")'>show</button></p>
          121  + <div id='x1684' style='display:none;' class='imgcontainer'>
          122  + <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
          123  +</div>
          124  +</div>
          125  +<p><b><a href="syntax/raise-function.html">raise-function:</a></b>
          126  +<button id='x1685' onclick='hideorshow("x1685","x1686")'>show</button></p>
          127  + <div id='x1686' style='display:none;' class='imgcontainer'>
          128  + <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
          129  +</div>
          130  +<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
          131  +<button id='x1687' onclick='hideorshow("x1687","x1688")'>show</button></p>
          132  + <div id='x1688' style='display:none;' class='imgcontainer'>
          133  + <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
          134  +<p><b><a href="syntax/common-table-expression.html">common-table-expression:</a></b>
          135  +<button id='x1689' onclick='hideorshow("x1689","x1690")'>show</button></p>
          136  + <div id='x1690' style='display:none;' class='imgcontainer'>
          137  + <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
          138  +</div>
          139  +<p><b><a href="syntax/compound-operator.html">compound-operator:</a></b>
          140  +<button id='x1691' onclick='hideorshow("x1691","x1692")'>show</button></p>
          141  + <div id='x1692' style='display:none;' class='imgcontainer'>
          142  + <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
          143  +</div>
          144  +<p><b><a href="syntax/join-clause.html">join-clause:</a></b>
          145  +<button id='x1693' onclick='hideorshow("x1693","x1694")'>show</button></p>
          146  + <div id='x1694' style='display:none;' class='imgcontainer'>
          147  + <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
          148  +<p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
          149  +<button id='x1695' onclick='hideorshow("x1695","x1696")'>show</button></p>
          150  + <div id='x1696' style='display:none;' class='imgcontainer'>
          151  + <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
          152  +</div>
          153  +<p><b><a href="syntax/join-operator.html">join-operator:</a></b>
          154  +<button id='x1697' onclick='hideorshow("x1697","x1698")'>show</button></p>
          155  + <div id='x1698' style='display:none;' class='imgcontainer'>
          156  + <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
          157  +</div>
          158  +</div>
          159  +<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
          160  +<button id='x1699' onclick='hideorshow("x1699","x1700")'>show</button></p>
          161  + <div id='x1700' style='display:none;' class='imgcontainer'>
          162  + <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
          163  +</div>
          164  +<p><b><a href="syntax/result-column.html">result-column:</a></b>
          165  +<button id='x1701' onclick='hideorshow("x1701","x1702")'>show</button></p>
          166  + <div id='x1702' style='display:none;' class='imgcontainer'>
          167  + <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
          168  +</div>
          169  +<p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
          170  +<button id='x1703' onclick='hideorshow("x1703","x1704")'>show</button></p>
          171  + <div id='x1704' style='display:none;' class='imgcontainer'>
          172  + <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
          173  +</div>
          174  +<p><b><a href="syntax/window-defn.html">window-defn:</a></b>
          175  +<button id='x1705' onclick='hideorshow("x1705","x1706")'>show</button></p>
          176  + <div id='x1706' style='display:none;' class='imgcontainer'>
          177  + <img alt="syntax diagram window-defn" src="images/syntax/window-defn.gif" />
          178  +<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
          179  +<button id='x1707' onclick='hideorshow("x1707","x1708")'>show</button></p>
          180  + <div id='x1708' style='display:none;' class='imgcontainer'>
          181  + <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
          182  +</div>
          183  +</div>
          184  +</div>
          185  +<p><b><a href="syntax/type-name.html">type-name:</a></b>
          186  +<button id='x1709' onclick='hideorshow("x1709","x1710")'>show</button></p>
          187  + <div id='x1710' style='display:none;' class='imgcontainer'>
          188  + <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
          189  +<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
          190  +<button id='x1711' onclick='hideorshow("x1711","x1712")'>show</button></p>
          191  + <div id='x1712' style='display:none;' class='imgcontainer'>
          192  + <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
          193  +</div>
          194  +</div>
          195  +</div>
          196  +<p><b><a href="syntax/filter-clause.html">filter-clause:</a></b>
          197  +<button id='x1713' onclick='hideorshow("x1713","x1714")'>show</button></p>
          198  + <div id='x1714' style='display:none;' class='imgcontainer'>
          199  + <img alt="syntax diagram filter-clause" src="images/syntax/filter-clause.gif" />
          200  +</div>
          201  +</div>
          202  +
          203  +
          204  +<p>
          205  +The aggregate functions shown below are available by default.  Additional
          206  +aggregate functions written in C may be added using the 
          207  +<a href="c3ref/create_function.html">sqlite3_create_function()</a></a>
          208  +API.</p>
          209  +
          210  +<p>
          211  +In any aggregate function that takes a single argument, that argument
          212  +can be preceded by the keyword DISTINCT.  In such cases, duplicate
          213  +elements are filtered before being passed into the aggregate function.
          214  +For example, the function "count(distinct X)" will return the number
          215  +of distinct values of column X instead of the total number of non-null
          216  +values in column X.
          217  +</p>
          218  +
          219  +<a name="aggfilter"></a>
          220  +
          221  +<p>
          222  +If a FILTER clause is provided, then only rows for which the <i>expr</i> is
          223  +true are included in the aggregate.
          224  +</p>
          225  +
          226  +<style>
          227  +#listtab33 tr td {vertical-align:top;}
          228  +</style>
          229  +<table id='listtab33' width='100%'></table>
          230  +<script>
          231  +var listitems33 = [{"u":"lang_aggfunc.html#avg","x":"avg(X)","s":0},
          232  +{"u":"lang_aggfunc.html#count","x":"count(*)","s":0},
          233  +{"u":"lang_aggfunc.html#count","x":"count(X)","s":0},
          234  +{"u":"lang_aggfunc.html#groupconcat","x":"group_concat(X)","s":0},
          235  +{"u":"lang_aggfunc.html#groupconcat","x":"group_concat(X,Y)","s":0},
          236  +{"u":"lang_corefunc.html#maxoreunc","x":"max(X)","s":0},
          237  +{"u":"lang_corefunc.html#minoreunc","x":"min(X)","s":0},
          238  +{"u":"lang_aggfunc.html#sumunc","x":"sum(X)","s":0},
          239  +{"u":"lang_aggfunc.html#sumunc","x":"total(X)","s":0}];
          240  +var j = 0;
          241  +var w = Math.max(document.documentElement.clientWidth,  window.innerWidth || 0);
          242  +var nCol = Math.floor(w/225);
          243  +if(nCol<=0) nCol=1;
          244  +var nRow = Math.ceil((listitems33.length+1)/nCol);
          245  +var h="<tr><td><ul class='multicol_list'>"
          246  +var ea
          247  +for(var i=0; i<listitems33.length; i++){
          248  +  if( (++j)>nRow ){
          249  +    h += "</ul></td>\n<td><ul class='multicol_list'>\n";
          250  +    j = 1;
          251  +  }
          252  +  if(listitems33[i].u=="" || listitems33[i].s==2){
          253  +    h += "<li>"
          254  +    ea = ""
          255  +  }else{
          256  +    h += "<li><a href='";
          257  +    h += listitems33[i].u;
          258  +    h += "'>";
          259  +    ea = "</a>"
          260  +  }
          261  +  if(listitems33[i].s==2 || listitems33[i].s==3) h += "<s>"
          262  +  h += listitems33[i].x;
          263  +  if(listitems33[i].s==2 || listitems33[i].s==3) h += "</s>"
          264  +  h += ea
          265  +  if(listitems33[i].s==1) h += "<small><i>(exp)</i></small>\n";
          266  +  if(listitems33[i].s==3) h += "&sup1\n";
          267  +  if(listitems33[i].s==4) h += "&sup2\n";
          268  +  if(listitems33[i].s==5) h += "&sup3\n";
          269  +}
          270  +document.getElementById("listtab33").innerHTML = h;
          271  +</script>
          272  +<hr class='xhr'>
          273  +<dl>
          274  +<a name="avg"></a>
          275  +<dt><p><b>avg(<i>X</i>)</b></dt><dd><p>
          276  +  The avg() function
          277  +  returns the average value of all non-NULL <i>X</i> within a
          278  +  group.  String and BLOB values that do not look like numbers are
          279  +  interpreted as 0.
          280  +  The result of avg() is always a floating point value as long as
          281  +  at there is at least one non-NULL input even if all
          282  +  inputs are integers.  The result of avg() is NULL if and only if
          283  +  there are no non-NULL inputs.  
          284  +</dd>
          285  +<a name="count"></a>
          286  +<dt><p><b>count(<i>X</i>)<br />count(*)</b></dt><dd><p>
          287  +  The count(X) function returns
          288  +  a count of the number of times
          289  +  that <i>X</i> is not NULL in a group.  The count(*) function
          290  +  (with no arguments) returns the total number of rows in the group.
          291  +</dd>
          292  +<a name="groupconcat"></a>
          293  +<dt><p><b>group_concat(<i>X</i>)<br />group_concat(<i>X</i>,<i>Y</i>)</b></dt><dd><p>
          294  +  The group_concat() function returns
          295  +  a string which is the concatenation of
          296  +  all non-NULL values of <i>X</i>.  If parameter <i>Y</i> is present then
          297  +  it is used as the separator
          298  +  between instances of <i>X</i>.  A comma (",") is used as the separator
          299  +  if <i>Y</i> is omitted.  The order of the concatenated elements is
          300  +  arbitrary.
          301  +</dd>
          302  +<a name="maxggunc"></a>
          303  +<dt><p><b>max(<i>X</i>)</b></dt><dd><p>
          304  +  The max() aggregate function
          305  +  returns the maximum value of all values in the group.
          306  +  The maximum value is the value that would be returned last in an
          307  +  ORDER BY on the same column.  Aggregate max() returns NULL 
          308  +  if and only if there are no non-NULL values in the group.
          309  +</dd>
          310  +<a name="minggunc"></a>
          311  +<dt><p><b>min(<i>X</i>)</b></dt><dd><p>
          312  +  The min() aggregate function
          313  +  returns the minimum non-NULL value of all values in the group.
          314  +  The minimum value is the first non-NULL value that would appear
          315  +  in an ORDER BY of the column.
          316  +  Aggregate min() returns NULL if and only if there are no non-NULL
          317  +  values in the group.
          318  +</dd>
          319  +<a name="sumunc"></a>
          320  +<dt><p><b>sum(<i>X</i>)<br />total(<i>X</i>)</b></dt><dd><p>
          321  +  The sum() and total() aggregate functions
          322  +  return sum of all non-NULL values in the group.
          323  +  If there are no non-NULL input rows then sum() returns
          324  +  NULL but total() returns 0.0.
          325  +  NULL is not normally a helpful result for the sum of no rows
          326  +  but the SQL standard requires it and most other
          327  +  SQL database engines implement sum() that way so SQLite does it in the
          328  +  same way in order to be compatible.   The non-standard total() function
          329  +  is provided as a convenient way to work around this design problem
          330  +  in the SQL language.</p>
          331  +
          332  +  <p>The result of total() is always a floating point value.
          333  +  The result of sum() is an integer value if all non-NULL inputs are integers.
          334  +  If any input to sum() is neither an integer or a NULL
          335  +  then sum() returns a floating point value
          336  +  which might be an approximation to the true sum.</p>
          337  +
          338  +  <p>Sum() will throw an "integer overflow" exception if all inputs
          339  +  are integers or NULL
          340  +  and an integer overflow occurs at any point during the computation.
          341  +  Total() never throws an integer overflow.
          342  +</dd>
          343  +</dl>
          344  +

Added Doc/Extra/Core/lang_altertable.html.

            1  +<!DOCTYPE html>
            2  +<html><head>
            3  +<meta name="viewport" content="width=device-width, initial-scale=1.0">
            4  +<meta http-equiv="content-type" content="text/html; charset=UTF-8">
            5  +<link href="sqlite.css" rel="stylesheet">
            6  +<title>SQLite Query Language: ALTER TABLE</title>
            7  +<!-- path= -->
            8  +</head>
            9  +<body>
           10  +<div class=nosearch>
           11  +<a href="index.html">
           12  +<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
           13  +</a>
           14  +<div><!-- IE hack to prevent disappearing logo --></div>
           15  +<div class="tagline desktoponly">
           16  +Small. Fast. Reliable.<br>Choose any three.
           17  +</div>
           18  +<div class="menu mainmenu">
           19  +<ul>
           20  +<li><a href="index.html">Home</a>
           21  +<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
           22  +<li class='wideonly'><a href='about.html'>About</a>
           23  +<li class='desktoponly'><a href="docs.html">Documentation</a>
           24  +<li class='desktoponly'><a href="download.html">Download</a>
           25  +<li class='wideonly'><a href='copyright.html'>License</a>
           26  +<li class='desktoponly'><a href="support.html">Support</a>
           27  +<li class='desktoponly'><a href="prosupport.html">Purchase</a>
           28  +<li class='search' id='search_menubutton'>
           29  +<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
           30  +</ul>
           31  +</div>
           32  +<div class="menu submenu" id="submenu">
           33  +<ul>
           34  +<li><a href='about.html'>About</a>
           35  +<li><a href='docs.html'>Documentation</a>
           36  +<li><a href='download.html'>Download</a>
           37  +<li><a href='support.html'>Support</a>
           38  +<li><a href='prosupport.html'>Purchase</a>
           39  +</ul>
           40  +</div>
           41  +<div class="searchmenu" id="searchmenu">
           42  +<form method="GET" action="search">
           43  +<select name="s" id="searchtype">
           44  +<option value="d">Search Documentation</option>
           45  +<option value="c">Search Changelog</option>
           46  +</select>
           47  +<input type="text" name="q" id="searchbox" value="">
           48  +<input type="submit" value="Go">
           49  +</form>
           50  +</div>
           51  +</div>
           52  +<script>
           53  +function toggle_div(nm) {
           54  +var w = document.getElementById(nm);
           55  +if( w.style.display=="block" ){
           56  +w.style.display = "none";
           57  +}else{
           58  +w.style.display = "block";
           59  +}
           60  +}
           61  +function toggle_search() {
           62  +var w = document.getElementById("searchmenu");
           63  +if( w.style.display=="block" ){
           64  +w.style.display = "none";
           65  +} else {
           66  +w.style.display = "block";
           67  +setTimeout(function(){
           68  +document.getElementById("searchbox").focus()
           69  +}, 30);
           70  +}
           71  +}
           72  +function div_off(nm){document.getElementById(nm).style.display="none";}
           73  +window.onbeforeunload = function(e){div_off("submenu");}
           74  +/* Disable the Search feature if we are not operating from CGI, since */
           75  +/* Search is accomplished using CGI and will not work without it. */
           76  +if( !location.origin.match || !location.origin.match(/http/) ){
           77  +document.getElementById("search_menubutton").style.display = "none";
           78  +}
           79  +/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
           80  +function hideorshow(btn,obj){
           81  +var x = document.getElementById(obj);
           82  +var b = document.getElementById(btn);
           83  +if( x.style.display!='none' ){
           84  +x.style.display = 'none';
           85  +b.innerHTML='show';
           86  +}else{
           87  +x.style.display = '';
           88  +b.innerHTML='hide';
           89  +}
           90  +return false;
           91  +}
           92  +</script>
           93  +</div>
           94  +<div class=nosearch><h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>ALTER TABLE</h2></div><p><b><a href="syntax/alter-table-stmt.html">alter-table-stmt:</a></b>
           95  +<button id='x1191' onclick='hideorshow("x1191","x1192")'>hide</button></p>
           96  + <div id='x1192' class='imgcontainer'>
           97  + <img alt="syntax diagram alter-table-stmt" src="images/syntax/alter-table-stmt.gif" />
           98  +<p><b><a href="syntax/column-def.html">column-def:</a></b>
           99  +<button id='x1193' onclick='hideorshow("x1193","x1194")'>show</button></p>
          100  + <div id='x1194' style='display:none;' class='imgcontainer'>
          101  + <img alt="syntax diagram column-def" src="images/syntax/column-def.gif" />
          102  +<p><b><a href="syntax/column-constraint.html">column-constraint:</a></b>
          103  +<button id='x1195' onclick='hideorshow("x1195","x1196")'>show</button></p>
          104  + <div id='x1196' style='display:none;' class='imgcontainer'>
          105  + <img alt="syntax diagram column-constraint" src="images/syntax/column-constraint.gif" />
          106  +<p><b><a href="syntax/conflict-clause.html">conflict-clause:</a></b>
          107  +<button id='x1197' onclick='hideorshow("x1197","x1198")'>show</button></p>
          108  + <div id='x1198' style='display:none;' class='imgcontainer'>
          109  + <img alt="syntax diagram conflict-clause" src="images/syntax/conflict-clause.gif" />
          110  +</div>
          111  +<p><b><a href="syntax/expr.html">expr:</a></b>
          112  +<button id='x1199' onclick='hideorshow("x1199","x1200")'>show</button></p>
          113  + <div id='x1200' style='display:none;' class='imgcontainer'>
          114  + <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
          115  +<p><b><a href="syntax/filter-clause.html">filter-clause:</a></b>
          116  +<button id='x1201' onclick='hideorshow("x1201","x1202")'>show</button></p>
          117  + <div id='x1202' style='display:none;' class='imgcontainer'>
          118  + <img alt="syntax diagram filter-clause" src="images/syntax/filter-clause.gif" />
          119  +</div>
          120  +<p><b><a href="syntax/over-clause.html">over-clause:</a></b>
          121  +<button id='x1203' onclick='hideorshow("x1203","x1204")'>show</button></p>
          122  + <div id='x1204' style='display:none;' class='imgcontainer'>
          123  + <img alt="syntax diagram over-clause" src="images/syntax/over-clause.gif" />
          124  +<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
          125  +<button id='x1205' onclick='hideorshow("x1205","x1206")'>show</button></p>
          126  + <div id='x1206' style='display:none;' class='imgcontainer'>
          127  + <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
          128  +</div>
          129  +<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
          130  +<button id='x1207' onclick='hideorshow("x1207","x1208")'>show</button></p>
          131  + <div id='x1208' style='display:none;' class='imgcontainer'>
          132  + <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
          133  +</div>
          134  +</div>
          135  +<p><b><a href="syntax/raise-function.html">raise-function:</a></b>
          136  +<button id='x1209' onclick='hideorshow("x1209","x1210")'>show</button></p>
          137  + <div id='x1210' style='display:none;' class='imgcontainer'>
          138  + <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
          139  +</div>
          140  +<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
          141  +<button id='x1211' onclick='hideorshow("x1211","x1212")'>show</button></p>
          142  + <div id='x1212' style='display:none;' class='imgcontainer'>
          143  + <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
          144  +<p><b><a href="syntax/common-table-expression.html">common-table-expression:</a></b>
          145  +<button id='x1213' onclick='hideorshow("x1213","x1214")'>show</button></p>
          146  + <div id='x1214' style='display:none;' class='imgcontainer'>
          147  + <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
          148  +</div>
          149  +<p><b><a href="syntax/compound-operator.html">compound-operator:</a></b>
          150  +<button id='x1215' onclick='hideorshow("x1215","x1216")'>show</button></p>
          151  + <div id='x1216' style='display:none;' class='imgcontainer'>
          152  + <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
          153  +</div>
          154  +<p><b><a href="syntax/join-clause.html">join-clause:</a></b>
          155  +<button id='x1217' onclick='hideorshow("x1217","x1218")'>show</button></p>
          156  + <div id='x1218' style='display:none;' class='imgcontainer'>
          157  + <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
          158  +<p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
          159  +<button id='x1219' onclick='hideorshow("x1219","x1220")'>show</button></p>
          160  + <div id='x1220' style='display:none;' class='imgcontainer'>
          161  + <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
          162  +</div>
          163  +<p><b><a href="syntax/join-operator.html">join-operator:</a></b>
          164  +<button id='x1221' onclick='hideorshow("x1221","x1222")'>show</button></p>
          165  + <div id='x1222' style='display:none;' class='imgcontainer'>
          166  + <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
          167  +</div>
          168  +</div>
          169  +<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
          170  +<button id='x1223' onclick='hideorshow("x1223","x1224")'>show</button></p>
          171  + <div id='x1224' style='display:none;' class='imgcontainer'>
          172  + <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
          173  +</div>
          174  +<p><b><a href="syntax/result-column.html">result-column:</a></b>
          175  +<button id='x1225' onclick='hideorshow("x1225","x1226")'>show</button></p>
          176  + <div id='x1226' style='display:none;' class='imgcontainer'>
          177  + <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
          178  +</div>
          179  +<p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
          180  +<button id='x1227' onclick='hideorshow("x1227","x1228")'>show</button></p>
          181  + <div id='x1228' style='display:none;' class='imgcontainer'>
          182  + <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
          183  +</div>
          184  +<p><b><a href="syntax/window-defn.html">window-defn:</a></b>
          185  +<button id='x1229' onclick='hideorshow("x1229","x1230")'>show</button></p>
          186  + <div id='x1230' style='display:none;' class='imgcontainer'>
          187  + <img alt="syntax diagram window-defn" src="images/syntax/window-defn.gif" />
          188  +<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
          189  +<button id='x1231' onclick='hideorshow("x1231","x1232")'>show</button></p>
          190  + <div id='x1232' style='display:none;' class='imgcontainer'>
          191  + <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
          192  +</div>
          193  +</div>
          194  +</div>
          195  +</div>
          196  +<p><b><a href="syntax/foreign-key-clause.html">foreign-key-clause:</a></b>
          197  +<button id='x1233' onclick='hideorshow("x1233","x1234")'>show</button></p>
          198  + <div id='x1234' style='display:none;' class='imgcontainer'>
          199  + <img alt="syntax diagram foreign-key-clause" src="images/syntax/foreign-key-clause.gif" />
          200  +</div>
          201  +<p><b><a href="syntax/literal-value.html">literal-value:</a></b>
          202  +<button id='x1235' onclick='hideorshow("x1235","x1236")'>show</button></p>
          203  + <div id='x1236' style='display:none;' class='imgcontainer'>
          204  + <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
          205  +</div>
          206  +<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
          207  +<button id='x1237' onclick='hideorshow("x1237","x1238")'>show</button></p>
          208  + <div id='x1238' style='display:none;' class='imgcontainer'>
          209  + <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
          210  +</div>
          211  +</div>
          212  +<p><b><a href="syntax/type-name.html">type-name:</a></b>
          213  +<button id='x1239' onclick='hideorshow("x1239","x1240")'>show</button></p>
          214  + <div id='x1240' style='display:none;' class='imgcontainer'>
          215  + <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
          216  +<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
          217  +<button id='x1241' onclick='hideorshow("x1241","x1242")'>show</button></p>
          218  + <div id='x1242' style='display:none;' class='imgcontainer'>
          219  + <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
          220  +</div>
          221  +</div>
          222  +</div>
          223  +</div>
          224  +
          225  +
          226  +<p>SQLite supports a limited subset of ALTER TABLE.
          227  +The ALTER TABLE command in SQLite allows the user to rename a table,
          228  +to rename a column within a table, or to add a new column to an existing table.
          229  +
          230  +<a name="altertabrename"></a>
          231  +
          232  +<h3>ALTER TABLE RENAME</h3>
          233  +
          234  +<p> The RENAME TO syntax changes the name of <span class='yyterm'>table-name</span>
          235  +to <span class='yyterm'>new-table-name</span>.
          236  +This command 
          237  +cannot be used to move a table between attached databases, only to rename 
          238  +a table within the same database.
          239  +If the table being renamed has triggers or indices, then these remain
          240  +attached to the table after it has been renamed.
          241  +
          242  +<blockquote style='background-color: #ffd0d0;'>
          243  +<b>Compatibility Note:</b>
          244  +The behavior of ALTER TABLE when renaming a table was enhanced
          245  +in versions 3.25.0 (2018-09-15) and 3.26.0 (2018-12-01)
          246  +in order to carry the rename operation forward into triggers and
          247  +views that reference the renamed table.  This is considered an
          248  +improvement. Applications that depend on the older (and
          249  +arguably buggy) behavior can use the
          250  +<a href="pragma.html#pragma_legacy_alter_table">PRAGMA legacy_alter_table=ON</a> statement or the
          251  +<a href="c3ref/c_dbconfig_defensive.html#sqlitedbconfiglegacyaltertable">SQLITE_DBCONFIG_LEGACY_ALTER_TABLE</a> configuration parameter
          252  +on <a href="c3ref/db_config.html">sqlite3_db_config()</a> interface to make ALTER TABLE RENAME
          253  +behave as it did prior to version 3.25.0.
          254  +</blockquote>
          255  +
          256  +<p>
          257  +Beginning with release 3.25.0 (2018-09-15), references to the table
          258  +within trigger bodies and view definitions are also renamed.
          259  +</p>
          260  +
          261  +<p> Prior to version 3.26.0 (2018-12-01), FOREIGN KEY references
          262  +to a table that is renamed were only edited if the
          263  +<a href="pragma.html#pragma_foreign_keys">PRAGMA foreign_keys=ON</a>, or in other words if
          264  +<a href="foreignkeys.html">foreign key constraints</a> were begin enforced.  With
          265  +<a href="pragma.html#pragma_foreign_keys">PRAGMA foreign_keys=OFF</a>, FOREIGN KEY constraints would not be changed
          266  +when the table that the foreign key referred to (the "<a href="foreignkeys.html#parentchild">parent table</a>")
          267  +was renamed.  Beginning with version 3.26.0, FOREIGN KEY constraints
          268  +are always converted when a table is renamed, unless the
          269  +<a href="pragma.html#pragma_legacy_alter_table">PRAGMA legacy_alter_table=ON</a> setting is engaged.  The following
          270  +table summaries the difference:</p>
          271  +
          272  +<blockquote>
          273  +<table border="1" cellpadding="2" cellspacing="0">
          274  +<tr>
          275  +<th>PRAGMA foreign_keys
          276  +<th>PRAGMA legacy_alter_table
          277  +<th><a href="foreignkeys.html#parentchild">Parent Table</a>
          278  +references are updated
          279  +<th>SQLite version
          280  +<tr><td align="center">Off<td align="center">Off<td align="center">No<td align="center">&lt; 3.26.0
          281  +<tr><td align="center">Off<td align="center">Off<td align="center">Yes<td align="center">&gt;= 3.26.0
          282  +<tr><td align="center">On<td align="center">Off<td align="center">Yes<td align="center">all
          283  +<tr><td align="center">Off<td align="center">On<td align="center">No<td align="center">all
          284  +<tr><td align="center">On<td align="center">On<td align="center">Yes<td align="center">all
          285  +</table>
          286  +</blockquote>
          287  +
          288  +<a name="altertabmvcol"></a>
          289  +
          290  +<h3>ALTER TABLE RENAME COLUMN</h3>
          291  +
          292  +<p> The RENAME COLUMN TO syntax changes the
          293  +<span class='yyterm'>column-name</span> of table <span class='yyterm'>table-name</span>
          294  +into <span class='yyterm'>new-column-name</span>.  The column name is changed both
          295  +within the table definition itself and also within all indexes, triggers,
          296  +and views that reference the column.  If the column name change would
          297  +result in a semantic ambiguity in a trigger or view, then the RENAME
          298  +COLUMN fails with an error and no changes are applied.
          299  +
          300  +<a name="altertabaddcol"></a>
          301  +
          302  +<h3>ALTER TABLE ADD COLUMN</h3>
          303  +
          304  +<p> The ADD COLUMN syntax
          305  +is used to add a new column to an existing table.
          306  +The new column is always appended to the end of the list of existing columns.
          307  +The <a href="syntax/column-def.html">column-def</a> rule defines the characteristics of the new column.
          308  +The new column may take any of the forms permissible in a <a href="lang_createtable.html">CREATE TABLE</a>
          309  +statement, with the following restrictions:
          310  +<ul>
          311  +<li>The column may not have a PRIMARY KEY or UNIQUE constraint.</li>
          312  +<li>The column may not have a default value of CURRENT_TIME, CURRENT_DATE, 
          313  +    CURRENT_TIMESTAMP, or an expression in parentheses.</li>
          314  +<li>If a NOT NULL constraint is specified, then the column must have a
          315  +    default value other than NULL.
          316  +<li>If <a href="foreignkeys.html">foreign key constraints</a> are <a href="pragma.html#pragma_foreign_keys">enabled</a> and
          317  +    a column with a <a href="syntax/foreign-key-clause.html">REFERENCES clause</a>
          318  +    is added, the column must have a default value of NULL.
          319  +</ul>
          320  +
          321  +<p>Note also that when adding a <a href="lang_createtable.html#ckconst">CHECK constraint</a>, the CHECK constraint
          322  +is not tested against preexisting rows of the table.
          323  +This can result in a table that contains data that
          324  +is in violation of the CHECK constraint.  Future versions of SQLite might
          325  +change to validate CHECK constraints as they are added.</p>
          326  +
          327  +<p>The ALTER TABLE command works by modifying the SQL text of the schema
          328  +stored in the <a href="fileformat2.html#sqlite_master">sqlite_master table</a>.
          329  +No changes are made to table content.
          330  +Because of this,
          331  +the execution time of the ALTER TABLE command is independent of
          332  +the amount of data in the table.  The ALTER TABLE command runs as quickly
          333  +on a table with 10 million rows as it does on a table with 1 row.
          334  +</p>
          335  +
          336  +<p>After ADD COLUMN has been run on a database, that database will not
          337  +be readable by SQLite version 3.1.3 (2005-02-20) and earlier.</p>
          338  +
          339  +<a name="otheralter"></a>
          340  +
          341  +<h3>Making Other Kinds Of Table Schema Changes</h3>
          342  +
          343  +<p> The only schema altering commands directly supported by SQLite are the
          344  +"<a href="lang_altertable.html#altertabrename">rename table</a>", "<a href="lang_altertable.html#altertabmvcol">rename column</a>", and "<a href="lang_altertable.html#altertabaddcol">add column</a>" commands shown above.  
          345  +However, applications
          346  +can make other arbitrary changes to the format of a table using a simple
          347  +sequence of operations.
          348  +The steps to make arbitrary changes to the schema design of some table X
          349  +are as follows:
          350  +
          351  +<ol>
          352  +<li><p>
          353  +If foreign key constraints are enabled, disable them using <a href="pragma.html#pragma_foreign_keys">PRAGMA foreign_keys=OFF</a>.
          354  +
          355  +<li><p>
          356  +Start a transaction.
          357  +
          358  +<li><p>
          359  +Remember the format of all indexes, triggers, and views associated with table X.
          360  +This information will be needed in step 8 below.  One way to do this is
          361  +to run a query like the following:
          362  +SELECT type, sql FROM sqlite_master WHERE tbl_name='X'.
          363  +
          364  +<li><p>
          365  +Use <a href="lang_createtable.html">CREATE TABLE</a> to construct a new table "new_X" that is in the desired
          366  +revised format of table X.  Make sure that the name "new_X" does not collide
          367  +with any existing table name, of course.
          368  +
          369  +<li><p>
          370  +Transfer content from X into new_X using a statement
          371  +like: INSERT INTO new_X SELECT ... FROM X.
          372  +
          373  +<li><p>
          374  +Drop the old table X:  <a href="lang_droptable.html">DROP TABLE X</a>.
          375  +
          376  +<li><p>
          377  +Change the name of new_X to X using: ALTER TABLE new_X RENAME TO X.
          378  +
          379  +<li><p>
          380  +Use <a href="lang_createindex.html">CREATE INDEX</a>, <a href="lang_createtrigger.html">CREATE TRIGGER</a>, and <a href="lang_createview.html">CREATE VIEW</a>
          381  +to reconstruct indexes, triggers, and views
          382  +associated with table X.  Perhaps use the old format of the triggers,
          383  +indexes, and views saved from step 3 above as a guide, making changes
          384  +as appropriate for the alteration.
          385  +
          386  +<li><p>If any views refer to table X in a way that is affected by the
          387  +schema change, then drop those views using <a href="lang_dropview.html">DROP VIEW</a> and recreate them
          388  +with whatever changes are necessary to accommodate the schema change
          389  +using <a href="lang_createview.html">CREATE VIEW</a>.
          390  +
          391  +<li><p>
          392  +If foreign key constraints were originally enabled
          393  +then run <a href="pragma.html#pragma_foreign_key_check">PRAGMA foreign_key_check</a> to verify that the schema
          394  +change did not break any foreign key constraints.
          395  +
          396  +
          397  +<li><p>
          398  +Commit the transaction started in step 2.
          399  +
          400  +<li><p>
          401  +If foreign keys constraints were originally enabled, reenable them now.
          402  +</ol>
          403  +
          404  +<a name="caution"></a>
          405  +
          406  +<p>
          407  +<b>Caution:</b>
          408  +Take care to follow the procedure above precisely.  The boxes below
          409  +summarize two procedures for modifying a table definition.  At first
          410  +glance, they both appear to accomplish the same thing.  However, the
          411  +procedure on the right does not always work, especially with the
          412  +enhanced <a href="lang_altertable.html#altertabrename">rename table</a> capabilities added by versions 3.25.0 and
          413  +3.26.0.  In the procedure on the right, the initial rename of the
          414  +table to a temporary name might corrupt references to that table in
          415  +triggers, views, and foreign key constraints.  The safe procedure on
          416  +the left constructs the revised table definition using a new temporary
          417  +name, then renames the table into its final name, which does not break
          418  +links.
          419  +
          420  +<center>
          421  +<table border="1" cellpadding="10" cellspacing="0">
          422  +<tr>
          423  +<td valign="top">
          424  +<ol>
          425  +<li>Create new table
          426  +<li>Copy data
          427  +<li>Drop old table
          428  +<li>Rename new into old
          429  +</ol>
          430  +<td valign="top">
          431  +<ol>
          432  +<li>Rename old table
          433  +<li>Create new table
          434  +<li>Copy data
          435  +<li>Drop old table
          436  +</ol>
          437  +<tr>
          438  +<th>&uarr;<br>Correct
          439  +<th>&uarr;<br>Incorrect
          440  +</table>
          441  +</center>
          442  +
          443  +<p>The 12-step <a href="lang_altertable.html#otheralter">generalized ALTER TABLE procedure</a>
          444  +above will work even if the
          445  +schema change causes the information stored in the table to change.
          446  +So the full 12-step procedure above is appropriate for dropping a column,
          447  +changing the order of columns, adding or removing a UNIQUE constraint
          448  +or PRIMARY KEY, adding CHECK or FOREIGN KEY or NOT NULL constraints,
          449  +or changing the datatype for a column, for example.  However, a simpler
          450  +and faster procedure can optionally be used for
          451  +some changes that do no affect the on-disk content in any way.
          452  +The following simpler procedure is appropriate for removing
          453  +CHECK or FOREIGN KEY or NOT NULL constraints,
          454  +or adding, removing, or changing default values on
          455  +a column.
          456  +
          457  +<ol>
          458  +<lI><p> Start a transaction.
          459  +
          460  +<li><p> Run <a href="pragma.html#pragma_schema_version">PRAGMA schema_version</a> to determine the current schema
          461  +version number.  This number will be needed for step 6 below.
          462  +
          463  +<li><p> Activate schema editing using 
          464  +<a href="pragma.html#pragma_writable_schema">PRAGMA writable_schema=ON</a>.
          465  +
          466  +<li><p> Run an <a href="lang_update.html">UPDATE</a> statement to change the definition of table X
          467  +in the <a href="fileformat2.html#sqlite_master">sqlite_master table</a>: 
          468  +UPDATE sqlite_master SET sql=... WHERE type='table' AND name='X';
          469  +<p><em>Caution:</em>  Making a change to the sqlite_master table like this will
          470  +render the database corrupt and unreadable if the change contains
          471  +a syntax error.  It is suggested that careful testing of the UPDATE
          472  +statement be done on a separate blank database prior to using it on
          473  +a database containing important data.
          474  +
          475  +<li><p> If the change to table X also affects other tables or indexes or
          476  +triggers are views within schema, then run <a href="lang_update.html">UPDATE</a> statements to modify
          477  +those other tables indexes and views too.  For example, if the name of
          478  +a column changes, all FOREIGN KEY constraints, triggers, indexes, and
          479  +views that refer to that column must be modified.
          480  +<p><em>Caution:</em>  Once again, making changes to the sqlite_master 
          481  +table like this will render the database corrupt and unreadable if the 
          482  +change contains an error.  Carefully test this entire procedure
          483  +on a separate test database prior to using it on
          484  +a database containing important data and/or make backup copies of
          485  +important databases prior to running this procedure.
          486  +
          487  +<li><p> Increment the schema version number using
          488  +<a href="pragma.html#pragma_schema_version">PRAGMA schema_version=X</a> where X is one
          489  +more than the old schema version number found in step 2 above.
          490  +
          491  +<li><p> Disable schema editing using 
          492  +<a href="pragma.html#pragma_writable_schema">PRAGMA writable_schema=OFF</a>.
          493  +
          494  +<li><p> (Optional) Run <a href="pragma.html#pragma_integrity_check">PRAGMA integrity_check</a> to verify that the
          495  +schema changes did not damage the database.
          496  +
          497  +<li><p> Commit the transaction started on step 1 above.
          498  +</ol>
          499  +
          500  +<p>If some future version of SQLite adds new ALTER TABLE capabilities, 
          501  +those capabilities will very likely use one of the two procedures
          502  +outlined above.
          503  +
          504  +<a name="altertableishard"></a>
          505  +
          506  +<h3>Why ALTER TABLE is such a problem for SQLite</h3>
          507  +
          508  +<p>Most SQL database engines store the schema already parsed into
          509  +various system tables.  On those database engines, ALTER TABLE merely 
          510  +has to make modifications to the corresponding system tables.
          511  +
          512  +<p>SQLite is different in that it stores the schema
          513  +in the <a href="fileformat2.html#sqlite_master">sqlite_master</a> table as the original text of the CREATE
          514  +statements that define the schema.  Hence ALTER TABLE needs
          515  +to revise the text of the CREATE statement.  Doing
          516  +so can be tricky for certain "creative" schema designs.
          517  +
          518  +<p>The SQLite approach of storing the schema as text has advantages
          519  +for an embedded relational database.  For one, it means that the
          520  +schema takes up less space in the database file.  This is important
          521  +since a common SQLite usage pattern is to have many small,
          522  +separate database files instead of putting everything in one
          523  +big global database file, which is the usual approach for client/server
          524  +database engines.
          525  +Since the schema is duplicated in each separate database file, it is
          526  +important to keep the schema representation compact.
          527  +
          528  +<p>Storing the schema as text rather than as parsed tables also
          529  +give flexibility to the implementation.  Since the internal parse
          530  +of the schema is regenerated each time the database is opened, the
          531  +internal representation of the schema can change from one release
          532  +to the next.  This is important, as sometimes new features require
          533  +enhancements to the internal schema representation.  Changing the
          534  +internal schema representation would be much more difficult if the
          535  +schema representation was exposed in the database file.  So, in other
          536  +words, storing the schema as text helps maintain backwards 
          537  +compatibility, and helps ensure that older database files can be
          538  +read and written by newer versions of SQLite.
          539  +
          540  +<p>Storing the schema a text also makes the 
          541  +<a href="fileformat2.html">SQLite database file format</a> easier to define, document, and 
          542  +understand. This helps make SQLite database files a
          543  +<a href="locrsf.html">recommended storage format</a> for long-term archiving of data.
          544  +
          545  +<p>The downside of storing schema a text is that it can make
          546  +the schema tricky to modify.  And for that reason, the ALTER TABLE
          547  +support in SQLite has traditionally lagged behind other SQL
          548  +database engines that store their schemas as parsed system tables
          549  +that are easier to modify.
          550  +
          551  +
          552  +
          553  +
          554  +
          555  +
          556  +

Added Doc/Extra/Core/lang_analyze.html.

            1  +<!DOCTYPE html>
            2  +<html><head>
            3  +<meta name="viewport" content="width=device-width, initial-scale=1.0">
            4  +<meta http-equiv="content-type" content="text/html; charset=UTF-8">
            5  +<link href="sqlite.css" rel="stylesheet">
            6  +<title>SQLite Query Language: ANALYZE</title>
            7  +<!-- path= -->
            8  +</head>
            9  +<body>
           10  +<div class=nosearch>
           11  +<a href="index.html">
           12  +<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
           13  +</a>
           14  +<div><!-- IE hack to prevent disappearing logo --></div>
           15  +<div class="tagline desktoponly">
           16  +Small. Fast. Reliable.<br>Choose any three.
           17  +</div>
           18  +<div class="menu mainmenu">
           19  +<ul>
           20  +<li><a href="index.html">Home</a>
           21  +<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
           22  +<li class='wideonly'><a href='about.html'>About</a>
           23  +<li class='desktoponly'><a href="docs.html">Documentation</a>
           24  +<li class='desktoponly'><a href="download.html">Download</a>
           25  +<li class='wideonly'><a href='copyright.html'>License</a>
           26  +<li class='desktoponly'><a href="support.html">Support</a>
           27  +<li class='desktoponly'><a href="prosupport.html">Purchase</a>
           28  +<li class='search' id='search_menubutton'>
           29  +<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
           30  +</ul>
           31  +</div>
           32  +<div class="menu submenu" id="submenu">
           33  +<ul>
           34  +<li><a href='about.html'>About</a>
           35  +<li><a href='docs.html'>Documentation</a>
           36  +<li><a href='download.html'>Download</a>
           37  +<li><a href='support.html'>Support</a>
           38  +<li><a href='prosupport.html'>Purchase</a>
           39  +</ul>
           40  +</div>
           41  +<div class="searchmenu" id="searchmenu">
           42  +<form method="GET" action="search">
           43  +<select name="s" id="searchtype">
           44  +<option value="d">Search Documentation</option>
           45  +<option value="c">Search Changelog</option>
           46  +</select>
           47  +<input type="text" name="q" id="searchbox" value="">
           48  +<input type="submit" value="Go">
           49  +</form>
           50  +</div>
           51  +</div>
           52  +<script>
           53  +function toggle_div(nm) {
           54  +var w = document.getElementById(nm);
           55  +if( w.style.display=="block" ){
           56  +w.style.display = "none";
           57  +}else{
           58  +w.style.display = "block";
           59  +}
           60  +}
           61  +function toggle_search() {
           62  +var w = document.getElementById("searchmenu");
           63  +if( w.style.display=="block" ){
           64  +w.style.display = "none";
           65  +} else {
           66  +w.style.display = "block";
           67  +setTimeout(function(){
           68  +document.getElementById("searchbox").focus()
           69  +}, 30);
           70  +}
           71  +}
           72  +function div_off(nm){document.getElementById(nm).style.display="none";}
           73  +window.onbeforeunload = function(e){div_off("submenu");}
           74  +/* Disable the Search feature if we are not operating from CGI, since */
           75  +/* Search is accomplished using CGI and will not work without it. */
           76  +if( !location.origin.match || !location.origin.match(/http/) ){
           77  +document.getElementById("search_menubutton").style.display = "none";
           78  +}
           79  +/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
           80  +function hideorshow(btn,obj){
           81  +var x = document.getElementById(obj);
           82  +var b = document.getElementById(btn);
           83  +if( x.style.display!='none' ){
           84  +x.style.display = 'none';
           85  +b.innerHTML='show';
           86  +}else{
           87  +x.style.display = '';
           88  +b.innerHTML='hide';
           89  +}
           90  +return false;
           91  +}
           92  +</script>
           93  +</div>
           94  +<div class=nosearch><h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>ANALYZE</h2></div><p><b><a href="syntax/analyze-stmt.html">analyze-stmt:</a></b>
           95  +<button id='x1243' onclick='hideorshow("x1243","x1244")'>hide</button></p>
           96  + <div id='x1244' class='imgcontainer'>
           97  + <img alt="syntax diagram analyze-stmt" src="images/syntax/analyze-stmt.gif" />
           98  +</div>
           99  +
          100  +
          101  +<p> The ANALYZE command gathers statistics about tables and
          102  +indices and stores the collected information
          103  +in <a href="fileformat2.html#intschema">internal tables</a> of the database where the query optimizer can
          104  +access the information and use it to help make better query planning choices.
          105  +If no arguments are given, all attached databases are
          106  +analyzed.  If a schema name is given as the argument, then all tables
          107  +and indices in that one database are analyzed.  
          108  +If the argument is a table name, then only that table and the
          109  +indices associated with that table are analyzed.  If the argument
          110  +is an index name, then only that one index is analyzed.</p>
          111  +
          112  +<p> The default implementation stores all statistics in a single
          113  +table named "<a href="fileformat2.html#stat1tab">sqlite_stat1</a>".  If SQLite is compiled with the
          114  +<a href="compile.html#enable_stat3">SQLITE_ENABLE_STAT3</a> option and without the <a href="compile.html#enable_stat4">SQLITE_ENABLE_STAT4</a>
          115  +option, then additional histogram data is
          116  +collected and stored in <a href="fileformat2.html#stat3tab">sqlite_stat3</a>.
          117  + If SQLite is compiled with the
          118  +<a href="compile.html#enable_stat4">SQLITE_ENABLE_STAT4</a> option, then additional histogram data is
          119  +collected and stored in <a href="fileformat2.html#stat4tab">sqlite_stat4</a>.
          120  +Older versions of SQLite would make use of the <a href="fileformat2.html#stat2tab">sqlite_stat2</a> table
          121  +when compiled with <a href="compile.html#enable_stat2">SQLITE_ENABLE_STAT2</a> but all recent versions of
          122  +SQLite ignore the sqlite_stat2 table.
          123  +Future enhancements may create
          124  +additional <a href="fileformat2.html#intschema">internal tables</a> with the same name pattern except with
          125  +final digit larger than "4".
          126  +All of these tables are collectively referred to as "statistics tables".
          127  +</p>
          128  +
          129  +<p> The content of the statistics tables can be queried using <a href="lang_select.html">SELECT</a>
          130  +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.
          131  +The <a href="lang_droptable.html">DROP TABLE</a> command works on statistics tables
          132  +as of SQLite version 3.7.9. (2011-11-01)
          133  +The <a href="lang_altertable.html">ALTER TABLE</a> command does not work on statistics tables.
          134  +Appropriate care should be used when changing the content of the statistics
          135  +tables as invalid content can cause SQLite to select inefficient
          136  +query plans.  Generally speaking, one should not modify the content of
          137  +the statistics tables by any mechanism other than invoking the
          138  +ANALYZE command.  
          139  +See "<a href="optoverview.html#manctrl">Manual Control Of Query Plans Using SQLITE_STAT Tables</a>" for
          140  +further information.</p>
          141  +
          142  +<p> Statistics gathered by ANALYZE are not automatically updated as
          143  +the content of the database changes.  If the content of the database
          144  +changes significantly, or if the database schema changes, then one should
          145  +consider rerunning the ANALYZE command in order to update the statistics.</p>
          146  +
          147  +<p> The query planner loads the content of the statistics tables
          148  +into memory when the schema is read.  Hence, when an application
          149  +changes the statistics tables directly, SQLite will not immediately
          150  +notice the changes. An application
          151  +can force the query planner to reread the statistics tables by running
          152  +<b>ANALYZE sqlite_master</b>. </p>
          153  +
          154  +<a name="autoanalyze"></a>
          155  +
          156  +<h2>Automatically Running ANALYZE</h2>
          157  +
          158  +<p>The <a href="pragma.html#pragma_optimize">PRAGMA optimize</a> command will automatically run ANALYZE on individual
          159  +tables on an as-needed basis.  The recommended practice is for applications
          160  +to invoke the <a href="pragma.html#pragma_optimize">PRAGMA optimize</a> statement just before closing each database
          161  +connection.</p>
          162  +
          163  +<p>Each SQLite <a href="c3ref/sqlite3.html">database connection</a> records cases when the query planner would
          164  +benefit from having accurate results of ANALYZE at hand.  These records
          165  +are held in memory and accumulate over the life of a database connection.
          166  +The <a href="pragma.html#pragma_optimize">PRAGMA optimize</a> command looks at those records and runs ANALYZE on only
          167  +those tables for which new or updated ANALYZE data seems likely to be useful.
          168  +In most cases <a href="pragma.html#pragma_optimize">PRAGMA optimize</a> will not run ANALYZE, but it will occasionally
          169  +do so either for tables that have never before been analyzed, or for tables
          170  +that have grown significantly since they were last analyzed.</p>
          171  +
          172  +<p>Since the actions of <a href="pragma.html#pragma_optimize">PRAGMA optimize</a> are determined to some extent by
          173  +prior queries that have been evaluated on the same database connection, it
          174  +is recommended that <a href="pragma.html#pragma_optimize">PRAGMA optimize</a> be deferred until the database connection
          175  +is closing and has thus had an opportunity to accumulate as much usage information
          176  +as possible.  It is also reasonable to set a timer to run <a href="pragma.html#pragma_optimize">PRAGMA optimize</a>
          177  +every few hours, or every few days, for database connections that stay open
          178  +for a long time.</p>
          179  +
          180  +<p>Applications that desire more control can run <a href="pragma.html#pragma_optimize">PRAGMA optimize(0x03)</a> to 
          181  +obtain a list of ANALYZE commands that SQLite thinks are appropriate to run,
          182  +but without actually running those commands.  If the returned set is 
          183  +non-empty, the application can then make a decision about whether or not
          184  +to run the suggested ANALYZE commands, perhaps after prompting the user
          185  +for guidance.</p>
          186  +
          187  +<p>The <a href="pragma.html#pragma_optimize">PRAGMA optimize</a> command was first introduced with 
          188  +SQLite 3.18.0 (2017-03-28) and is a no-op for all prior releases
          189  +of SQLite.</p>
          190  +
          191  +<h2>Anticipated Future Enhancements</h2>
          192  +
          193  +<p>All existing versions of SQLite do a full table scan for ANALYZE.  This can be
          194  +slow for multi-gigabyte and larger databases.  Future versions of SQLite might
          195  +use random sampling rather than a full table scan to obtain estimates for the
          196  +database shape, especially on larger tables.  The results would approximate, but 
          197  +will be close enough for query planning purposes.  As of 2017-03-20, this
          198  +concept has been tested in experimental branches and appears to work well, but
          199  +has not been folded into an official release.</p>
          200  +
          201  +

Added Doc/Extra/Core/lang_attach.html.

            1  +<!DOCTYPE html>
            2  +<html><head>
            3  +<meta name="viewport" content="width=device-width, initial-scale=1.0">
            4  +<meta http-equiv="content-type" content="text/html; charset=UTF-8">
            5  +<link href="sqlite.css" rel="stylesheet">
            6  +<title>SQLite Query Language: ATTACH DATABASE</title>
            7  +<!-- path= -->
            8  +</head>
            9  +<body>
           10  +<div class=nosearch>
           11  +<a href="index.html">
           12  +<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
           13  +</a>
           14  +<div><!-- IE hack to prevent disappearing logo --></div>
           15  +<div class="tagline desktoponly">
           16  +Small. Fast. Reliable.<br>Choose any three.
           17  +</div>
           18  +<div class="menu mainmenu">
           19  +<ul>
           20  +<li><a href="index.html">Home</a>
           21  +<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
           22  +<li class='wideonly'><a href='about.html'>About</a>
           23  +<li class='desktoponly'><a href="docs.html">Documentation</a>
           24  +<li class='desktoponly'><a href="download.html">Download</a>
           25  +<li class='wideonly'><a href='copyright.html'>License</a>
           26  +<li class='desktoponly'><a href="support.html">Support</a>
           27  +<li class='desktoponly'><a href="prosupport.html">Purchase</a>
           28  +<li class='search' id='search_menubutton'>
           29  +<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
           30  +</ul>
           31  +</div>
           32  +<div class="menu submenu" id="submenu">
           33  +<ul>
           34  +<li><a href='about.html'>About</a>
           35  +<li><a href='docs.html'>Documentation</a>
           36  +<li><a href='download.html'>Download</a>
           37  +<li><a href='support.html'>Support</a>
           38  +<li><a href='prosupport.html'>Purchase</a>
           39  +</ul>
           40  +</div>
           41  +<div class="searchmenu" id="searchmenu">
           42  +<form method="GET" action="search">
           43  +<select name="s" id="searchtype">
           44  +<option value="d">Search Documentation</option>
           45  +<option value="c">Search Changelog</option>
           46  +</select>
           47  +<input type="text" name="q" id="searchbox" value="">
           48  +<input type="submit" value="Go">
           49  +</form>
           50  +</div>
           51  +</div>
           52  +<script>
           53  +function toggle_div(nm) {
           54  +var w = document.getElementById(nm);
           55  +if( w.style.display=="block" ){
           56  +w.style.display = "none";
           57  +}else{
           58  +w.style.display = "block";
           59  +}
           60  +}
           61  +function toggle_search() {
           62  +var w = document.getElementById("searchmenu");
           63  +if( w.style.display=="block" ){
           64  +w.style.display = "none";
           65  +} else {
           66  +w.style.display = "block";
           67  +setTimeout(function(){
           68  +document.getElementById("searchbox").focus()
           69  +}, 30);
           70  +}
           71  +}
           72  +function div_off(nm){document.getElementById(nm).style.display="none";}
           73  +window.onbeforeunload = function(e){div_off("submenu");}
           74  +/* Disable the Search feature if we are not operating from CGI, since */
           75  +/* Search is accomplished using CGI and will not work without it. */
           76  +if( !location.origin.match || !location.origin.match(/http/) ){
           77  +document.getElementById("search_menubutton").style.display = "none";
           78  +}
           79  +/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
           80  +function hideorshow(btn,obj){
           81  +var x = document.getElementById(obj);
           82  +var b = document.getElementById(btn);
           83  +if( x.style.display!='none' ){
           84  +x.style.display = 'none';
           85  +b.innerHTML='show';
           86  +}else{
           87  +x.style.display = '';
           88  +b.innerHTML='hide';
           89  +}
           90  +return false;
           91  +}
           92  +</script>
           93  +</div>
           94  +<div class=nosearch><h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>ATTACH DATABASE</h2></div><p><b><a href="syntax/attach-stmt.html">attach-stmt:</a></b>
           95  +<button id='x1245' onclick='hideorshow("x1245","x1246")'>hide</button></p>
           96  + <div id='x1246' class='imgcontainer'>
           97  + <img alt="syntax diagram attach-stmt" src="images/syntax/attach-stmt.gif" />
           98  +<p><b><a href="syntax/expr.html">expr:</a></b>
           99  +<button id='x1247' onclick='hideorshow("x1247","x1248")'>show</button></p>
          100  + <div id='x1248' style='display:none;' class='imgcontainer'>
          101  + <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
          102  +<p><b><a href="syntax/filter-clause.html">filter-clause:</a></b>
          103  +<button id='x1249' onclick='hideorshow("x1249","x1250")'>show</button></p>
          104  + <div id='x1250' style='display:none;' class='imgcontainer'>
          105  + <img alt="syntax diagram filter-clause" src="images/syntax/filter-clause.gif" />
          106  +</div>
          107  +<p><b><a href="syntax/literal-value.html">literal-value:</a></b>
          108  +<button id='x1251' onclick='hideorshow("x1251","x1252")'>show</button></p>
          109  + <div id='x1252' style='display:none;' class='imgcontainer'>
          110  + <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
          111  +</div>
          112  +<p><b><a href="syntax/over-clause.html">over-clause:</a></b>
          113  +<button id='x1253' onclick='hideorshow("x1253","x1254")'>show</button></p>
          114  + <div id='x1254' style='display:none;' class='imgcontainer'>
          115  + <img alt="syntax diagram over-clause" src="images/syntax/over-clause.gif" />
          116  +<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
          117  +<button id='x1255' onclick='hideorshow("x1255","x1256")'>show</button></p>
          118  + <div id='x1256' style='display:none;' class='imgcontainer'>
          119  + <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
          120  +</div>
          121  +<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
          122  +<button id='x1257' onclick='hideorshow("x1257","x1258")'>show</button></p>
          123  + <div id='x1258' style='display:none;' class='imgcontainer'>
          124  + <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
          125  +</div>
          126  +</div>
          127  +<p><b><a href="syntax/raise-function.html">raise-function:</a></b>
          128  +<button id='x1259' onclick='hideorshow("x1259","x1260")'>show</button></p>
          129  + <div id='x1260' style='display:none;' class='imgcontainer'>
          130  + <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
          131  +</div>
          132  +<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
          133  +<button id='x1261' onclick='hideorshow("x1261","x1262")'>show</button></p>
          134  + <div id='x1262' style='display:none;' class='imgcontainer'>
          135  + <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
          136  +<p><b><a href="syntax/common-table-expression.html">common-table-expression:</a></b>
          137  +<button id='x1263' onclick='hideorshow("x1263","x1264")'>show</button></p>
          138  + <div id='x1264' style='display:none;' class='imgcontainer'>
          139  + <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
          140  +</div>
          141  +<p><b><a href="syntax/compound-operator.html">compound-operator:</a></b>
          142  +<button id='x1265' onclick='hideorshow("x1265","x1266")'>show</button></p>
          143  + <div id='x1266' style='display:none;' class='imgcontainer'>
          144  + <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
          145  +</div>
          146  +<p><b><a href="syntax/join-clause.html">join-clause:</a></b>
          147  +<button id='x1267' onclick='hideorshow("x1267","x1268")'>show</button></p>
          148  + <div id='x1268' style='display:none;' class='imgcontainer'>
          149  + <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
          150  +<p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
          151  +<button id='x1269' onclick='hideorshow("x1269","x1270")'>show</button></p>
          152  + <div id='x1270' style='display:none;' class='imgcontainer'>
          153  + <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
          154  +</div>
          155  +<p><b><a href="syntax/join-operator.html">join-operator:</a></b>
          156  +<button id='x1271' onclick='hideorshow("x1271","x1272")'>show</button></p>
          157  + <div id='x1272' style='display:none;' class='imgcontainer'>
          158  + <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
          159  +</div>
          160  +</div>
          161  +<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
          162  +<button id='x1273' onclick='hideorshow("x1273","x1274")'>show</button></p>
          163  + <div id='x1274' style='display:none;' class='imgcontainer'>
          164  + <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
          165  +</div>
          166  +<p><b><a href="syntax/result-column.html">result-column:</a></b>
          167  +<button id='x1275' onclick='hideorshow("x1275","x1276")'>show</button></p>
          168  + <div id='x1276' style='display:none;' class='imgcontainer'>
          169  + <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
          170  +</div>
          171  +<p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
          172  +<button id='x1277' onclick='hideorshow("x1277","x1278")'>show</button></p>
          173  + <div id='x1278' style='display:none;' class='imgcontainer'>
          174  + <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
          175  +</div>
          176  +<p><b><a href="syntax/window-defn.html">window-defn:</a></b>
          177  +<button id='x1279' onclick='hideorshow("x1279","x1280")'>show</button></p>
          178  + <div id='x1280' style='display:none;' class='imgcontainer'>
          179  + <img alt="syntax diagram window-defn" src="images/syntax/window-defn.gif" />
          180  +<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
          181  +<button id='x1281' onclick='hideorshow("x1281","x1282")'>show</button></p>
          182  + <div id='x1282' style='display:none;' class='imgcontainer'>
          183  + <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
          184  +</div>
          185  +</div>
          186  +</div>
          187  +<p><b><a href="syntax/type-name.html">type-name:</a></b>
          188  +<button id='x1283' onclick='hideorshow("x1283","x1284")'>show</button></p>
          189  + <div id='x1284' style='display:none;' class='imgcontainer'>
          190  + <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
          191  +<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
          192  +<button id='x1285' onclick='hideorshow("x1285","x1286")'>show</button></p>
          193  + <div id='x1286' style='display:none;' class='imgcontainer'>
          194  + <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
          195  +</div>
          196  +</div>
          197  +</div>
          198  +</div>
          199  +
          200  +
          201  +<p> The ATTACH DATABASE statement adds another database 
          202  +file to the current <a href="c3ref/sqlite3.html">database connection</a>. 
          203  +Database files that were previously attached can be removed using
          204  +the <a href="lang_detach.html">DETACH DATABASE</a> command.
          205  +
          206  +<p>The filename for the database to be attached is the value of
          207  +the expression that occurs before the AS keyword.
          208  +The filename of the database follows the same semantics as the
          209  +filename argument to <a href="c3ref/open.html">sqlite3_open()</a> and <a href="c3ref/open.html">sqlite3_open_v2()</a>; the
          210  +special name "<a href="inmemorydb.html">:memory:</a>" results in an <a href="inmemorydb.html">in-memory database</a> and an
          211  +empty string results in a new temporary database.
          212  +The filename argument can be a <a href="uri.html">URI filename</a> if URI filename processing
          213  +is enable on the database connection.  The default behavior is for
          214  +URI filenames to be disabled, however that might change in a future release
          215  +of SQLite, so application developers are advised to plan accordingly.
          216  +
          217  +<p>The name that occurs after the AS keyword is the name of the database
          218  +used internally by SQLite.
          219  +The schema-names 'main' and 
          220  +'temp' refer to the main database and the database used for 
          221  +temporary tables.  The main and temp databases cannot be attached or
          222  +detached.</p>
          223  +
          224  +<p> Tables in an attached database can be referred to using the syntax 
          225  +<i>schema-name.table-name</i>.  If the name of the table is unique
          226  +across all attached databases and the main and temp databases, then the
          227  +<i>schema-name</i> prefix is not required.  If two or more tables in
          228  +different databases have the same name and the 
          229  +<i>schema-name</i> prefix is not used on a table reference, then the
          230  +table chosen is the one in the database that was least recently attached.</p>
          231  +
          232  +<p>
          233  +Transactions involving multiple attached databases are atomic,
          234  +assuming that the main database is not "<a href="inmemorydb.html">:memory:</a>" and the 
          235  +<a href="pragma.html#pragma_journal_mode">journal_mode</a> is not <a href="wal.html">WAL</a>.  If the main
          236  +database is ":memory:" or if the journal_mode is WAL, then 
          237  +transactions continue to be atomic within each individual
          238  +database file. But if the host computer crashes in the middle
          239  +of a <a href="lang_transaction.html">COMMIT</a> where two or more database files are updated,
          240  +some of those files might get the changes where others
          241  +might not.
          242  +</p>
          243  +
          244  +<p> There is a limit, set using <a href="c3ref/limit.html">sqlite3_limit()</a> and 
          245  +<a href="c3ref/c_limit_attached.html#sqlitelimitattached">SQLITE_LIMIT_ATTACHED</a>, to the number of databases that can be
          246  +simultaneously attached to a single database connection.</p>
          247  +
          248  +

Added Doc/Extra/Core/lang_comment.html.

            1  +<!DOCTYPE html>
            2  +<html><head>
            3  +<meta name="viewport" content="width=device-width, initial-scale=1.0">
            4  +<meta http-equiv="content-type" content="text/html; charset=UTF-8">
            5  +<link href="sqlite.css" rel="stylesheet">
            6  +<title>SQLite Query Language: comment</title>
            7  +<!-- path= -->
            8  +</head>
            9  +<body>
           10  +<div class=nosearch>
           11  +<a href="index.html">
           12  +<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
           13  +</a>
           14  +<div><!-- IE hack to prevent disappearing logo --></div>
           15  +<div class="tagline desktoponly">
           16  +Small. Fast. Reliable.<br>Choose any three.
           17  +</div>
           18  +<div class="menu mainmenu">
           19  +<ul>
           20  +<li><a href="index.html">Home</a>
           21  +<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
           22  +<li class='wideonly'><a href='about.html'>About</a>
           23  +<li class='desktoponly'><a href="docs.html">Documentation</a>
           24  +<li class='desktoponly'><a href="download.html">Download</a>
           25  +<li class='wideonly'><a href='copyright.html'>License</a>
           26  +<li class='desktoponly'><a href="support.html">Support</a>
           27  +<li class='desktoponly'><a href="prosupport.html">Purchase</a>
           28  +<li class='search' id='search_menubutton'>
           29  +<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
           30  +</ul>
           31  +</div>
           32  +<div class="menu submenu" id="submenu">
           33  +<ul>
           34  +<li><a href='about.html'>About</a>
           35  +<li><a href='docs.html'>Documentation</a>
           36  +<li><a href='download.html'>Download</a>
           37  +<li><a href='support.html'>Support</a>
           38  +<li><a href='prosupport.html'>Purchase</a>
           39  +</ul>
           40  +</div>
           41  +<div class="searchmenu" id="searchmenu">
           42  +<form method="GET" action="search">
           43  +<select name="s" id="searchtype">
           44  +<option value="d">Search Documentation</option>
           45  +<option value="c">Search Changelog</option>
           46  +</select>
           47  +<input type="text" name="q" id="searchbox" value="">
           48  +<input type="submit" value="Go">
           49  +</form>
           50  +</div>
           51  +</div>
           52  +<script>
           53  +function toggle_div(nm) {
           54  +var w = document.getElementById(nm);
           55  +if( w.style.display=="block" ){
           56  +w.style.display = "none";
           57  +}else{
           58  +w.style.display = "block";
           59  +}
           60  +}
           61  +function toggle_search() {
           62  +var w = document.getElementById("searchmenu");
           63  +if( w.style.display=="block" ){
           64  +w.style.display = "none";
           65  +} else {
           66  +w.style.display = "block";
           67  +setTimeout(function(){
           68  +document.getElementById("searchbox").focus()
           69  +}, 30);
           70  +}
           71  +}
           72  +function div_off(nm){document.getElementById(nm).style.display="none";}
           73  +window.onbeforeunload = function(e){div_off("submenu");}
           74  +/* Disable the Search feature if we are not operating from CGI, since */
           75  +/* Search is accomplished using CGI and will not work without it. */
           76  +if( !location.origin.match || !location.origin.match(/http/) ){
           77  +document.getElementById("search_menubutton").style.display = "none";
           78  +}
           79  +/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
           80  +function hideorshow(btn,obj){
           81  +var x = document.getElementById(obj);
           82  +var b = document.getElementById(btn);
           83  +if( x.style.display!='none' ){
           84  +x.style.display = 'none';
           85  +b.innerHTML='show';
           86  +}else{
           87  +x.style.display = '';
           88  +b.innerHTML='hide';
           89  +}
           90  +return false;
           91  +}
           92  +</script>
           93  +</div>
           94  +<div class=nosearch><h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>comment</h2></div><p><b><a href="syntax/comment-syntax.html">comment-syntax:</a></b>
           95  +<button id='x1299' onclick='hideorshow("x1299","x1300")'>hide</button></p>
           96  + <div id='x1300' class='imgcontainer'>
           97  + <img alt="syntax diagram comment-syntax" src="images/syntax/comment-syntax.gif" />
           98  +</div>
           99  +
          100  +
          101  +<p>Comments are not SQL commands, but can occur within the text of
          102  +SQL queries passed to <a href="c3ref/prepare.html">sqlite3_prepare_v2()</a> and related interfaces.
          103  +Comments are treated as whitespace by the parser.
          104  +Comments can begin anywhere whitespace 
          105  +can be found, including inside expressions that span multiple lines.
          106  +</p>
          107  +
          108  +<p>SQL comments begin with two consecutive "-" characters (ASCII 0x2d)
          109  +and extend up to and including the next newline character (ASCII 0x0a)
          110  +or until the end of input, whichever comes first.</p>
          111  +
          112  +<p>C-style comments begin
          113  +with "/*" and extend up to and including the next "*/" character pair
          114  +or until the end of input, whichever comes first.  C-style comments
          115  +can span multiple lines. </p>
          116  +
          117  +<p>Comments can appear anywhere whitespace can occur,
          118  +including inside expressions and in the middle of other SQL statements.
          119  +Comments do not nest.
          120  +</p>
          121  +
          122  +
          123  +

Added Doc/Extra/Core/lang_conflict.html.

            1  +<!DOCTYPE html>
            2  +<html><head>
            3  +<meta name="viewport" content="width=device-width, initial-scale=1.0">
            4  +<meta http-equiv="content-type" content="text/html; charset=UTF-8">
            5  +<link href="sqlite.css" rel="stylesheet">
            6  +<title>SQLite Query Language: ON CONFLICT clause</title>
            7  +<!-- path= -->
            8  +</head>
            9  +<body>
           10  +<div class=nosearch>
           11  +<a href="index.html">
           12  +<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
           13  +</a>
           14  +<div><!-- IE hack to prevent disappearing logo --></div>
           15  +<div class="tagline desktoponly">
           16  +Small. Fast. Reliable.<br>Choose any three.
           17  +</div>
           18  +<div class="menu mainmenu">
           19  +<ul>
           20  +<li><a href="index.html">Home</a>
           21  +<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
           22  +<li class='wideonly'><a href='about.html'>About</a>
           23  +<li class='desktoponly'><a href="docs.html">Documentation</a>
           24  +<li class='desktoponly'><a href="download.html">Download</a>
           25  +<li class='wideonly'><a href='copyright.html'>License</a>
           26  +<li class='desktoponly'><a href="support.html">Support</a>
           27  +<li class='desktoponly'><a href="prosupport.html">Purchase</a>
           28  +<li class='search' id='search_menubutton'>
           29  +<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
           30  +</ul>
           31  +</div>
           32  +<div class="menu submenu" id="submenu">
           33  +<ul>
           34  +<li><a href='about.html'>About</a>
           35  +<li><a href='docs.html'>Documentation</a>
           36  +<li><a href='download.html'>Download</a>
           37  +<li><a href='support.html'>Support</a>
           38  +<li><a href='prosupport.html'>Purchase</a>
           39  +</ul>
           40  +</div>
           41  +<div class="searchmenu" id="searchmenu">
           42  +<form method="GET" action="search">
           43  +<select name="s" id="searchtype">
           44  +<option value="d">Search Documentation</option>
           45  +<option value="c">Search Changelog</option>
           46  +</select>
           47  +<input type="text" name="q" id="searchbox" value="">
           48  +<input type="submit" value="Go">
           49  +</form>
           50  +</div>
           51  +</div>
           52  +<script>
           53  +function toggle_div(nm) {
           54  +var w = document.getElementById(nm);
           55  +if( w.style.display=="block" ){
           56  +w.style.display = "none";
           57  +}else{
           58  +w.style.display = "block";
           59  +}
           60  +}
           61  +function toggle_search() {
           62  +var w = document.getElementById("searchmenu");
           63  +if( w.style.display=="block" ){
           64  +w.style.display = "none";
           65  +} else {
           66  +w.style.display = "block";
           67  +setTimeout(function(){
           68  +document.getElementById("searchbox").focus()
           69  +}, 30);
           70  +}
           71  +}
           72  +function div_off(nm){document.getElementById(nm).style.display="none";}
           73  +window.onbeforeunload = function(e){div_off("submenu");}
           74  +/* Disable the Search feature if we are not operating from CGI, since */
           75  +/* Search is accomplished using CGI and will not work without it. */
           76  +if( !location.origin.match || !location.origin.match(/http/) ){
           77  +document.getElementById("search_menubutton").style.display = "none";
           78  +}
           79  +/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
           80  +function hideorshow(btn,obj){
           81  +var x = document.getElementById(obj);
           82  +var b = document.getElementById(btn);
           83  +if( x.style.display!='none' ){
           84  +x.style.display = 'none';
           85  +b.innerHTML='show';
           86  +}else{
           87  +x.style.display = '';
           88  +b.innerHTML='hide';
           89  +}
           90  +return false;
           91  +}
           92  +</script>
           93  +</div>
           94  +<div class=nosearch><h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>ON CONFLICT clause</h2></div><p><b><a href="syntax/conflict-clause.html">conflict-clause:</a></b>
           95  +<button id='x1813' onclick='hideorshow("x1813","x1814")'>hide</button></p>
           96  + <div id='x1814' class='imgcontainer'>
           97  + <img alt="syntax diagram conflict-clause" src="images/syntax/conflict-clause.gif" />
           98  +</div>
           99  +
          100  +
          101  +<p>The ON CONFLICT clause is a
          102  +non-standard extension specific to SQLite 
          103  +that can appear in many other SQL commands.
          104  +It is given its own section in this document because it is not
          105  +part of standard SQL and therefore might not be familiar.</p>
          106  +
          107  +<p>The ON CONFLICT clause described here has been a part of
          108  +SQLite since before version 3.0.0 (2004-06-18).  The phrase
          109  +"ON&nbsp;CONFLICT" is also part of <a href="lang_UPSERT.html">UPSERT</a>, which is an extension
          110  +to <a href="lang_insert.html">INSERT</a> added in version 3.24.0 (2018-06-04).  Do not
          111  +confuse these two separate uses of the "ON&nbsp;CONFLICT" phrase.
          112  +
          113  +<p>The syntax for the ON CONFLICT clause is as shown above for
          114  +the CREATE TABLE command.  For the INSERT and
          115  +UPDATE commands, the keywords "ON CONFLICT" are replaced by "OR" so that
          116  +the syntax reads more naturally.  For example, instead of
          117  +"INSERT ON CONFLICT IGNORE" we have "INSERT OR IGNORE".
          118  +The keywords change but the meaning of the clause is the same
          119  +either way.</p>
          120  +
          121  +<p>The ON CONFLICT clause applies to <a href="lang_createtable.html#uniqueconst">UNIQUE</a>, <a href="lang_createtable.html#notnullconst">NOT NULL</a>,
          122  +<a href="lang_createtable.html#ckconst">CHECK</a>, and <a href="lang_createtable.html#primkeyconst">PRIMARY KEY</a> constraints.
          123  +The ON CONFLICT algorithm does not
          124  +apply to <a href="foreignkeys.html">FOREIGN KEY constraints</a>.
          125  +There are five conflict resolution algorithm choices:
          126  +ROLLBACK, ABORT, FAIL, IGNORE, and REPLACE.
          127  +The default conflict resolution algorithm is ABORT.  This
          128  +is what they mean:</p>
          129  +
          130  +<dl>
          131  +<dt><b>ROLLBACK</b></dt>
          132  +<dd><p> When an applicable constraint violation occurs, the ROLLBACK
          133  +resolution algorithm aborts the current SQL statement with
          134  +an SQLITE_CONSTRAINT error and rolls back the current transaction.
          135  +If no transaction is
          136  +active (other than the implied transaction that is created on every
          137  +command) then the ROLLBACK resolution algorithm works the same as the
          138  +ABORT algorithm.</p></dd>
          139  +
          140  +<dt><b>ABORT</b></dt>
          141  +<dd><p> When an applicable constraint violation occurs, the ABORT
          142  +resolution algorithm aborts the current SQL statement
          143  +with an SQLITE_CONSTRAINT error and backs out any changes
          144  +made by the current SQL statement; but changes caused
          145  +by prior SQL statements within the same transaction are preserved and the
          146  +transaction remains active.
          147  +This is the default behavior and the behavior specified by the SQL
          148  +standard.</p></dd>
          149  +
          150  +<dt><b>FAIL</b></dt>
          151  +<dd><p> When an applicable constraint violation occurs, the FAIL
          152  +resolution algorithm aborts the current SQL statement with an
          153  +SQLITE_CONSTRAINT error.  But the FAIL resolution does not
          154  +back out prior changes of the SQL statement that failed nor does
          155  +it end the transaction.
          156  +For example, if an UPDATE
          157  +statement encountered a constraint violation on the 100th row that
          158  +it attempts to update, then the first 99 row changes are preserved
          159  +but changes to rows 100 and beyond never occur.</p>
          160  +
          161  +<p>The FAIL behavior only works for uniqueness, NOT NULL, and CHECK 
          162  +constraints.  A <a href="foreignkeys.html">foreign key constraint</a> violation causes an ABORT.
          163  +</p></dd>
          164  +
          165  +<dt><b>IGNORE</b></dt>
          166  +<dd><p> When an applicable constraint violation occurs, 
          167  +the IGNORE resolution algorithm skips the one row that contains
          168  +the constraint violation and continues processing subsequent rows
          169  +of the SQL statement as if nothing went wrong.
          170  +Other rows before and after the row that
          171  +contained the constraint violation are inserted or updated
          172  +normally. No error is returned for uniqueness, NOT NULL, and
          173  +UNIQUE constraint errors when the IGNORE conflict resolution
          174  +algorithm is used.  However, the IGNORE conflict resolution
          175  +algorithm works like ABORT for <a href="foreignkeys.html">foreign key constraint</a> errors.
          176  +</p>
          177  +</dd>
          178  +
          179  +<dt><b>REPLACE</b></dt>
          180  +<dd><p> When a <a href="lang_createtable.html#uniqueconst">UNIQUE</a> or <a href="lang_createtable.html#primkeyconst">PRIMARY KEY</a> constraint violation occurs, 
          181  +the REPLACE algorithm
          182  +deletes pre-existing rows that are causing the constraint violation
          183  +prior to inserting or updating the current row and the command continues 
          184  +executing normally.
          185  +If a <a href="lang_createtable.html#notnullconst">NOT NULL</a> constraint violation occurs, the REPLACE conflict
          186  +resolution replaces the NULL value with
          187  +the default value for that column, or if the column has no default
          188  +value, then the ABORT algorithm is used.
          189  +If a <a href="lang_createtable.html#ckconst">CHECK constraint</a> or <a href="foreignkeys.html">foreign key constraint</a> violation occurs, 
          190  +the REPLACE conflict resolution algorithm works like ABORT.</p>
          191  +
          192  +<p>When the REPLACE conflict resolution strategy deletes rows in order to
          193  +satisfy a constraint, <a href="lang_createtrigger.html">delete triggers</a> fire if and only if
          194  +<a href="pragma.html#pragma_recursive_triggers">recursive triggers</a> are enabled.</p>
          195  +
          196  +<p>The <a href="c3ref/update_hook.html">update hook</a> is not invoked for rows that
          197  +are deleted by the REPLACE conflict resolution strategy.  Nor does
          198  +REPLACE increment the <a href="c3ref/changes.html">change counter</a>.
          199  +The exceptional behaviors defined in this paragraph might change 
          200  +in a future release.</p>
          201  +</dl>
          202  +
          203  +<p>The algorithm specified in the OR clause of an INSERT or UPDATE
          204  +overrides any algorithm specified in a CREATE TABLE.
          205  +If no algorithm is specified anywhere, the ABORT algorithm is used.</p>
          206  +
          207  +

Added Doc/Extra/Core/lang_corefunc.html.

            1  +<!DOCTYPE html>
            2  +<html><head>
            3  +<meta name="viewport" content="width=device-width, initial-scale=1.0">
            4  +<meta http-equiv="content-type" content="text/html; charset=UTF-8">
            5  +<link href="sqlite.css" rel="stylesheet">
            6  +<title>SQLite Query Language: Core Functions</title>
            7  +<!-- path= -->
            8  +</head>
            9  +<body>
           10  +<div class=nosearch>
           11  +<a href="index.html">
           12  +<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
           13  +</a>
           14  +<div><!-- IE hack to prevent disappearing logo --></div>
           15  +<div class="tagline desktoponly">
           16  +Small. Fast. Reliable.<br>Choose any three.
           17  +</div>
           18  +<div class="menu mainmenu">
           19  +<ul>
           20  +<li><a href="index.html">Home</a>
           21  +<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
           22  +<li class='wideonly'><a href='about.html'>About</a>
           23  +<li class='desktoponly'><a href="docs.html">Documentation</a>
           24  +<li class='desktoponly'><a href="download.html">Download</a>
           25  +<li class='wideonly'><a href='copyright.html'>License</a>
           26  +<li class='desktoponly'><a href="support.html">Support</a>
           27  +<li class='desktoponly'><a href="prosupport.html">Purchase</a>
           28  +<li class='search' id='search_menubutton'>
           29  +<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
           30  +</ul>
           31  +</div>
           32  +<div class="menu submenu" id="submenu">
           33  +<ul>
           34  +<li><a href='about.html'>About</a>
           35  +<li><a href='docs.html'>Documentation</a>
           36  +<li><a href='download.html'>Download</a>
           37  +<li><a href='support.html'>Support</a>
           38  +<li><a href='prosupport.html'>Purchase</a>
           39  +</ul>
           40  +</div>
           41  +<div class="searchmenu" id="searchmenu">
           42  +<form method="GET" action="search">
           43  +<select name="s" id="searchtype">
           44  +<option value="d">Search Documentation</option>
           45  +<option value="c">Search Changelog</option>
           46  +</select>
           47  +<input type="text" name="q" id="searchbox" value="">
           48  +<input type="submit" value="Go">
           49  +</form>
           50  +</div>
           51  +</div>
           52  +<script>
           53  +function toggle_div(nm) {
           54  +var w = document.getElementById(nm);
           55  +if( w.style.display=="block" ){
           56  +w.style.display = "none";
           57  +}else{
           58  +w.style.display = "block";
           59  +}
           60  +}
           61  +function toggle_search() {
           62  +var w = document.getElementById("searchmenu");
           63  +if( w.style.display=="block" ){
           64  +w.style.display = "none";
           65  +} else {
           66  +w.style.display = "block";
           67  +setTimeout(function(){
           68  +document.getElementById("searchbox").focus()
           69  +}, 30);
           70  +}
           71  +}
           72  +function div_off(nm){document.getElementById(nm).style.display="none";}
           73  +window.onbeforeunload = function(e){div_off("submenu");}
           74  +/* Disable the Search feature if we are not operating from CGI, since */
           75  +/* Search is accomplished using CGI and will not work without it. */
           76  +if( !location.origin.match || !location.origin.match(/http/) ){
           77  +document.getElementById("search_menubutton").style.display = "none";
           78  +}
           79  +/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
           80  +function hideorshow(btn,obj){
           81  +var x = document.getElementById(obj);
           82  +var b = document.getElementById(btn);
           83  +if( x.style.display!='none' ){
           84  +x.style.display = 'none';
           85  +b.innerHTML='show';
           86  +}else{
           87  +x.style.display = '';
           88  +b.innerHTML='hide';
           89  +}
           90  +return false;
           91  +}
           92  +</script>
           93  +</div>
           94  +<div class=nosearch><h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>Core Functions</h2></div>
           95  +
           96  +<p>The core functions shown below are available by default. 
           97  +<a href="lang_datefunc.html">Date &amp; Time functions</a>,
           98  +<a href="lang_aggfunc.html">aggregate functions</a>,
           99  +<a href="windowfunctions.html#biwinfunc">window functions</a>, and
          100  +<a href="json1.html">JSON functions</a> are documented separately.  An
          101  +application may define additional
          102  +functions written in C and added to the database engine using
          103  +the <a href="c3ref/create_function.html">sqlite3_create_function()</a> API.</p>
          104  +
          105  +<style>
          106  +#listtab32 tr td {vertical-align:top;}
          107  +</style>
          108  +<table id='listtab32' width='100%'></table>
          109  +<script>
          110  +var listitems32 = [{"u":"lang_corefunc.html#abs","x":"abs(X)","s":0},
          111  +{"u":"lang_corefunc.html#changes","x":"changes()","s":0},
          112  +{"u":"lang_corefunc.html#char","x":"char(X1,X2,...,XN)","s":0},
          113  +{"u":"lang_corefunc.html#coalesce","x":"coalesce(X,Y,...)","s":0},
          114  +{"u":"lang_corefunc.html#glob","x":"glob(X,Y)","s":0},
          115  +{"u":"lang_corefunc.html#hex","x":"hex(X)","s":0},
          116  +{"u":"lang_corefunc.html#ifnull","x":"ifnull(X,Y)","s":0},
          117  +{"u":"lang_corefunc.html#instr","x":"instr(X,Y)","s":0},
          118  +{"u":"lang_corefunc.html#last_insert_rowid","x":"last_insert_rowid()","s":0},
          119  +{"u":"lang_corefunc.html#length","x":"length(X)","s":0},
          120  +{"u":"lang_corefunc.html#like","x":"like(X,Y)","s":0},
          121  +{"u":"lang_corefunc.html#like","x":"like(X,Y,Z)","s":0},
          122  +{"u":"lang_corefunc.html#likelihood","x":"likelihood(X,Y)","s":0},
          123  +{"u":"lang_corefunc.html#likely","x":"likely(X)","s":0},
          124  +{"u":"lang_corefunc.html#load_extension","x":"load_extension(X)","s":0},
          125  +{"u":"lang_corefunc.html#load_extension","x":"load_extension(X,Y)","s":0},
          126  +{"u":"lang_corefunc.html#lower","x":"lower(X)","s":0},
          127  +{"u":"lang_corefunc.html#ltrim","x":"ltrim(X)","s":0},
          128  +{"u":"lang_corefunc.html#ltrim","x":"ltrim(X,Y)","s":0},
          129  +{"u":"lang_corefunc.html#maxoreunc","x":"max(X,Y,...)","s":0},
          130  +{"u":"lang_corefunc.html#minoreunc","x":"min(X,Y,...)","s":0},
          131  +{"u":"lang_corefunc.html#nullif","x":"nullif(X,Y)","s":0},
          132  +{"u":"lang_corefunc.html#printf","x":"printf(FORMAT,...)","s":0},
          133  +{"u":"lang_corefunc.html#quote","x":"quote(X)","s":0},
          134  +{"u":"lang_corefunc.html#random","x":"random()","s":0},
          135  +{"u":"lang_corefunc.html#randomblob","x":"randomblob(N)","s":0},
          136  +{"u":"lang_corefunc.html#replace","x":"replace(X,Y,Z)","s":0},
          137  +{"u":"lang_corefunc.html#round","x":"round(X)","s":0},
          138  +{"u":"lang_corefunc.html#round","x":"round(X,Y)","s":0},
          139  +{"u":"lang_corefunc.html#rtrim","x":"rtrim(X)","s":0},
          140  +{"u":"lang_corefunc.html#rtrim","x":"rtrim(X,Y)","s":0},
          141  +{"u":"lang_corefunc.html#soundex","x":"soundex(X)","s":0},
          142  +{"u":"lang_corefunc.html#sqlite_compileoption_get","x":"sqlite_compileoption_get(N)","s":0},
          143  +{"u":"lang_corefunc.html#sqlite_compileoption_used","x":"sqlite_compileoption_used(X)","s":0},
          144  +{"u":"lang_corefunc.html#sqlite_offset","x":"sqlite_offset(X)","s":0},
          145  +{"u":"lang_corefunc.html#sqlite_source_id","x":"sqlite_source_id()","s":0},
          146  +{"u":"lang_corefunc.html#sqlite_version","x":"sqlite_version()","s":0},
          147  +{"u":"lang_corefunc.html#substr","x":"substr(X,Y)","s":0},
          148  +{"u":"lang_corefunc.html#substr","x":"substr(X,Y,Z)","s":0},
          149  +{"u":"lang_corefunc.html#total_changes","x":"total_changes()","s":0},
          150  +{"u":"lang_corefunc.html#trim","x":"trim(X)","s":0},
          151  +{"u":"lang_corefunc.html#trim","x":"trim(X,Y)","s":0},
          152  +{"u":"lang_corefunc.html#typeof","x":"typeof(X)","s":0},
          153  +{"u":"lang_corefunc.html#unicode","x":"unicode(X)","s":0},
          154  +{"u":"lang_corefunc.html#unlikely","x":"unlikely(X)","s":0},
          155  +{"u":"lang_corefunc.html#upper","x":"upper(X)","s":0},
          156  +{"u":"lang_corefunc.html#zeroblob","x":"zeroblob(N)","s":0}];
          157  +var j = 0;
          158  +var w = Math.max(document.documentElement.clientWidth,  window.innerWidth || 0);
          159  +var nCol = Math.floor(w/225);
          160  +if(nCol<=0) nCol=1;
          161  +var nRow = Math.ceil((listitems32.length+1)/nCol);
          162  +var h="<tr><td><ul class='multicol_list'>"
          163  +var ea
          164  +for(var i=0; i<listitems32.length; i++){
          165  +  if( (++j)>nRow ){
          166  +    h += "</ul></td>\n<td><ul class='multicol_list'>\n";
          167  +    j = 1;
          168  +  }
          169  +  if(listitems32[i].u=="" || listitems32[i].s==2){
          170  +    h += "<li>"
          171  +    ea = ""
          172  +  }else{
          173  +    h += "<li><a href='";
          174  +    h += listitems32[i].u;
          175  +    h += "'>";
          176  +    ea = "</a>"
          177  +  }
          178  +  if(listitems32[i].s==2 || listitems32[i].s==3) h += "<s>"
          179  +  h += listitems32[i].x;
          180  +  if(listitems32[i].s==2 || listitems32[i].s==3) h += "</s>"
          181  +  h += ea
          182  +  if(listitems32[i].s==1) h += "<small><i>(exp)</i></small>\n";
          183  +  if(listitems32[i].s==3) h += "&sup1\n";
          184  +  if(listitems32[i].s==4) h += "&sup2\n";
          185  +  if(listitems32[i].s==5) h += "&sup3\n";
          186  +}
          187  +document.getElementById("listtab32").innerHTML = h;
          188  +</script>
          189  +<hr class='xhr'>
          190  +<dl>
          191  +<a name="abs"></a>
          192  +<dt><p><b>abs(<i>X</i>)</b></dt><dd><p>
          193  +  The abs(X) function returns the absolute value of the numeric
          194  +  argument X.  Abs(X) returns NULL if X is NULL. 
          195  +  Abs(X) returns 0.0 if X is a string or blob
          196  +  that cannot be converted to a numeric value.  If X is the 
          197  +  integer -9223372036854775808 then abs(X) throws an integer overflow
          198  +  error since there is no equivalent positive 64-bit two complement value.
          199  +</dd>
          200  +<a name="changes"></a>
          201  +<dt><p><b>changes()</b></dt><dd><p>
          202  +  The changes() function returns the number of database rows that were changed
          203  +  or inserted or deleted by the most recently completed INSERT, DELETE,
          204  +  or UPDATE statement, exclusive of statements in lower-level triggers.
          205  +  The changes() SQL function is a wrapper around the <a href="c3ref/changes.html">sqlite3_changes()</a>
          206  +  C/C++ function and hence follows the same rules for counting changes.
          207  +</dd>
          208  +<a name="char"></a>
          209  +<dt><p><b>char(<i>X1</i>,<i>X2</i>,...,<i>XN</i>)</b></dt><dd><p>
          210  +  The char(X1,X2,...,XN) function returns a string composed of characters having the
          211  +   unicode code point values of integers X1 through XN, respectively.
          212  +</dd>
          213  +<a name="coalesce"></a>
          214  +<dt><p><b>coalesce(<i>X</i>,<i>Y</i>,...)</b></dt><dd><p>
          215  +  The coalesce() function returns a copy of its first non-NULL argument, or
          216  +  NULL if all arguments are NULL.  Coalesce() must have at least 
          217  +  2 arguments.
          218  +</dd>
          219  +<a name="glob"></a>
          220  +<dt><p><b>glob(<i>X</i>,<i>Y</i>)</b></dt><dd><p>
          221  +  The glob(X,Y) function is equivalent to the
          222  +  expression "<b>Y GLOB X</b>".
          223  +  Note that the X and Y arguments are reversed in the glob() function
          224  +  relative to the infix <a href="lang_expr.html#glob">GLOB</a> operator.  Y is the string and X is the
          225  +  pattern.  So, for example, the following expressions are equivalent:
          226  +  <blockquote><pre>
          227  +     name GLOB '*helium*'
          228  +     glob('*helium*',name)
          229  +  </pre></blockquote>
          230  +  <p>If the <a href="c3ref/create_function.html">sqlite3_create_function()</a> interface is used to
          231  +  override the glob(X,Y) function with an alternative implementation then
          232  +  the <a href="lang_expr.html#glob">GLOB</a> operator will invoke the alternative implementation.
          233  +</dd>
          234  +<a name="hex"></a>
          235  +<dt><p><b>hex(<i>X</i>)</b></dt><dd><p>
          236  +  The hex() function interprets its argument as a BLOB and returns
          237  +  a string which is the upper-case hexadecimal rendering of the content of
          238  +  that blob.
          239  +</dd>
          240  +<a name="ifnull"></a>
          241  +<dt><p><b>ifnull(<i>X</i>,<i>Y</i>)</b></dt><dd><p>
          242  +  The ifnull() function returns a copy of its first non-NULL argument, or
          243  +  NULL if both arguments are NULL.  Ifnull() must have exactly 2 arguments.
          244  +  The ifnull() function is equivalent to <a href="lang_corefunc.html#coalesce">coalesce()</a> with two arguments.
          245  +</dd>
          246  +<a name="instr"></a>
          247  +<dt><p><b>instr(<i>X</i>,<i>Y</i>)</b></dt><dd><p>
          248  +  The instr(X,Y) function finds the first occurrence of string Y within 
          249  +  string X and returns the number of prior characters plus 1, or 0 if
          250  +  Y is nowhere found within X.
          251  +  Or, if X and Y are both BLOBs, then instr(X,Y) returns one
          252  +  more than the number bytes prior to the first occurrence of Y, or 0 if
          253  +  Y does not occur anywhere within X.
          254  +  If both arguments X and Y to instr(X,Y) are non-NULL and are not BLOBs
          255  +  then both are interpreted as strings.
          256  +  If either X or Y are NULL in instr(X,Y) then the result is NULL.
          257  +</dd>
          258  +<a name="last_insert_rowid"></a>
          259  +<dt><p><b>last_insert_rowid()</b></dt><dd><p>
          260  +  The last_insert_rowid() function returns the <a href="lang_createtable.html#rowid">ROWID</a>
          261  +  of the last row insert from the database connection which invoked the
          262  +  function.
          263  +  The last_insert_rowid() SQL function is a wrapper around the
          264  +  <a href="c3ref/last_insert_rowid.html">sqlite3_last_insert_rowid()</a> C/C++ interface function.
          265  +</dd>
          266  +<a name="length"></a>
          267  +<dt><p><b>length(<i>X</i>)</b></dt><dd><p>
          268  +  For a string value X, the length(X) function returns the number of 
          269  +  characters (not bytes) in X prior to the first NUL character.
          270  +  Since SQLite strings do not normally contain NUL characters, the length(X)
          271  +  function will usually return the total number of characters in the string X.
          272  +  For a blob value X, length(X) returns the number of bytes in the blob.
          273  +  If X is NULL then length(X) is NULL.
          274  +  If X is numeric then length(X) returns the length of a string
          275  +  representation of X.
          276  +</dd>
          277  +<a name="like"></a>
          278  +<dt><p><b>like(<i>X</i>,<i>Y</i>)<br />like(<i>X</i>,<i>Y</i>,<i>Z</i>)</b></dt><dd><p>
          279  +  The like() function is used to implement the
          280  +  "<b>Y LIKE X &#91;ESCAPE Z&#93;</b>" expression. 
          281  +  If the optional ESCAPE clause is present, then the
          282  +  like() function is invoked with three arguments.  Otherwise, it is
          283  +  invoked with two arguments only. Note that the X and Y parameters are
          284  +  reversed in the like() function relative to the infix <a href="lang_expr.html#like">LIKE</a> operator.
          285  +  X is the pattern and Y is the string to match against that pattern.
          286  +  Hence, the following expressions are equivalent:
          287  +  <blockquote><pre>
          288  +     name LIKE '%neon%'
          289  +     like('%neon%',name)
          290  +  </pre></blockquote>
          291  +  The <a href="c3ref/create_function.html">sqlite3_create_function()</a> interface can be used to override the
          292  +  like() function and thereby change the operation of the
          293  +  <a href="lang_expr.html#like">LIKE</a> operator.  When overriding the like() function, it may be important
          294  +  to override both the two and three argument versions of the like() 
          295  +  function. Otherwise, different code may be called to implement the
          296  +  <a href="lang_expr.html#like">LIKE</a> operator depending on whether or not an ESCAPE clause was 
          297  +  specified.
          298  +</dd>
          299  +<a name="likelihood"></a>
          300  +<dt><p><b>likelihood(<i>X</i>,<i>Y</i>)</b></dt><dd><p>
          301  +  The likelihood(X,Y) function returns argument X unchanged.
          302  +  The value Y in likelihood(X,Y) must be a floating point constant
          303  +  between 0.0 and 1.0, inclusive.
          304  +  The likelihood(X) function is a no-op that the code generator
          305  +  optimizes away so that it consumes no CPU cycles during run-time
          306  +  (that is, during calls to <a href="c3ref/step.html">sqlite3_step()</a>).
          307  +  The purpose of the likelihood(X,Y) function is to provide a hint
          308  +  to the query planner that the argument X is a boolean that is
          309  +  true with a probability of approximately Y.
          310  +  The <a href="lang_corefunc.html#unlikely">unlikely(X)</a> function is short-hand for likelihood(X,0.0625).
          311  +  The <a href="lang_corefunc.html#likely">likely(X)</a> function is short-hand for likelihood(X,0.9375).
          312  +</dd>
          313  +<a name="likely"></a>
          314  +<dt><p><b>likely(<i>X</i>)</b></dt><dd><p>
          315  +  The likely(X) function returns the argument X unchanged.
          316  +  The likely(X) function is a no-op that the code generator
          317  +  optimizes away so that it consumes no CPU cycles at
          318  +  run-time (that is, during calls to <a href="c3ref/step.html">sqlite3_step()</a>).
          319  +  The purpose of the likely(X) function is to provide a hint
          320  +  to the query planner that the argument X is a boolean value
          321  +  that is usually true. The likely(X) function is equivalent
          322  +  to <a href="lang_corefunc.html#likelihood">likelihood</a>(X,0.9375). See also: <a href="lang_corefunc.html#unlikely">unlikely(X)</a>.
          323  +</dd>
          324  +<a name="load_extension"></a>
          325  +<dt><p><b>load_extension(<i>X</i>)<br />load_extension(<i>X</i>,<i>Y</i>)</b></dt><dd><p>
          326  +  The load_extension(X,Y) function loads <a href="loadext.html">SQLite extensions</a> out of the shared
          327  +  library file named X using the entry point Y.  The result of load_extension()
          328  +  is always a NULL.  If Y is omitted then the default entry point name is used.
          329  +  The load_extension() function raises an exception if the extension fails to
          330  +  load or initialize correctly.
          331  +
          332  +  <p>The load_extension() function will fail if the extension attempts to 
          333  +  modify or delete an SQL function or collating sequence.  The
          334  +  extension can add new functions or collating sequences, but cannot
          335  +  modify or delete existing functions or collating sequences because
          336  +  those functions and/or collating sequences might be used elsewhere
          337  +  in the currently running SQL statement.  To load an extension that
          338  +  changes or deletes functions or collating sequences, use the
          339  +  <a href="c3ref/load_extension.html">sqlite3_load_extension()</a> C-language API.</p>
          340  +
          341  +  <p>For security reasons, extension loaded is turned off by default and must
          342  +  be enabled by a prior call to <a href="c3ref/enable_load_extension.html">sqlite3_enable_load_extension()</a>.</p>
          343  +</dd>
          344  +<a name="lower"></a>
          345  +<dt><p><b>lower(<i>X</i>)</b></dt><dd><p>
          346  +  The lower(X) function returns a copy of string X with all ASCII characters
          347  +  converted to lower case.  The default built-in lower() function works
          348  +  for ASCII characters only.  To do case conversions on non-ASCII
          349  +  characters, load the ICU extension.
          350  +</dd>
          351  +<a name="ltrim"></a>
          352  +<dt><p><b>ltrim(<i>X</i>)<br />ltrim(<i>X</i>,<i>Y</i>)</b></dt><dd><p>
          353  +  The ltrim(X,Y) function returns a string formed by removing any and all
          354  +  characters that appear in Y from the left side of X.
          355  +  If the Y argument is omitted, ltrim(X) removes spaces from the left side
          356  +  of X.
          357  +</dd>
          358  +<a name="maxoreunc"></a>
          359  +<dt><p><b>max(<i>X</i>,<i>Y</i>,...)</b></dt><dd><p>
          360  +  The multi-argument max() function returns the argument with the 
          361  +  maximum value, or return NULL if any argument is NULL. 
          362  +  The multi-argument max() function searches its arguments from left to right
          363  +  for an argument that defines a collating function and uses that collating
          364  +  function for all string comparisons.  If none of the arguments to max()
          365  +  define a collating function, then the BINARY collating function is used.
          366  +  Note that <b>max()</b> is a simple function when
          367  +  it has 2 or more arguments but operates as an
          368  +  <a href="lang_aggfunc.html#maxggunc">aggregate function</a> if given only a single argument.
          369  +</dd>
          370  +<a name="minoreunc"></a>
          371  +<dt><p><b>min(<i>X</i>,<i>Y</i>,...)</b></dt><dd><p>
          372  +  The multi-argument min() function returns the argument with the
          373  +  minimum value.
          374  +  The multi-argument min() function searches its arguments from left to right
          375  +  for an argument that defines a collating function and uses that collating
          376  +  function for all string comparisons.  If none of the arguments to min()
          377  +  define a collating function, then the BINARY collating function is used.
          378  +  Note that <b>min()</b> is a simple function when
          379  +  it has 2 or more arguments but operates as an 
          380  +  <a href="lang_aggfunc.html#minggunc">aggregate function</a> if given
          381  +  only a single argument.
          382  +</dd>
          383  +<a name="nullif"></a>
          384  +<dt><p><b>nullif(<i>X</i>,<i>Y</i>)</b></dt><dd><p>
          385  +  The nullif(X,Y) function returns its first argument if the arguments are
          386  +  different and NULL if the arguments are the same.  The nullif(X,Y) function
          387  +  searches its arguments from left to right for an argument that defines a
          388  +  collating function and uses that collating function for all string
          389  +  comparisons.  If neither argument to nullif() defines a collating function
          390  +  then the BINARY is used.
          391  +</dd>
          392  +<a name="printf"></a>
          393  +<dt><p><b>printf(<i>FORMAT</i>,...)</b></dt><dd><p>
          394  +  The printf(FORMAT,...) SQL function works like the <a href="c3ref/mprintf.html">sqlite3_mprintf()</a> C-language
          395  +  function and the printf() function from the standard C library.
          396  +  The first argument is a format string that specifies how to construct the output
          397  +  string using values taken from subsequent arguments.  If the FORMAT argument is
          398  +  missing or NULL then the result is NULL.  The %n format is silently ignored and
          399  +  does not consume an argument.  The %p format is an alias for %X.  The %z format
          400  +  is interchangeable with %s.  If there are too few arguments in the argument list,
          401  +  missing arguments are assumed to have a NULL value, which is translated into
          402  +  0 or 0.0 for numeric formats or an empty string for %s.  See the
          403  +  <a href="printf.html">built-in printf()</a> documentation for additional information.
          404  +</dd>
          405  +<a name="quote"></a>
          406  +<dt><p><b>quote(<i>X</i>)</b></dt><dd><p>
          407  +  The quote(X) function returns the text of an SQL literal which
          408  +  is the value of its argument suitable for inclusion into an SQL statement.
          409  +  Strings are surrounded by single-quotes with escapes on interior quotes
          410  +  as needed.  BLOBs are encoded as hexadecimal literals.
          411  +  Strings with embedded NUL characters cannot be represented as string
          412  +  literals in SQL and hence the returned string literal is truncated prior
          413  +  to the first NUL.
          414  +</dd>
          415  +<a name="random"></a>
          416  +<dt><p><b>random()</b></dt><dd><p>
          417  +  The random() function returns a pseudo-random integer
          418  +  between -9223372036854775808 and +9223372036854775807.
          419  +</dd>
          420  +<a name="randomblob"></a>
          421  +<dt><p><b>randomblob(<i>N</i>)</b></dt><dd><p>
          422  +  The randomblob(N) function return an N-byte blob containing pseudo-random
          423  +  bytes. If N is less than 1 then a 1-byte random blob is returned.
          424  +
          425  +  <p>Hint:  applications can generate globally unique identifiers
          426  +  using this function together with <a href="lang_corefunc.html#hex">hex()</a> and/or
          427  +  <a href="lang_corefunc.html#lower">lower()</a> like this:</p>
          428  +
          429  +  <blockquote>
          430  +  hex(randomblob(16))<br></br>
          431  +  lower(hex(randomblob(16)))
          432  +  </blockquote>
          433  +</dd>
          434  +<a name="replace"></a>
          435  +<dt><p><b>replace(<i>X</i>,<i>Y</i>,<i>Z</i>)</b></dt><dd><p>
          436  +  The replace(X,Y,Z) function returns a string formed by substituting
          437  +  string Z for every occurrence of string Y in string X.  The <a href="datatype3.html#collation">BINARY</a>
          438  +  collating sequence is used for comparisons.  If Y is an empty
          439  +  string then return X unchanged.  If Z is not initially
          440  +  a string, it is cast to a UTF-8 string prior to processing.
          441  +</dd>
          442  +<a name="round"></a>
          443  +<dt><p><b>round(<i>X</i>)<br />round(<i>X</i>,<i>Y</i>)</b></dt><dd><p>
          444  +  The round(X,Y) function returns a floating-point
          445  +  value X rounded to Y digits to the right of the decimal point.
          446  +  If the Y argument is omitted, it is assumed to be 0.
          447  +</dd>
          448  +<a name="rtrim"></a>
          449  +<dt><p><b>rtrim(<i>X</i>)<br />rtrim(<i>X</i>,<i>Y</i>)</b></dt><dd><p>
          450  +  The rtrim(X,Y) function returns a string formed by removing any and all
          451  +  characters that appear in Y from the right side of X.
          452  +  If the Y argument is omitted, rtrim(X) removes spaces from the right
          453  +  side of X.
          454  +</dd>
          455  +<a name="soundex"></a>
          456  +<dt><p><b>soundex(<i>X</i>)</b></dt><dd><p>
          457  +  The soundex(X) function returns a string that is the soundex encoding 
          458  +  of the string X.
          459  +  The string "?000" is returned if the argument is NULL or contains
          460  +  no ASCII alphabetic characters.
          461  +  This function is omitted from SQLite by default.
          462  +  It is only available if the <a href="compile.html#soundex">SQLITE_SOUNDEX</a> compile-time option
          463  +  is used when SQLite is built.
          464  +</dd>
          465  +<a name="sqlite_compileoption_get"></a>
          466  +<dt><p><b>sqlite_compileoption_get(<i>N</i>)</b></dt><dd><p>
          467  +  The sqlite_compileoption_get() SQL function is a wrapper around the
          468  +  <a href="c3ref/compileoption_get.html">sqlite3_compileoption_get()</a> C/C++ function.
          469  +  This routine returns the N-th compile-time option used to build SQLite
          470  +  or NULL if N is out of range.  See also the <a href="pragma.html#pragma_compile_options">compile_options pragma</a>.
          471  +</dd>
          472  +<a name="sqlite_compileoption_used"></a>
          473  +<dt><p><b>sqlite_compileoption_used(<i>X</i>)</b></dt><dd><p>
          474  +  The sqlite_compileoption_used() SQL function is a wrapper around the
          475  +  <a href="c3ref/compileoption_get.html">sqlite3_compileoption_used()</a> C/C++ function.
          476  +  When the argument X to sqlite_compileoption_used(X) is a string which
          477  +  is the name of a compile-time option, this routine returns true (1) or
          478  +  false (0) depending on whether or not that option was used during the
          479  +  build.
          480  +</dd>
          481  +<a name="sqlite_offset"></a>
          482  +<dt><p><b>sqlite_offset(<i>X</i>)</b></dt><dd><p>
          483  +  The sqlite_offset(X) function returns the byte offset in the database
          484  +  file for the beginning of the record from which value would be read.
          485  +  If X is not a column in an ordinary table, then sqlite_offset(X) returns
          486  +  NULL.  The value returned by sqlite_offset(X) might reference either the
          487  +  original table or an index, depending on the query.  If the value X would
          488  +  normally be extracted from an index, the sqlite_offset(X) returns the
          489  +  offset to the corresponding index record.  If the value X would be
          490  +  extracted from the original table, then sqlite_offset(X) returns the offset
          491  +  to the table record.
          492  +
          493  +  <p>The sqlite_offset(X) SQL function is only available if SQLite is built
          494  +  using the <a href="compile.html#enable_offset_sql_func">-DSQLITE_ENABLE_OFFSET_SQL_FUNC</a> compile-time option.
          495  +</dd>
          496  +<a name="sqlite_source_id"></a>
          497  +<dt><p><b>sqlite_source_id()</b></dt><dd><p>
          498  +  The sqlite_source_id() function returns a string that identifies the
          499  +  specific version of the source code that was used to build the SQLite
          500  +  library.  The string returned by sqlite_source_id() is
          501  +  the date and time that the source code was checked in followed by
          502  +  the SHA1 hash for that check-in.  This function is
          503  +  an SQL wrapper around the <a href="c3ref/libversion.html">sqlite3_sourceid()</a> C interface.
          504  +</dd>
          505  +<a name="sqlite_version"></a>
          506  +<dt><p><b>sqlite_version()</b></dt><dd><p>
          507  +  The sqlite_version() function returns the version string for the SQLite
          508  +  library that is running.  This function is an SQL
          509  +  wrapper around the <a href="c3ref/libversion.html">sqlite3_libversion()</a> C-interface.
          510  +</dd>
          511  +<a name="substr"></a>
          512  +<dt><p><b>substr(<i>X</i>,<i>Y</i>,<i>Z</i>)<br />substr(<i>X</i>,<i>Y</i>)</b></dt><dd><p>
          513  +  The substr(X,Y,Z) function returns a substring of input string X that begins
          514  +  with the Y-th character and which is Z characters long.
          515  +  If Z is omitted then substr(X,Y) returns all characters through the end
          516  +  of the string X beginning with the Y-th.
          517  +  The left-most character of X is number 1.  If Y is negative
          518  +  then the first character of the substring is found by counting from the
          519  +  right rather than the left.  If Z is negative then
          520  +  the abs(Z) characters preceding the Y-th character are returned.
          521  +  If X is a string then characters indices refer to actual UTF-8 
          522  +  characters.  If X is a BLOB then the indices refer to bytes.
          523  +</dd>
          524  +<a name="total_changes"></a>
          525  +<dt><p><b>total_changes()</b></dt><dd><p>
          526  +  The total_changes() function returns the number of row changes
          527  +  caused by INSERT, UPDATE or DELETE
          528  +  statements since the current database connection was opened.
          529  +  This function is a wrapper around the <a href="c3ref/total_changes.html">sqlite3_total_changes()</a>
          530  +  C/C++ interface.
          531  +</dd>
          532  +<a name="trim"></a>
          533  +<dt><p><b>trim(<i>X</i>)<br />trim(<i>X</i>,<i>Y</i>)</b></dt><dd><p>
          534  +  The trim(X,Y) function returns a string formed by removing any and all
          535  +  characters that appear in Y from both ends of X.
          536  +  If the Y argument is omitted, trim(X) removes spaces from both ends of X.
          537  +</dd>
          538  +<a name="typeof"></a>
          539  +<dt><p><b>typeof(<i>X</i>)</b></dt><dd><p>
          540  +  The typeof(X) function returns a string that indicates the <a href="datatype3.html">datatype</a> of
          541  +  the expression X: "null", "integer", "real", "text", or "blob".
          542  +</dd>
          543  +<a name="unicode"></a>
          544  +<dt><p><b>unicode(<i>X</i>)</b></dt><dd><p>
          545  +  The unicode(X) function returns the numeric unicode code point corresponding to
          546  +  the first character of the string X.  If the argument to unicode(X) is not a string
          547  +  then the result is undefined.
          548  +</dd>
          549  +<a name="unlikely"></a>
          550  +<dt><p><b>unlikely(<i>X</i>)</b></dt><dd><p>
          551  +  The unlikely(X) function returns the argument X unchanged.
          552  +  The unlikely(X) function is a no-op that the code generator
          553  +  optimizes away so that it consumes no CPU cycles at
          554  +  run-time (that is, during calls to <a href="c3ref/step.html">sqlite3_step()</a>).
          555  +  The purpose of the unlikely(X) function is to provide a hint
          556  +  to the query planner that the argument X is a boolean value
          557  +  that is usually not true. The unlikely(X) function is equivalent
          558  +  to <a href="lang_corefunc.html#likelihood">likelihood</a>(X, 0.0625).
          559  +</dd>
          560  +<a name="upper"></a>
          561  +<dt><p><b>upper(<i>X</i>)</b></dt><dd><p>
          562  +  The upper(X) function returns a copy of input string X in which all 
          563  +  lower-case ASCII characters are converted to their upper-case equivalent.
          564  +</dd>
          565  +<a name="zeroblob"></a>
          566  +<dt><p><b>zeroblob(<i>N</i>)</b></dt><dd><p>
          567  +  The zeroblob(N) function returns a BLOB consisting of N bytes of 0x00.
          568  +  SQLite manages these zeroblobs very efficiently.  Zeroblobs can be used to
          569  +  reserve space for a BLOB that is later written using 
          570  +  <a href="c3ref/blob_open.html">incremental BLOB I/O</a>.
          571  +  This SQL function is implemented using the <a href="c3ref/result_blob.html">sqlite3_result_zeroblob()</a>
          572  +  routine from the C/C++ interface.
          573  +</dd>
          574  +</dl>
          575  +

Added Doc/Extra/Core/lang_createindex.html.

            1  +<!DOCTYPE html>
            2  +<html><head>
            3  +<meta name="viewport" content="width=device-width, initial-scale=1.0">
            4  +<meta http-equiv="content-type" content="text/html; charset=UTF-8">
            5  +<link href="sqlite.css" rel="stylesheet">
            6  +<title>SQLite Query Language: CREATE INDEX</title>
            7  +<!-- path= -->
            8  +</head>
            9  +<body>
           10  +<div class=nosearch>
           11  +<a href="index.html">
           12  +<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
           13  +</a>
           14  +<div><!-- IE hack to prevent disappearing logo --></div>
           15  +<div class="tagline desktoponly">
           16  +Small. Fast. Reliable.<br>Choose any three.
           17  +</div>
           18  +<div class="menu mainmenu">
           19  +<ul>
           20  +<li><a href="index.html">Home</a>
           21  +<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
           22  +<li class='wideonly'><a href='about.html'>About</a>
           23  +<li class='desktoponly'><a href="docs.html">Documentation</a>
           24  +<li class='desktoponly'><a href="download.html">Download</a>
           25  +<li class='wideonly'><a href='copyright.html'>License</a>
           26  +<li class='desktoponly'><a href="support.html">Support</a>
           27  +<li class='desktoponly'><a href="prosupport.html">Purchase</a>
           28  +<li class='search' id='search_menubutton'>
           29  +<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
           30  +</ul>
           31  +</div>
           32  +<div class="menu submenu" id="submenu">
           33  +<ul>
           34  +<li><a href='about.html'>About</a>
           35  +<li><a href='docs.html'>Documentation</a>
           36  +<li><a href='download.html'>Download</a>
           37  +<li><a href='support.html'>Support</a>
           38  +<li><a href='prosupport.html'>Purchase</a>
           39  +</ul>
           40  +</div>
           41  +<div class="searchmenu" id="searchmenu">
           42  +<form method="GET" action="search">
           43  +<select name="s" id="searchtype">
           44  +<option value="d">Search Documentation</option>
           45  +<option value="c">Search Changelog</option>
           46  +</select>
           47  +<input type="text" name="q" id="searchbox" value="">
           48  +<input type="submit" value="Go">
           49  +</form>
           50  +</div>
           51  +</div>
           52  +<script>
           53  +function toggle_div(nm) {
           54  +var w = document.getElementById(nm);
           55  +if( w.style.display=="block" ){
           56  +w.style.display = "none";
           57  +}else{
           58  +w.style.display = "block";
           59  +}
           60  +}
           61  +function toggle_search() {
           62  +var w = document.getElementById("searchmenu");
           63  +if( w.style.display=="block" ){
           64  +w.style.display = "none";
           65  +} else {
           66  +w.style.display = "block";
           67  +setTimeout(function(){
           68  +document.getElementById("searchbox").focus()
           69  +}, 30);
           70  +}
           71  +}
           72  +function div_off(nm){document.getElementById(nm).style.display="none";}
           73  +window.onbeforeunload = function(e){div_off("submenu");}
           74  +/* Disable the Search feature if we are not operating from CGI, since */
           75  +/* Search is accomplished using CGI and will not work without it. */
           76  +if( !location.origin.match || !location.origin.match(/http/) ){
           77  +document.getElementById("search_menubutton").style.display = "none";
           78  +}
           79  +/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
           80  +function hideorshow(btn,obj){
           81  +var x = document.getElementById(obj);
           82  +var b = document.getElementById(btn);
           83  +if( x.style.display!='none' ){
           84  +x.style.display = 'none';
           85  +b.innerHTML='show';
           86  +}else{
           87  +x.style.display = '';
           88  +b.innerHTML='hide';
           89  +}
           90  +return false;
           91  +}
           92  +</script>
           93  +</div>
           94  +<div class=nosearch><h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>CREATE INDEX</h2></div><p><b><a href="syntax/create-index-stmt.html">create-index-stmt:</a></b>
           95  +<button id='x1301' onclick='hideorshow("x1301","x1302")'>hide</button></p>
           96  + <div id='x1302' class='imgcontainer'>
           97  + <img alt="syntax diagram create-index-stmt" src="images/syntax/create-index-stmt.gif" />
           98  +<p><b><a href="syntax/expr.html">expr:</a></b>
           99  +<button id='x1303' onclick='hideorshow("x1303","x1304")'>show</button></p>
          100  + <div id='x1304' style='display:none;' class='imgcontainer'>
          101  + <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
          102  +<p><b><a href="syntax/filter-clause.html">filter-clause:</a></b>
          103  +<button id='x1305' onclick='hideorshow("x1305","x1306")'>show</button></p>
          104  + <div id='x1306' style='display:none;' class='imgcontainer'>
          105  + <img alt="syntax diagram filter-clause" src="images/syntax/filter-clause.gif" />
          106  +</div>
          107  +<p><b><a href="syntax/literal-value.html">literal-value:</a></b>
          108  +<button id='x1307' onclick='hideorshow("x1307","x1308")'>show</button></p>
          109  + <div id='x1308' style='display:none;' class='imgcontainer'>
          110  + <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
          111  +</div>
          112  +<p><b><a href="syntax/over-clause.html">over-clause:</a></b>
          113  +<button id='x1309' onclick='hideorshow("x1309","x1310")'>show</button></p>
          114  + <div id='x1310' style='display:none;' class='imgcontainer'>
          115  + <img alt="syntax diagram over-clause" src="images/syntax/over-clause.gif" />
          116  +<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
          117  +<button id='x1311' onclick='hideorshow("x1311","x1312")'>show</button></p>
          118  + <div id='x1312' style='display:none;' class='imgcontainer'>
          119  + <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
          120  +</div>
          121  +<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
          122  +<button id='x1313' onclick='hideorshow("x1313","x1314")'>show</button></p>
          123  + <div id='x1314' style='display:none;' class='imgcontainer'>
          124  + <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
          125  +</div>
          126  +</div>
          127  +<p><b><a href="syntax/raise-function.html">raise-function:</a></b>
          128  +<button id='x1315' onclick='hideorshow("x1315","x1316")'>show</button></p>
          129  + <div id='x1316' style='display:none;' class='imgcontainer'>
          130  + <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
          131  +</div>
          132  +<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
          133  +<button id='x1317' onclick='hideorshow("x1317","x1318")'>show</button></p>
          134  + <div id='x1318' style='display:none;' class='imgcontainer'>
          135  + <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
          136  +<p><b><a href="syntax/common-table-expression.html">common-table-expression:</a></b>
          137  +<button id='x1319' onclick='hideorshow("x1319","x1320")'>show</button></p>
          138  + <div id='x1320' style='display:none;' class='imgcontainer'>
          139  + <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
          140  +</div>
          141  +<p><b><a href="syntax/compound-operator.html">compound-operator:</a></b>
          142  +<button id='x1321' onclick='hideorshow("x1321","x1322")'>show</button></p>
          143  + <div id='x1322' style='display:none;' class='imgcontainer'>
          144  + <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
          145  +</div>
          146  +<p><b><a href="syntax/join-clause.html">join-clause:</a></b>
          147  +<button id='x1323' onclick='hideorshow("x1323","x1324")'>show</button></p>
          148  + <div id='x1324' style='display:none;' class='imgcontainer'>
          149  + <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
          150  +<p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
          151  +<button id='x1325' onclick='hideorshow("x1325","x1326")'>show</button></p>
          152  + <div id='x1326' style='display:none;' class='imgcontainer'>
          153  + <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
          154  +</div>
          155  +<p><b><a href="syntax/join-operator.html">join-operator:</a></b>
          156  +<button id='x1327' onclick='hideorshow("x1327","x1328")'>show</button></p>
          157  + <div id='x1328' style='display:none;' class='imgcontainer'>
          158  + <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
          159  +</div>
          160  +</div>
          161  +<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
          162  +<button id='x1329' onclick='hideorshow("x1329","x1330")'>show</button></p>
          163  + <div id='x1330' style='display:none;' class='imgcontainer'>
          164  + <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
          165  +</div>
          166  +<p><b><a href="syntax/result-column.html">result-column:</a></b>
          167  +<button id='x1331' onclick='hideorshow("x1331","x1332")'>show</button></p>
          168  + <div id='x1332' style='display:none;' class='imgcontainer'>
          169  + <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
          170  +</div>
          171  +<p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
          172  +<button id='x1333' onclick='hideorshow("x1333","x1334")'>show</button></p>
          173  + <div id='x1334' style='display:none;' class='imgcontainer'>
          174  + <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
          175  +</div>
          176  +<p><b><a href="syntax/window-defn.html">window-defn:</a></b>
          177  +<button id='x1335' onclick='hideorshow("x1335","x1336")'>show</button></p>
          178  + <div id='x1336' style='display:none;' class='imgcontainer'>
          179  + <img alt="syntax diagram window-defn" src="images/syntax/window-defn.gif" />
          180  +<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
          181  +<button id='x1337' onclick='hideorshow("x1337","x1338")'>show</button></p>
          182  + <div id='x1338' style='display:none;' class='imgcontainer'>
          183  + <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
          184  +</div>
          185  +</div>
          186  +</div>
          187  +<p><b><a href="syntax/type-name.html">type-name:</a></b>
          188  +<button id='x1339' onclick='hideorshow("x1339","x1340")'>show</button></p>
          189  + <div id='x1340' style='display:none;' class='imgcontainer'>
          190  + <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
          191  +<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
          192  +<button id='x1341' onclick='hideorshow("x1341","x1342")'>show</button></p>
          193  + <div id='x1342' style='display:none;' class='imgcontainer'>
          194  + <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
          195  +</div>
          196  +</div>
          197  +</div>
          198  +<p><b><a href="syntax/indexed-column.html">indexed-column:</a></b>
          199  +<button id='x1343' onclick='hideorshow("x1343","x1344")'>show</button></p>
          200  + <div id='x1344' style='display:none;' class='imgcontainer'>
          201  + <img alt="syntax diagram indexed-column" src="images/syntax/indexed-column.gif" />
          202  +</div>
          203  +</div>
          204  +
          205  +
          206  +<p>The CREATE INDEX command consists of the keywords "CREATE INDEX" followed
          207  +by the name of the new index, the keyword "ON", the name of a previously
          208  +created table that is to be indexed, and a parenthesized list of table column
          209  +names and/or expressions that are used for the index key.
          210  +If the optional WHERE clause is included, then the index is a "<a href="partialindex.html">partial index</a>".
          211  +</p>
          212  +
          213  +<a name="descidx"></a>
          214  +
          215  +<p>Each column name or expression can be followed by one
          216  +of the "ASC" or "DESC" keywords to indicate sort order.
          217  +The sort order may or may not be ignored depending
          218  +on the database file format, and in particular the <a href="fileformat2.html#schemaformat">schema format number</a>.
          219  +The "legacy" schema format (1) ignores index
          220  +sort order.  The descending index schema format (4) takes index sort order
          221  +into account.  Only versions of SQLite 3.3.0 (2006-01-11)
          222  +and later are able to understand
          223  +the descending index format. For compatibility, version of SQLite between 3.3.0
          224  +and 3.7.9 use the legacy schema format by default.  The newer schema format is
          225  +used by default in version 3.7.10 (2012-01-16) and later.
          226  +The <a href="pragma.html#pragma_legacy_file_format">legacy_file_format pragma</a> can be used to change set the specific
          227  +behavior for any version of SQLite.</p>
          228  +
          229  +<p>The NULLS FIRST and NULLS LAST predicates are not supported
          230  +for indexes.  For <a href="datatype3.html#sortorder">sorting purposes</a>, SQLite considers NULL values 
          231  +to be smaller than all other values.  Hences NULL values always appear at
          232  +the beginning of an ASC index and at the end of a DESC index.</p>
          233  +
          234  +<a name="collidx"></a>
          235  +
          236  +<p>The COLLATE clause optionally following each column name
          237  +or expression defines a
          238  +collating sequence used for text entries in that column.
          239  +The default collating
          240  +sequence is the collating sequence defined for that column in the
          241  +<a href="lang_createtable.html">CREATE TABLE</a> statement.  Or if no collating sequence is otherwise defined,
          242  +the built-in BINARY collating sequence is used.</p>
          243  +
          244  +<a name="indexexpr"></a>
          245  +
          246  +<p>Expressions in an index may not reference other tables
          247  +and may not use subqueries nor functions whose result might
          248  +change (ex: <a href="lang_corefunc.html#random">random()</a> or <a href="lang_corefunc.html#sqlite_version">sqlite_version()</a>).
          249  +Expressions in an index may only refer to columns in the table
          250  +that is being indexed.
          251  +Indexes on expression will not work with versions of SQLite prior
          252  +to <a href="releaselog/3_9_0.html">version 3.9.0</a> (2015-10-14).
          253  +See the <a href="expridx.html">Indexes On Expressions</a> document for additional information
          254  +about using general expressions in CREATE INDEX statements.
          255  +
          256  +<p>There are no arbitrary limits on the number of indices that can be
          257  +attached to a single table.  The number of columns in an index is 
          258  +limited to the value set by
          259  +<a href="c3ref/limit.html">sqlite3_limit</a>(<a href="c3ref/c_limit_attached.html#sqlitelimitcolumn">SQLITE_LIMIT_COLUMN</a>,...).</p>
          260  +
          261  +<a name="uniqueidx"></a>
          262  +
          263  +<p>If the UNIQUE keyword appears between CREATE and INDEX then duplicate
          264  +index entries are not allowed.  Any attempt to insert a duplicate entry
          265  +will result in an error.  For the purposes of unique indices, all NULL values
          266  +are considered different from all other NULL values and are thus unique.
          267  +This is one of the two possible interpretations of the SQL-92 standard
          268  +(the language in the standard is ambiguous) and is the interpretation
          269  +followed by PostgreSQL, MySQL, Firebird, and Oracle.  Informix and
          270  +Microsoft SQL Server follow the other interpretation of the standard.</p>
          271  +
          272  +<p>If the optional IF NOT EXISTS clause is present and another index
          273  +with the same name already exists, then this command becomes a no-op.</p>
          274  +
          275  +<p>Indexes are removed with the <a href="lang_dropindex.html">DROP INDEX</a> command.</p>
          276  +
          277  +
          278  +

Added Doc/Extra/Core/lang_createtable.html.

            1  +<!DOCTYPE html>
            2  +<html><head>
            3  +<meta name="viewport" content="width=device-width, initial-scale=1.0">
            4  +<meta http-equiv="content-type" content="text/html; charset=UTF-8">
            5  +<link href="sqlite.css" rel="stylesheet">
            6  +<title>SQLite Query Language: CREATE TABLE</title>
            7  +<!-- path= -->
            8  +</head>
            9  +<body>
           10  +<div class=nosearch>
           11  +<a href="index.html">
           12  +<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
           13  +</a>
           14  +<div><!-- IE hack to prevent disappearing logo --></div>
           15  +<div class="tagline desktoponly">
           16  +Small. Fast. Reliable.<br>Choose any three.
           17  +</div>
           18  +<div class="menu mainmenu">
           19  +<ul>
           20  +<li><a href="index.html">Home</a>
           21  +<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
           22  +<li class='wideonly'><a href='about.html'>About</a>
           23  +<li class='desktoponly'><a href="docs.html">Documentation</a>
           24  +<li class='desktoponly'><a href="download.html">Download</a>
           25  +<li class='wideonly'><a href='copyright.html'>License</a>
           26  +<li class='desktoponly'><a href="support.html">Support</a>
           27  +<li class='desktoponly'><a href="prosupport.html">Purchase</a>
           28  +<li class='search' id='search_menubutton'>
           29  +<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
           30  +</ul>
           31  +</div>
           32  +<div class="menu submenu" id="submenu">
           33  +<ul>
           34  +<li><a href='about.html'>About</a>
           35  +<li><a href='docs.html'>Documentation</a>
           36  +<li><a href='download.html'>Download</a>
           37  +<li><a href='support.html'>Support</a>
           38  +<li><a href='prosupport.html'>Purchase</a>
           39  +</ul>
           40  +</div>
           41  +<div class="searchmenu" id="searchmenu">
           42  +<form method="GET" action="search">
           43  +<select name="s" id="searchtype">
           44  +<option value="d">Search Documentation</option>
           45  +<option value="c">Search Changelog</option>
           46  +</select>
           47  +<input type="text" name="q" id="searchbox" value="">
           48  +<input type="submit" value="Go">
           49  +</form>
           50  +</div>
           51  +</div>
           52  +<script>
           53  +function toggle_div(nm) {
           54  +var w = document.getElementById(nm);
           55  +if( w.style.display=="block" ){
           56  +w.style.display = "none";
           57  +}else{
           58  +w.style.display = "block";
           59  +}
           60  +}
           61  +function toggle_search() {
           62  +var w = document.getElementById("searchmenu");
           63  +if( w.style.display=="block" ){
           64  +w.style.display = "none";
           65  +} else {
           66  +w.style.display = "block";
           67  +setTimeout(function(){
           68  +document.getElementById("searchbox").focus()
           69  +}, 30);
           70  +}
           71  +}
           72  +function div_off(nm){document.getElementById(nm).style.display="none";}
           73  +window.onbeforeunload = function(e){div_off("submenu");}
           74  +/* Disable the Search feature if we are not operating from CGI, since */
           75  +/* Search is accomplished using CGI and will not work without it. */
           76  +if( !location.origin.match || !location.origin.match(/http/) ){
           77  +document.getElementById("search_menubutton").style.display = "none";
           78  +}
           79  +/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
           80  +function hideorshow(btn,obj){
           81  +var x = document.getElementById(obj);
           82  +var b = document.getElementById(btn);
           83  +if( x.style.display!='none' ){
           84  +x.style.display = 'none';
           85  +b.innerHTML='show';
           86  +}else{
           87  +x.style.display = '';
           88  +b.innerHTML='hide';
           89  +}
           90  +return false;
           91  +}
           92  +</script>
           93  +</div>
           94  +<div class=nosearch><h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>CREATE TABLE</h2></div><p><b><a href="syntax/create-table-stmt.html">create-table-stmt:</a></b>
           95  +<button id='x1345' onclick='hideorshow("x1345","x1346")'>hide</button></p>
           96  + <div id='x1346' class='imgcontainer'>
           97  + <img alt="syntax diagram create-table-stmt" src="images/syntax/create-table-stmt.gif" />
           98  +<p><b><a href="syntax/column-def.html">column-def:</a></b>
           99  +<button id='x1347' onclick='hideorshow("x1347","x1348")'>show</button></p>
          100  + <div id='x1348' style='display:none;' class='imgcontainer'>
          101  + <img alt="syntax diagram column-def" src="images/syntax/column-def.gif" />
          102  +<p><b><a href="syntax/column-constraint.html">column-constraint:</a></b>
          103  +<button id='x1349' onclick='hideorshow("x1349","x1350")'>show</button></p>
          104  + <div id='x1350' style='display:none;' class='imgcontainer'>
          105  + <img alt="syntax diagram column-constraint" src="images/syntax/column-constraint.gif" />
          106  +<p><b><a href="syntax/conflict-clause.html">conflict-clause:</a></b>
          107  +<button id='x1351' onclick='hideorshow("x1351","x1352")'>show</button></p>
          108  + <div id='x1352' style='display:none;' class='imgcontainer'>
          109  + <img alt="syntax diagram conflict-clause" src="images/syntax/conflict-clause.gif" />
          110  +</div>
          111  +<p><b><a href="syntax/expr.html">expr:</a></b>
          112  +<button id='x1353' onclick='hideorshow("x1353","x1354")'>show</button></p>
          113  + <div id='x1354' style='display:none;' class='imgcontainer'>
          114  + <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
          115  +<p><b><a href="syntax/filter-clause.html">filter-clause:</a></b>
          116  +<button id='x1355' onclick='hideorshow("x1355","x1356")'>show</button></p>
          117  + <div id='x1356' style='display:none;' class='imgcontainer'>
          118  + <img alt="syntax diagram filter-clause" src="images/syntax/filter-clause.gif" />
          119  +</div>
          120  +<p><b><a href="syntax/over-clause.html">over-clause:</a></b>
          121  +<button id='x1357' onclick='hideorshow("x1357","x1358")'>show</button></p>
          122  + <div id='x1358' style='display:none;' class='imgcontainer'>
          123  + <img alt="syntax diagram over-clause" src="images/syntax/over-clause.gif" />
          124  +<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
          125  +<button id='x1359' onclick='hideorshow("x1359","x1360")'>show</button></p>
          126  + <div id='x1360' style='display:none;' class='imgcontainer'>
          127  + <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
          128  +</div>
          129  +<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
          130  +<button id='x1361' onclick='hideorshow("x1361","x1362")'>show</button></p>
          131  + <div id='x1362' style='display:none;' class='imgcontainer'>
          132  + <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
          133  +</div>
          134  +</div>
          135  +<p><b><a href="syntax/raise-function.html">raise-function:</a></b>
          136  +<button id='x1363' onclick='hideorshow("x1363","x1364")'>show</button></p>
          137  + <div id='x1364' style='display:none;' class='imgcontainer'>
          138  + <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
          139  +</div>
          140  +</div>
          141  +<p><b><a href="syntax/foreign-key-clause.html">foreign-key-clause:</a></b>
          142  +<button id='x1365' onclick='hideorshow("x1365","x1366")'>show</button></p>
          143  + <div id='x1366' style='display:none;' class='imgcontainer'>
          144  + <img alt="syntax diagram foreign-key-clause" src="images/syntax/foreign-key-clause.gif" />
          145  +</div>
          146  +<p><b><a href="syntax/literal-value.html">literal-value:</a></b>
          147  +<button id='x1367' onclick='hideorshow("x1367","x1368")'>show</button></p>
          148  + <div id='x1368' style='display:none;' class='imgcontainer'>
          149  + <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
          150  +</div>
          151  +<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
          152  +<button id='x1369' onclick='hideorshow("x1369","x1370")'>show</button></p>
          153  + <div id='x1370' style='display:none;' class='imgcontainer'>
          154  + <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
          155  +</div>
          156  +</div>
          157  +<p><b><a href="syntax/type-name.html">type-name:</a></b>
          158  +<button id='x1371' onclick='hideorshow("x1371","x1372")'>show</button></p>
          159  + <div id='x1372' style='display:none;' class='imgcontainer'>
          160  + <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
          161  +<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
          162  +<button id='x1373' onclick='hideorshow("x1373","x1374")'>show</button></p>
          163  + <div id='x1374' style='display:none;' class='imgcontainer'>
          164  + <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
          165  +</div>
          166  +</div>
          167  +</div>
          168  +<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
          169  +<button id='x1375' onclick='hideorshow("x1375","x1376")'>show</button></p>
          170  + <div id='x1376' style='display:none;' class='imgcontainer'>
          171  + <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
          172  +<p><b><a href="syntax/common-table-expression.html">common-table-expression:</a></b>
          173  +<button id='x1377' onclick='hideorshow("x1377","x1378")'>show</button></p>
          174  + <div id='x1378' style='display:none;' class='imgcontainer'>
          175  + <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
          176  +</div>
          177  +<p><b><a href="syntax/compound-operator.html">compound-operator:</a></b>
          178  +<button id='x1379' onclick='hideorshow("x1379","x1380")'>show</button></p>
          179  + <div id='x1380' style='display:none;' class='imgcontainer'>
          180  + <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
          181  +</div>
          182  +<p><b><a href="syntax/expr.html">expr:</a></b>
          183  +<button id='x1381' onclick='hideorshow("x1381","x1382")'>show</button></p>
          184  + <div id='x1382' style='display:none;' class='imgcontainer'>
          185  + <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
          186  +<p><b><a href="syntax/filter-clause.html">filter-clause:</a></b>
          187  +<button id='x1383' onclick='hideorshow("x1383","x1384")'>show</button></p>
          188  + <div id='x1384' style='display:none;' class='imgcontainer'>
          189  + <img alt="syntax diagram filter-clause" src="images/syntax/filter-clause.gif" />
          190  +</div>
          191  +<p><b><a href="syntax/literal-value.html">literal-value:</a></b>
          192  +<button id='x1385' onclick='hideorshow("x1385","x1386")'>show</button></p>
          193  + <div id='x1386' style='display:none;' class='imgcontainer'>
          194  + <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
          195  +</div>
          196  +<p><b><a href="syntax/over-clause.html">over-clause:</a></b>
          197  +<button id='x1387' onclick='hideorshow("x1387","x1388")'>show</button></p>
          198  + <div id='x1388' style='display:none;' class='imgcontainer'>
          199  + <img alt="syntax diagram over-clause" src="images/syntax/over-clause.gif" />
          200  +<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
          201  +<button id='x1389' onclick='hideorshow("x1389","x1390")'>show</button></p>
          202  + <div id='x1390' style='display:none;' class='imgcontainer'>
          203  + <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
          204  +</div>
          205  +</div>
          206  +<p><b><a href="syntax/raise-function.html">raise-function:</a></b>
          207  +<button id='x1391' onclick='hideorshow("x1391","x1392")'>show</button></p>
          208  + <div id='x1392' style='display:none;' class='imgcontainer'>
          209  + <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
          210  +</div>
          211  +<p><b><a href="syntax/type-name.html">type-name:</a></b>
          212  +<button id='x1393' onclick='hideorshow("x1393","x1394")'>show</button></p>
          213  + <div id='x1394' style='display:none;' class='imgcontainer'>
          214  + <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
          215  +<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
          216  +<button id='x1395' onclick='hideorshow("x1395","x1396")'>show</button></p>
          217  + <div id='x1396' style='display:none;' class='imgcontainer'>
          218  + <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
          219  +</div>
          220  +</div>
          221  +</div>
          222  +<p><b><a href="syntax/join-clause.html">join-clause:</a></b>
          223  +<button id='x1397' onclick='hideorshow("x1397","x1398")'>show</button></p>
          224  + <div id='x1398' style='display:none;' class='imgcontainer'>
          225  + <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
          226  +<p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
          227  +<button id='x1399' onclick='hideorshow("x1399","x1400")'>show</button></p>
          228  + <div id='x1400' style='display:none;' class='imgcontainer'>
          229  + <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
          230  +</div>
          231  +<p><b><a href="syntax/join-operator.html">join-operator:</a></b>
          232  +<button id='x1401' onclick='hideorshow("x1401","x1402")'>show</button></p>
          233  + <div id='x1402' style='display:none;' class='imgcontainer'>
          234  + <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
          235  +</div>
          236  +</div>
          237  +<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
          238  +<button id='x1403' onclick='hideorshow("x1403","x1404")'>show</button></p>
          239  + <div id='x1404' style='display:none;' class='imgcontainer'>
          240  + <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
          241  +</div>
          242  +<p><b><a href="syntax/result-column.html">result-column:</a></b>
          243  +<button id='x1405' onclick='hideorshow("x1405","x1406")'>show</button></p>
          244  + <div id='x1406' style='display:none;' class='imgcontainer'>
          245  + <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
          246  +</div>
          247  +<p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
          248  +<button id='x1407' onclick='hideorshow("x1407","x1408")'>show</button></p>
          249  + <div id='x1408' style='display:none;' class='imgcontainer'>
          250  + <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
          251  +</div>
          252  +<p><b><a href="syntax/window-defn.html">window-defn:</a></b>
          253  +<button id='x1409' onclick='hideorshow("x1409","x1410")'>show</button></p>
          254  + <div id='x1410' style='display:none;' class='imgcontainer'>
          255  + <img alt="syntax diagram window-defn" src="images/syntax/window-defn.gif" />
          256  +<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
          257  +<button id='x1411' onclick='hideorshow("x1411","x1412")'>show</button></p>
          258  + <div id='x1412' style='display:none;' class='imgcontainer'>
          259  + <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
          260  +</div>
          261  +</div>
          262  +</div>
          263  +<p><b><a href="syntax/table-constraint.html">table-constraint:</a></b>
          264  +<button id='x1413' onclick='hideorshow("x1413","x1414")'>show</button></p>
          265  + <div id='x1414' style='display:none;' class='imgcontainer'>
          266  + <img alt="syntax diagram table-constraint" src="images/syntax/table-constraint.gif" />
          267  +<p><b><a href="syntax/conflict-clause.html">conflict-clause:</a></b>
          268  +<button id='x1415' onclick='hideorshow("x1415","x1416")'>show</button></p>
          269  + <div id='x1416' style='display:none;' class='imgcontainer'>
          270  + <img alt="syntax diagram conflict-clause" src="images/syntax/conflict-clause.gif" />
          271  +</div>
          272  +<p><b><a href="syntax/expr.html">expr:</a></b>
          273  +<button id='x1417' onclick='hideorshow("x1417","x1418")'>show</button></p>
          274  + <div id='x1418' style='display:none;' class='imgcontainer'>
          275  + <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
          276  +<p><b><a href="syntax/filter-clause.html">filter-clause:</a></b>
          277  +<button id='x1419' onclick='hideorshow("x1419","x1420")'>show</button></p>
          278  + <div id='x1420' style='display:none;' class='imgcontainer'>
          279  + <img alt="syntax diagram filter-clause" src="images/syntax/filter-clause.gif" />
          280  +</div>
          281  +<p><b><a href="syntax/literal-value.html">literal-value:</a></b>
          282  +<button id='x1421' onclick='hideorshow("x1421","x1422")'>show</button></p>
          283  + <div id='x1422' style='display:none;' class='imgcontainer'>
          284  + <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
          285  +</div>
          286  +<p><b><a href="syntax/over-clause.html">over-clause:</a></b>
          287  +<button id='x1423' onclick='hideorshow("x1423","x1424")'>show</button></p>
          288  + <div id='x1424' style='display:none;' class='imgcontainer'>
          289  + <img alt="syntax diagram over-clause" src="images/syntax/over-clause.gif" />
          290  +<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
          291  +<button id='x1425' onclick='hideorshow("x1425","x1426")'>show</button></p>
          292  + <div id='x1426' style='display:none;' class='imgcontainer'>
          293  + <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
          294  +</div>
          295  +<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
          296  +<button id='x1427' onclick='hideorshow("x1427","x1428")'>show</button></p>
          297  + <div id='x1428' style='display:none;' class='imgcontainer'>
          298  + <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
          299  +</div>
          300  +</div>
          301  +<p><b><a href="syntax/raise-function.html">raise-function:</a></b>
          302  +<button id='x1429' onclick='hideorshow("x1429","x1430")'>show</button></p>
          303  + <div id='x1430' style='display:none;' class='imgcontainer'>
          304  + <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
          305  +</div>
          306  +<p><b><a href="syntax/type-name.html">type-name:</a></b>
          307  +<button id='x1431' onclick='hideorshow("x1431","x1432")'>show</button></p>
          308  + <div id='x1432' style='display:none;' class='imgcontainer'>
          309  + <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
          310  +<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
          311  +<button id='x1433' onclick='hideorshow("x1433","x1434")'>show</button></p>
          312  + <div id='x1434' style='display:none;' class='imgcontainer'>
          313  + <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
          314  +</div>
          315  +</div>
          316  +</div>
          317  +<p><b><a href="syntax/foreign-key-clause.html">foreign-key-clause:</a></b>
          318  +<button id='x1435' onclick='hideorshow("x1435","x1436")'>show</button></p>
          319  + <div id='x1436' style='display:none;' class='imgcontainer'>
          320  + <img alt="syntax diagram foreign-key-clause" src="images/syntax/foreign-key-clause.gif" />
          321  +</div>
          322  +<p><b><a href="syntax/indexed-column.html">indexed-column:</a></b>
          323  +<button id='x1437' onclick='hideorshow("x1437","x1438")'>show</button></p>
          324  + <div id='x1438' style='display:none;' class='imgcontainer'>
          325  + <img alt="syntax diagram indexed-column" src="images/syntax/indexed-column.gif" />
          326  +</div>
          327  +</div>
          328  +</div>
          329  +
          330  +
          331  +<p>The "CREATE TABLE" command is used to create a new table in an SQLite 
          332  +database. A CREATE TABLE command specifies the following attributes of the
          333  +new table:
          334  +
          335  +<ul>
          336  +  <li><p>The name of the new table.
          337  +
          338  +  <li><p> The database in which the new table is created. Tables may be 
          339  +      created in the main database, the temp database, or in any attached
          340  +      database.
          341  +
          342  +  <li><p> The name of each column in the table.
          343  +
          344  +  <li><p> The declared type of each column in the table.
          345  +
          346  +  <li><p> A default value or expression for each column in the table.
          347  +
          348  +  <li><p> A default collation sequence to use with each column.
          349  +
          350  +  <li><p> Optionally, a PRIMARY KEY for the table. Both single column and
          351  +       composite (multiple column) primary keys are supported.
          352  +
          353  +  <li><p> A set of SQL constraints for each table. SQLite supports UNIQUE, NOT
          354  +       NULL, CHECK and FOREIGN KEY constraints.
          355  +
          356  +  <li><p> Whether the table is a <a href="withoutrowid.html">WITHOUT ROWID</a> table.
          357  +</ul>
          358  +
          359  +<p>Every CREATE TABLE statement must specify a name for the new table.
          360  +  Table names that begin with "sqlite_" are reserved for internal use. It
          361  +  is an error to attempt to create a table with a name that starts with
          362  +  "sqlite_".
          363  +
          364  +<p> If a <span class='yyterm'>schema-name</span> is specified, it must be either "main", 
          365  +  "temp", or the name of an <a href="lang_attach.html">attached database</a>. In this case
          366  +  the new table is created in the named database. If the "TEMP" or "TEMPORARY"
          367  +  keyword occurs between the "CREATE" and "TABLE" then the new table is
          368  +  created in the temp database. It is an error to specify both a 
          369  +  <span class='yyterm'>schema-name</span> and the TEMP or TEMPORARY keyword, unless the
          370  +  <span class='yyterm'>schema-name</span> is "temp". 
          371  +  If no schema name is specified and the
          372  +  TEMP keyword is not present then the table is created in the main
          373  +  database.
          374  +
          375  +<p>
          376  +  It is usually an error to attempt to create a new table in a database that
          377  +  already contains a table, index or view of the same name. However, if the
          378  +  "IF NOT EXISTS" clause is specified as part of the CREATE TABLE statement and
          379  +  a table or view of the same name already exists, the CREATE TABLE command
          380  +  simply has no effect (and no error message is returned). An error is still
          381  +  returned if the table cannot be created because of an existing index, even 
          382  +  if the "IF NOT EXISTS" clause is specified.
          383  +
          384  +<p>It is not an error to create a table that has the same name as an 
          385  +  existing <a href="lang_createtrigger.html">trigger</a>.
          386  +
          387  +<p>Tables are removed using the <a href="lang_droptable.html">DROP TABLE</a> statement.  </p>
          388  +
          389  +<a name="createtabas"></a>
          390  +
          391  +<h3>CREATE TABLE ... AS SELECT Statements</h3>
          392  +
          393  +<p>A "CREATE TABLE ... AS SELECT" statement creates and populates a database
          394  +table based on the results of a SELECT statement. The table has the same
          395  +number of columns as the rows returned by the SELECT statement. The name of
          396  +each column is the same as the name of the corresponding column in the result
          397  +set of the SELECT statement. The declared type of each column is determined
          398  +by the <a href="datatype3.html#expraff">expression affinity</a> of the corresponding expression in the result set
          399  +of the SELECT statement, as follows:
          400  +</p>
          401  +
          402  +<center><table border=1>
          403  +  <tr><th>Expression Affinity   <th>Column Declared Type
          404  +  <tr><td>TEXT                  <td>"TEXT"
          405  +  <tr><td>NUMERIC               <td>"NUM"
          406  +  <tr><td>INTEGER               <td>"INT"
          407  +  <tr><td>REAL                  <td>"REAL"
          408  +  <tr><td>BLOB (a.k.a "NONE")   <td>"" (empty string)
          409  +</table></center>
          410  +
          411  +<p>A table created using CREATE TABLE AS has no PRIMARY KEY and no
          412  +constraints of any kind. The default value of each column is NULL. The default
          413  +collation sequence for each column of the new table is BINARY.
          414  +
          415  +<p>Tables created using CREATE TABLE AS are initially populated with the
          416  +rows of data returned by the SELECT statement. Rows are assigned contiguously
          417  +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
          418  +are returned by the SELECT statement.
          419  +
          420  +<a name="tablecoldef"></a>
          421  +
          422  +<h3>Column Definitions</h3>
          423  +
          424  +<p>Unless it is a CREATE TABLE ... AS SELECT statement, a CREATE TABLE includes
          425  +one or more <a href="syntax/column-def.html">column definitions</a>, optionally followed by a list of
          426  +<a href="syntax/table-constraint.html">table constraints</a>.  Each column definition consists of the
          427  +name of the column, optionally followed by the declared type of the column,
          428  +then one or more optional <a href="syntax/column-constraint.html">column constraints</a>. Included in
          429  +the definition of "column constraints" for the purposes of the previous
          430  +statement are the COLLATE and DEFAULT clauses, even though these are not really
          431  +constraints in the sense that they do not restrict the data that the table may
          432  +contain. The other constraints - NOT NULL, CHECK, UNIQUE, PRIMARY KEY and
          433  +FOREIGN KEY constraints - impose restrictions on the tables data, and are are
          434  +described under <a href="lang_createtable.html#constraints">SQL Data Constraints</a> below.
          435  +
          436  +<p>Unlike most SQL databases, SQLite does not restrict the type of data that
          437  +may be inserted into a column based on the columns declared type. Instead,
          438  +SQLite uses <a href="datatype3.html">dynamic typing</a>. The declared type of a column is used to
          439  +determine the <a href="datatype3.html#affinity">affinity</a> of the column only.
          440  +
          441  +<a name="dfltval"></a>
          442  +
          443  +<p>The DEFAULT clause specifies a default value to use for the column if no
          444  +value is explicitly provided by the user when doing an <a href="lang_insert.html">INSERT</a>. If there
          445  +is no explicit DEFAULT clause attached to a column definition, then the 
          446  +default value of the column is NULL. An explicit DEFAULT clause may specify
          447  +that the default value is NULL, a string constant, a blob constant, a
          448  +signed-number, or any constant expression enclosed in parentheses. A
          449  +default value may also be one of the special case-independent keywords
          450  +CURRENT_TIME, CURRENT_DATE or CURRENT_TIMESTAMP. For the purposes of the
          451  +DEFAULT clause, an expression is considered constant if it
          452  +contains no sub-queries, column or table references, <a href="lang_expr.html#varparam">bound parameters</a>,
          453  +or string literals enclosed in double-quotes instead of single-quotes.
          454  +
          455  +<p>Each time a row is inserted into the table by an INSERT statement that 
          456  +does not provide explicit values for all table columns the values stored in
          457  +the new row are determined by their default values, as follows:
          458  +
          459  +<ul>
          460  +  <li><p>If the default value of the column is a constant NULL, text, blob or
          461  +    signed-number value, then that value is used directly in the new row.
          462  +
          463  +  <li><p>If the default value of a column is an expression in parentheses, then
          464  +    the expression is evaluated once for each row inserted and the results
          465  +    used in the new row.
          466  +
          467  +  <li><p>If the default value of a column is CURRENT_TIME, CURRENT_DATE or
          468  +    CURRENT_TIMESTAMP, then the value used in the new row is a text
          469  +    representation of the current UTC date and/or time. For CURRENT_TIME, the
          470  +    format of the value is "HH:MM:SS". For CURRENT_DATE, "YYYY-MM-DD". The
          471  +    format for CURRENT_TIMESTAMP is "YYYY-MM-DD HH:MM:SS".
          472  +</ul>
          473  +
          474  +<p>The COLLATE clause specifies the name of a <a href="datatype3.html#collation">collating sequence</a> to use as
          475  +the default collation sequence for the column. If no COLLATE clause is
          476  +specified, the default collation sequence is <a href="datatype3.html#collation">BINARY</a>.
          477  +
          478  +<p>The number of columns in a table is limited by the <a href="limits.html#max_column">SQLITE_MAX_COLUMN</a>
          479  +compile-time parameter. A single row of a table cannot store more than
          480  +<a href="limits.html#max_length">SQLITE_MAX_LENGTH</a> bytes of data. Both of these limits can be lowered at
          481  +runtime using the <a href="c3ref/limit.html">sqlite3_limit()</a> C/C++ interface.</p>
          482  +
          483  +<a name="constraints"></a>
          484  +
          485  +<h3>SQL Data Constraints</h3>
          486  +
          487  +<a name="primkeyconst"></a>
          488  +
          489  +<p>Each table in SQLite may have at most one <b>PRIMARY KEY</b>. If the
          490  +  keywords PRIMARY KEY are added to a column definition, then the primary key
          491  +  for the table consists of that single column. Or, if a PRIMARY KEY clause 
          492  +  is specified as a <a href="syntax/table-constraint.html">table-constraint</a>, then the primary key of the table
          493  +  consists of the list of columns specified as part of the PRIMARY KEY clause.
          494  +  The PRIMARY KEY clause must contain only column names &mdash; the use of 
          495  +  expressions in an <a href="syntax/indexed-column.html">indexed-column</a> of a PRIMARY KEY is not supported.
          496  +  An error is raised if more than one PRIMARY KEY clause appears in a
          497  +  CREATE TABLE statement.  The PRIMARY KEY is optional for ordinary tables
          498  +  but is required for <a href="withoutrowid.html">WITHOUT ROWID</a> tables.
          499  +
          500  +<p>If a table has a single column primary key and the declared type of that
          501  +  column is "INTEGER" and the table is not a <a href="withoutrowid.html">WITHOUT ROWID</a> table,
          502  +  then the column is known as an <a href="lang_createtable.html#rowid">INTEGER PRIMARY KEY</a>.
          503  +  See <a href="lang_createtable.html#rowid">below</a> for a description of the special properties and behaviors
          504  +  associated with an <a href="lang_createtable.html#rowid">INTEGER PRIMARY KEY</a>.
          505  +
          506  +<p>Each row in a table with a primary key must have a unique combination
          507  +  of values in its primary key columns. For the purposes of determining
          508  +  the uniqueness of primary key values, NULL values are considered distinct from
          509  +  all other values, including other NULLs. If an <a href="lang_insert.html">INSERT</a> or <a href="lang_update.html">UPDATE</a>
          510  +  statement attempts to modify the table content so that two or more rows
          511  +  have identical primary key values, that is a constraint violation.
          512  +
          513  +<p> According to the SQL standard, PRIMARY KEY should always imply NOT NULL.
          514  +  Unfortunately, due to a bug in some early versions, this is not the
          515  +  case in SQLite. Unless the column is an <a href="lang_createtable.html#rowid">INTEGER PRIMARY KEY</a> or
          516  +  the table is a <a href="withoutrowid.html">WITHOUT ROWID</a> table or the column is declared NOT NULL,
          517  +  SQLite allows NULL values in a PRIMARY KEY column.  SQLite could be fixed to
          518  +  conform to the standard, but doing so might break legacy applications.
          519  +  Hence, it has been decided to merely document the fact that SQLite
          520  +  allowing NULLs in most PRIMARY KEY columns.
          521  +
          522  +<a name="uniqueconst"></a>
          523  +
          524  +<p>A <b>UNIQUE</b> constraint is similar to a PRIMARY KEY constraint, except
          525  +  that a single table may have any number of UNIQUE constraints. For each
          526  +  UNIQUE constraint on the table, each row must contain a unique combination
          527  +  of values in the columns identified by the UNIQUE constraint. 
          528  +  For the purposes of UNIQUE constraints, NULL values
          529  +  are considered distinct from all other values, including other NULLs.
          530  +  As with PRIMARY KEYs, a UNIQUE <a href="syntax/table-constraint.html">table-constraint</a> clause must contain
          531  +  only column names &mdash; the use of 
          532  +  expressions in an <a href="syntax/indexed-column.html">indexed-column</a> of a UNIQUE <a href="syntax/table-constraint.html">table-constraint</a>
          533  +  is not supported.
          534  +  
          535  +
          536  +<p>In most cases, UNIQUE and PRIMARY KEY
          537  +  constraints are implemented by creating a unique index in the database.
          538  +  (The exceptions are <a href="lang_createtable.html#rowid">INTEGER PRIMARY KEY</a> and PRIMARY KEYs on 
          539  +  <a href="withoutrowid.html">WITHOUT ROWID</a> tables.)
          540  +  Hence, the following schemas are logically equivalent:
          541  +
          542  +  <ol>
          543  +  <li><p>CREATE TABLE t1(a, b UNIQUE);
          544  +  <li><p>CREATE TABLE t1(a, b PRIMARY KEY);
          545  +  <li><p>CREATE TABLE t1(a, b);<br>
          546  +         CREATE UNIQUE INDEX t1b ON t1(b);
          547  +  </ol>
          548  +
          549  +<a name="ckconst"></a>
          550  +
          551  +<p>A <b>CHECK</b> constraint may be attached to a column definition or
          552  +  specified as a table constraint. In practice it makes no difference. Each
          553  +  time a new row is inserted into the table or an existing row is updated,
          554  +  the expression associated with each CHECK constraint is evaluated and
          555  +  cast to a NUMERIC value in the same way as a <a href="lang_expr.html#castexpr">CAST expression</a>. If the 
          556  +  result is zero (integer value 0 or real value 0.0), then a constraint
          557  +  violation has occurred. If the CHECK expression evaluates to NULL, or
          558  +  any other non-zero value, it is not a constraint violation.
          559  +  The expression of a CHECK constraint may not contain a subquery.
          560  +
          561  +<a name="notnullconst"></a>
          562  +
          563  +<p>A <b>NOT NULL</b> constraint may only be attached to a column definition,
          564  +  not specified as a table constraint.  Not surprisingly, a NOT NULL
          565  +  constraint dictates that the associated column may not contain a NULL value.
          566  +  Attempting to set the column value to NULL when inserting a new row or
          567  +  updating an existing one causes a constraint violation.
          568  +
          569  +<p>Exactly how a constraint violation is dealt with is determined by the
          570  +  <a href="lang_conflict.html">constraint conflict resolution algorithm</a>. Each 
          571  +  PRIMARY KEY, UNIQUE, NOT NULL and CHECK constraint has a default conflict
          572  +  resolution algorithm. PRIMARY KEY, UNIQUE and NOT NULL constraints may be
          573  +  explicitly assigned a default conflict resolution algorithm by including
          574  +  a <a href="syntax/conflict-clause.html">conflict-clause</a> in their definitions. Or, if a constraint definition
          575  +  does not include a <a href="syntax/conflict-clause.html">conflict-clause</a> or it is a CHECK constraint, the default
          576  +  conflict resolution algorithm is ABORT. Different constraints within the
          577  +  same table may have different default conflict resolution algorithms. See
          578  +  the section titled <a href="lang_conflict.html">ON CONFLICT</a> for additional information.
          579  +
          580  +<a name="rowid"></a>
          581  +
          582  +<h3>ROWIDs and the INTEGER PRIMARY KEY</h3>
          583  +
          584  +<p>Except for <a href="withoutrowid.html">WITHOUT ROWID</a> tables, all rows within SQLite tables
          585  +have a 64-bit signed integer key that uniquely identifies the row within its table.
          586  +This integer is usually
          587  +called the "rowid". The rowid value can be accessed using one of the special
          588  +case-independent names "rowid", "oid", or "_rowid_" in place of a column name.
          589  +If a table contains a user defined column named "rowid", "oid" or "_rowid_",
          590  +then that name always refers the explicitly declared column and cannot be used
          591  +to retrieve the integer rowid value.
          592  +
          593  +<p>The rowid (and "oid" and "_rowid_") is omitted in <a href="withoutrowid.html">WITHOUT ROWID</a> tables.
          594  +WITHOUT ROWID tables are only available in SQLite <a href="releaselog/3_8_2.html">version 3.8.2</a>
          595  +(2013-12-06) and later.
          596  +A table that lacks the WITHOUT ROWID clause is called a "rowid table".
          597  +
          598  +<p>The data for rowid tables is stored as a B-Tree structure containing
          599  +one entry for each table row, using the rowid value as the key. This means that
          600  +retrieving or sorting records by rowid is fast. Searching for a record with a
          601  +specific rowid, or for all records with rowids within a specified range is
          602  +around twice as fast as a similar search made by specifying any other PRIMARY
          603  +KEY or indexed value.
          604  +
          605  +<p> With one exception noted below, if a rowid table has a primary key that consists
          606  +of a single column and the declared type of that column is "INTEGER" in any mixture of
          607  +upper and lower case, then the column becomes an alias for the rowid. Such a
          608  +column is usually referred to as an "integer primary key". A PRIMARY KEY column
          609  +only becomes an integer primary key if the declared type name is exactly
          610  +"INTEGER".  Other integer type names like "INT" or "BIGINT" or "SHORT INTEGER"
          611  +or "UNSIGNED INTEGER" causes the primary key column to behave as an ordinary
          612  +table column with integer <a href="datatype3.html#affinity">affinity</a> and a unique index, not as an alias for
          613  +the rowid.
          614  +
          615  +<p> The exception mentioned above is that if the declaration of a column with
          616  +declared type "INTEGER" includes an "PRIMARY KEY DESC" clause, it does not
          617  +become an alias for the rowid and is not classified as an integer primary key.
          618  +This quirk is not by design. It is due to a bug in early versions of SQLite.
          619  +But fixing the bug could result in backwards incompatibilities.
          620  +Hence, the original behavior has been retained (and documented) because odd
          621  +behavior in a corner case is far better than a compatibility break.  This means
          622  +that the following three table declarations all cause the column "x" to be an
          623  +alias for the rowid (an integer primary key):
          624  +
          625  +<ul>
          626  +<li><tt>CREATE TABLE t(x INTEGER PRIMARY KEY ASC, y, z);</tt>
          627  +<li><tt>CREATE TABLE t(x INTEGER, y, z, PRIMARY KEY(x ASC));</tt>
          628  +<li><tt>CREATE TABLE t(x INTEGER, y, z, PRIMARY KEY(x DESC));</tt>
          629  +</ul>
          630  +
          631  +<p>But the following declaration does not result in "x" being an alias for
          632  +the rowid:
          633  +<ul>
          634  +<li><tt>CREATE TABLE t(x INTEGER PRIMARY KEY DESC, y, z);</tt>
          635  +</ul>
          636  +
          637  +<p>Rowid values may be modified using an UPDATE statement in the same
          638  +way as any other column value can, either using one of the built-in aliases
          639  +("rowid", "oid" or "_rowid_") or by using an alias created by an integer
          640  +primary key. Similarly, an INSERT statement may provide a value to use as the
          641  +rowid for each row inserted. Unlike normal SQLite columns, an integer primary
          642  +key or rowid column must contain integer values. Integer primary key or rowid
          643  +columns are not able to hold floating point values, strings, BLOBs, or NULLs.
          644  +
          645  +<p>If an UPDATE statement attempts to set an integer primary key or rowid column
          646  +to a NULL or blob value, or to a string or real value that cannot be losslessly
          647  +converted to an integer, a "datatype mismatch" error occurs and the statement
          648  +is aborted. If an INSERT statement attempts to insert a blob value, or a string
          649  +or real value that cannot be losslessly converted to an integer into an
          650  +integer primary key or rowid column, a "datatype mismatch" error occurs and the
          651  +statement is aborted.
          652  +
          653  +<p>If an INSERT statement attempts to insert a NULL value into a rowid or
          654  +integer primary key column, the system chooses an integer value to use as the
          655  +rowid automatically. A detailed description of how this is done is provided
          656  +<a href="autoinc.html">separately</a>.</p>
          657  +
          658  +<p>The <a href="foreignkeys.html#parentchild">parent key</a> of a <a href="foreignkeys.html">foreign key constraint</a> is not allowed to
          659  +use the rowid.  The parent key must used named columns only.</p>
          660  +
          661  +

Added Doc/Extra/Core/lang_createtrigger.html.

            1  +<!DOCTYPE html>
            2  +<html><head>
            3  +<meta name="viewport" content="width=device-width, initial-scale=1.0">
            4  +<meta http-equiv="content-type" content="text/html; charset=UTF-8">
            5  +<link href="sqlite.css" rel="stylesheet">
            6  +<title>SQLite Query Language: CREATE TRIGGER</title>
            7  +<!-- path= -->
            8  +</head>
            9  +<body>
           10  +<div class=nosearch>
           11  +<a href="index.html">
           12  +<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
           13  +</a>
           14  +<div><!-- IE hack to prevent disappearing logo --></div>
           15  +<div class="tagline desktoponly">
           16  +Small. Fast. Reliable.<br>Choose any three.
           17  +</div>
           18  +<div class="menu mainmenu">
           19  +<ul>
           20  +<li><a href="index.html">Home</a>
           21  +<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
           22  +<li class='wideonly'><a href='about.html'>About</a>
           23  +<li class='desktoponly'><a href="docs.html">Documentation</a>
           24  +<li class='desktoponly'><a href="download.html">Download</a>
           25  +<li class='wideonly'><a href='copyright.html'>License</a>
           26  +<li class='desktoponly'><a href="support.html">Support</a>
           27  +<li class='desktoponly'><a href="prosupport.html">Purchase</a>
           28  +<li class='search' id='search_menubutton'>
           29  +<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
           30  +</ul>
           31  +</div>
           32  +<div class="menu submenu" id="submenu">
           33  +<ul>
           34  +<li><a href='about.html'>About</a>
           35  +<li><a href='docs.html'>Documentation</a>
           36  +<li><a href='download.html'>Download</a>
           37  +<li><a href='support.html'>Support</a>
           38  +<li><a href='prosupport.html'>Purchase</a>
           39  +</ul>
           40  +</div>
           41  +<div class="searchmenu" id="searchmenu">
           42  +<form method="GET" action="search">
           43  +<select name="s" id="searchtype">
           44  +<option value="d">Search Documentation</option>
           45  +<option value="c">Search Changelog</option>
           46  +</select>
           47  +<input type="text" name="q" id="searchbox" value="">
           48  +<input type="submit" value="Go">
           49  +</form>
           50  +</div>
           51  +</div>
           52  +<script>
           53  +function toggle_div(nm) {
           54  +var w = document.getElementById(nm);
           55  +if( w.style.display=="block" ){
           56  +w.style.display = "none";
           57  +}else{
           58  +w.style.display = "block";
           59  +}
           60  +}
           61  +function toggle_search() {
           62  +var w = document.getElementById("searchmenu");
           63  +if( w.style.display=="block" ){
           64  +w.style.display = "none";
           65  +} else {
           66  +w.style.display = "block";
           67  +setTimeout(function(){
           68  +document.getElementById("searchbox").focus()
           69  +}, 30);
           70  +}
           71  +}
           72  +function div_off(nm){document.getElementById(nm).style.display="none";}
           73  +window.onbeforeunload = function(e){div_off("submenu");}
           74  +/* Disable the Search feature if we are not operating from CGI, since */
           75  +/* Search is accomplished using CGI and will not work without it. */
           76  +if( !location.origin.match || !location.origin.match(/http/) ){
           77  +document.getElementById("search_menubutton").style.display = "none";
           78  +}
           79  +/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
           80  +function hideorshow(btn,obj){
           81  +var x = document.getElementById(obj);
           82  +var b = document.getElementById(btn);
           83  +if( x.style.display!='none' ){
           84  +x.style.display = 'none';
           85  +b.innerHTML='show';
           86  +}else{
           87  +x.style.display = '';
           88  +b.innerHTML='hide';
           89  +}
           90  +return false;
           91  +}
           92  +</script>
           93  +</div>
           94  +<div class=nosearch><h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>CREATE TRIGGER</h2></div><p><b><a href="syntax/create-trigger-stmt.html">create-trigger-stmt:</a></b>
           95  +<button id='x1439' onclick='hideorshow("x1439","x1440")'>hide</button></p>
           96  + <div id='x1440' class='imgcontainer'>
           97  + <img alt="syntax diagram create-trigger-stmt" src="images/syntax/create-trigger-stmt.gif" />
           98  +<p><b><a href="syntax/delete-stmt.html">delete-stmt:</a></b>
           99  +<button id='x1441' onclick='hideorshow("x1441","x1442")'>show</button></p>
          100  + <div id='x1442' style='display:none;' class='imgcontainer'>
          101  + <img alt="syntax diagram delete-stmt" src="images/syntax/delete-stmt.gif" />
          102  +<p><b><a href="syntax/qualified-table-name.html">qualified-table-name:</a></b>
          103  +<button id='x1443' onclick='hideorshow("x1443","x1444")'>show</button></p>
          104  + <div id='x1444' style='display:none;' class='imgcontainer'>
          105  + <img alt="syntax diagram qualified-table-name" src="images/syntax/qualified-table-name.gif" />
          106  +</div>
          107  +<p><b><a href="syntax/with-clause.html">with-clause:</a></b>
          108  +<button id='x1445' onclick='hideorshow("x1445","x1446")'>show</button></p>
          109  + <div id='x1446' style='display:none;' class='imgcontainer'>
          110  + <img alt="syntax diagram with-clause" src="images/syntax/with-clause.gif" />
          111  +<p><b><a href="syntax/cte-table-name.html">cte-table-name:</a></b>
          112  +<button id='x1447' onclick='hideorshow("x1447","x1448")'>show</button></p>
          113  + <div id='x1448' style='display:none;' class='imgcontainer'>
          114  + <img alt="syntax diagram cte-table-name" src="images/syntax/cte-table-name.gif" />
          115  +</div>
          116  +</div>
          117  +</div>
          118  +<p><b><a href="syntax/expr.html">expr:</a></b>
          119  +<button id='x1449' onclick='hideorshow("x1449","x1450")'>show</button></p>
          120  + <div id='x1450' style='display:none;' class='imgcontainer'>
          121  + <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
          122  +<p><b><a href="syntax/filter-clause.html">filter-clause:</a></b>
          123  +<button id='x1451' onclick='hideorshow("x1451","x1452")'>show</button></p>
          124  + <div id='x1452' style='display:none;' class='imgcontainer'>
          125  + <img alt="syntax diagram filter-clause" src="images/syntax/filter-clause.gif" />
          126  +</div>
          127  +<p><b><a href="syntax/literal-value.html">literal-value:</a></b>
          128  +<button id='x1453' onclick='hideorshow("x1453","x1454")'>show</button></p>
          129  + <div id='x1454' style='display:none;' class='imgcontainer'>
          130  + <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
          131  +</div>
          132  +<p><b><a href="syntax/over-clause.html">over-clause:</a></b>
          133  +<button id='x1455' onclick='hideorshow("x1455","x1456")'>show</button></p>
          134  + <div id='x1456' style='display:none;' class='imgcontainer'>
          135  + <img alt="syntax diagram over-clause" src="images/syntax/over-clause.gif" />
          136  +<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
          137  +<button id='x1457' onclick='hideorshow("x1457","x1458")'>show</button></p>
          138  + <div id='x1458' style='display:none;' class='imgcontainer'>
          139  + <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
          140  +</div>
          141  +<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
          142  +<button id='x1459' onclick='hideorshow("x1459","x1460")'>show</button></p>
          143  + <div id='x1460' style='display:none;' class='imgcontainer'>
          144  + <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
          145  +</div>
          146  +</div>
          147  +<p><b><a href="syntax/raise-function.html">raise-function:</a></b>
          148  +<button id='x1461' onclick='hideorshow("x1461","x1462")'>show</button></p>
          149  + <div id='x1462' style='display:none;' class='imgcontainer'>
          150  + <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
          151  +</div>
          152  +<p><b><a href="syntax/type-name.html">type-name:</a></b>
          153  +<button id='x1463' onclick='hideorshow("x1463","x1464")'>show</button></p>
          154  + <div id='x1464' style='display:none;' class='imgcontainer'>
          155  + <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
          156  +<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
          157  +<button id='x1465' onclick='hideorshow("x1465","x1466")'>show</button></p>
          158  + <div id='x1466' style='display:none;' class='imgcontainer'>
          159  + <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
          160  +</div>
          161  +</div>
          162  +</div>
          163  +<p><b><a href="syntax/insert-stmt.html">insert-stmt:</a></b>
          164  +<button id='x1467' onclick='hideorshow("x1467","x1468")'>show</button></p>
          165  + <div id='x1468' style='display:none;' class='imgcontainer'>
          166  + <img alt="syntax diagram insert-stmt" src="images/syntax/insert-stmt.gif" />
          167  +<p><b><a href="syntax/upsert-clause.html">upsert-clause:</a></b>
          168  +<button id='x1469' onclick='hideorshow("x1469","x1470")'>show</button></p>
          169  + <div id='x1470' style='display:none;' class='imgcontainer'>
          170  + <img alt="syntax diagram upsert-clause" src="images/syntax/upsert-clause.gif" />
          171  +<p><b><a href="syntax/column-name-list.html">column-name-list:</a></b>
          172  +<button id='x1471' onclick='hideorshow("x1471","x1472")'>show</button></p>
          173  + <div id='x1472' style='display:none;' class='imgcontainer'>
          174  + <img alt="syntax diagram column-name-list" src="images/syntax/column-name-list.gif" />
          175  +</div>
          176  +<p><b><a href="syntax/indexed-column.html">indexed-column:</a></b>
          177  +<button id='x1473' onclick='hideorshow("x1473","x1474")'>show</button></p>
          178  + <div id='x1474' style='display:none;' class='imgcontainer'>
          179  + <img alt="syntax diagram indexed-column" src="images/syntax/indexed-column.gif" />
          180  +</div>
          181  +</div>
          182  +<p><b><a href="syntax/with-clause.html">with-clause:</a></b>
          183  +<button id='x1475' onclick='hideorshow("x1475","x1476")'>show</button></p>
          184  + <div id='x1476' style='display:none;' class='imgcontainer'>
          185  + <img alt="syntax diagram with-clause" src="images/syntax/with-clause.gif" />
          186  +<p><b><a href="syntax/cte-table-name.html">cte-table-name:</a></b>
          187  +<button id='x1477' onclick='hideorshow("x1477","x1478")'>show</button></p>
          188  + <div id='x1478' style='display:none;' class='imgcontainer'>
          189  + <img alt="syntax diagram cte-table-name" src="images/syntax/cte-table-name.gif" />
          190  +</div>
          191  +</div>
          192  +</div>
          193  +<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
          194  +<button id='x1479' onclick='hideorshow("x1479","x1480")'>show</button></p>
          195  + <div id='x1480' style='display:none;' class='imgcontainer'>
          196  + <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
          197  +<p><b><a href="syntax/common-table-expression.html">common-table-expression:</a></b>
          198  +<button id='x1481' onclick='hideorshow("x1481","x1482")'>show</button></p>
          199  + <div id='x1482' style='display:none;' class='imgcontainer'>
          200  + <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
          201  +</div>
          202  +<p><b><a href="syntax/compound-operator.html">compound-operator:</a></b>
          203  +<button id='x1483' onclick='hideorshow("x1483","x1484")'>show</button></p>
          204  + <div id='x1484' style='display:none;' class='imgcontainer'>
          205  + <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
          206  +</div>
          207  +<p><b><a href="syntax/join-clause.html">join-clause:</a></b>
          208  +<button id='x1485' onclick='hideorshow("x1485","x1486")'>show</button></p>
          209  + <div id='x1486' style='display:none;' class='imgcontainer'>
          210  + <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
          211  +<p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
          212  +<button id='x1487' onclick='hideorshow("x1487","x1488")'>show</button></p>
          213  + <div id='x1488' style='display:none;' class='imgcontainer'>
          214  + <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
          215  +</div>
          216  +<p><b><a href="syntax/join-operator.html">join-operator:</a></b>
          217  +<button id='x1489' onclick='hideorshow("x1489","x1490")'>show</button></p>
          218  + <div id='x1490' style='display:none;' class='imgcontainer'>
          219  + <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
          220  +</div>
          221  +</div>
          222  +<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
          223  +<button id='x1491' onclick='hideorshow("x1491","x1492")'>show</button></p>
          224  + <div id='x1492' style='display:none;' class='imgcontainer'>
          225  + <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
          226  +</div>
          227  +<p><b><a href="syntax/result-column.html">result-column:</a></b>
          228  +<button id='x1493' onclick='hideorshow("x1493","x1494")'>show</button></p>
          229  + <div id='x1494' style='display:none;' class='imgcontainer'>
          230  + <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
          231  +</div>
          232  +<p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
          233  +<button id='x1495' onclick='hideorshow("x1495","x1496")'>show</button></p>
          234  + <div id='x1496' style='display:none;' class='imgcontainer'>
          235  + <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
          236  +</div>
          237  +<p><b><a href="syntax/window-defn.html">window-defn:</a></b>
          238  +<button id='x1497' onclick='hideorshow("x1497","x1498")'>show</button></p>
          239  + <div id='x1498' style='display:none;' class='imgcontainer'>
          240  + <img alt="syntax diagram window-defn" src="images/syntax/window-defn.gif" />
          241  +<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
          242  +<button id='x1499' onclick='hideorshow("x1499","x1500")'>show</button></p>
          243  + <div id='x1500' style='display:none;' class='imgcontainer'>
          244  + <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
          245  +</div>
          246  +</div>
          247  +</div>
          248  +<p><b><a href="syntax/update-stmt.html">update-stmt:</a></b>
          249  +<button id='x1501' onclick='hideorshow("x1501","x1502")'>show</button></p>
          250  + <div id='x1502' style='display:none;' class='imgcontainer'>
          251  + <img alt="syntax diagram update-stmt" src="images/syntax/update-stmt.gif" />
          252  +<p><b><a href="syntax/column-name-list.html">column-name-list:</a></b>
          253  +<button id='x1503' onclick='hideorshow("x1503","x1504")'>show</button></p>
          254  + <div id='x1504' style='display:none;' class='imgcontainer'>
          255  + <img alt="syntax diagram column-name-list" src="images/syntax/column-name-list.gif" />
          256  +</div>
          257  +<p><b><a href="syntax/qualified-table-name.html">qualified-table-name:</a></b>
          258  +<button id='x1505' onclick='hideorshow("x1505","x1506")'>show</button></p>
          259  + <div id='x1506' style='display:none;' class='imgcontainer'>
          260  + <img alt="syntax diagram qualified-table-name" src="images/syntax/qualified-table-name.gif" />
          261  +</div>
          262  +<p><b><a href="syntax/with-clause.html">with-clause:</a></b>
          263  +<button id='x1507' onclick='hideorshow("x1507","x1508")'>show</button></p>
          264  + <div id='x1508' style='display:none;' class='imgcontainer'>
          265  + <img alt="syntax diagram with-clause" src="images/syntax/with-clause.gif" />
          266  +<p><b><a href="syntax/cte-table-name.html">cte-table-name:</a></b>
          267  +<button id='x1509' onclick='hideorshow("x1509","x1510")'>show</button></p>
          268  + <div id='x1510' style='display:none;' class='imgcontainer'>
          269  + <img alt="syntax diagram cte-table-name" src="images/syntax/cte-table-name.gif" />
          270  +</div>
          271  +</div>
          272  +</div>
          273  +</div>
          274  +
          275  +
          276  +<p>The CREATE TRIGGER statement is used to add triggers to the 
          277  +database schema. Triggers are database operations 
          278  +that are automatically performed when a specified database event
          279  +occurs.  </p>
          280  +
          281  +<p>Each trigger must specify that it will fire for one of
          282  +the following operations: <a href="lang_delete.html">DELETE</a>, <a href="lang_insert.html">INSERT</a>, <a href="lang_update.html">UPDATE</a>.
          283  +The trigger fires once for each row that is deleted, inserted,
          284  +or updated.  If the "UPDATE OF <span class='yyterm'>column-name</span>"
          285  +syntax is used, then the trigger will only fire if
          286  +<span class='yyterm'>column-name</span> appears on the left-hand side of
          287  +one of the terms in the SET clause of the <a href="lang_update.html">UPDATE</a> statement.</p>
          288  +
          289  +<p>Due to an historical oversight, columns named in the "UPDATE OF"
          290  +clause do not actually have to exist in the table being updated.
          291  +Unrecognized column names are silently ignored.
          292  +It would be more helpful if SQLite would fail the CREATE TRIGGER
          293  +statement if any of the names in the "UPDATE OF" clause are not
          294  +columns in the table.  However, as this problem was discovered
          295  +many years after SQLite was widely deployed, we have resisted
          296  +fixing the problem for fear of breaking legacy applications.</p>
          297  +
          298  +<p>At this time SQLite supports only FOR EACH ROW triggers, not FOR EACH
          299  +STATEMENT triggers. Hence explicitly specifying FOR EACH ROW is optional.
          300  +FOR EACH ROW implies that the SQL statements specified in the trigger
          301  +may be executed (depending on the WHEN clause) for each database row being
          302  +inserted, updated or deleted by the statement causing the trigger to fire.</p>
          303  +
          304  +<p>Both the WHEN clause and the trigger actions may access elements of 
          305  +the row being inserted, deleted or updated using references of the form 
          306  +"NEW.<i>column-name</i>" and "OLD.<i>column-name</i>", where
          307  +<i>column-name</i> is the name of a column from the table that the trigger
          308  +is associated with. OLD and NEW references may only be used in triggers on
          309  +events for which they are relevant, as follows:</p>
          310  +
          311  +<table border=0 cellpadding=10>
          312  +<tr>
          313  +<td valign="top" align="right" width=120><i>INSERT</i></td>
          314  +<td valign="top">NEW references are valid</td>
          315  +</tr>
          316  +<tr>
          317  +<td valign="top" align="right" width=120><i>UPDATE</i></td>
          318  +<td valign="top">NEW and OLD references are valid</td>
          319  +</tr>
          320  +<tr>
          321  +<td valign="top" align="right" width=120><i>DELETE</i></td>
          322  +<td valign="top">OLD references are valid</td>
          323  +</tr>
          324  +</table>
          325  +</p>
          326  +
          327  +<p>If a WHEN clause is supplied, the SQL statements specified
          328  +are only executed if the WHEN clause is true.
          329  +If no WHEN clause is supplied, the SQL statements
          330  +are executed every time the trigger fires.</p>
          331  +
          332  +<p>The BEFORE or AFTER keyword determines when the trigger actions
          333  +will be executed relative to the insertion, modification or removal of the
          334  +associated row.</p>
          335  +
          336  +<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>
          337  +action within the body of the trigger.
          338  +However if an <a href="lang_conflict.html">ON CONFLICT</a> clause is specified as part of 
          339  +the statement causing the trigger to fire, then conflict handling
          340  +policy of the outer statement is used instead.</p>
          341  +
          342  +<p>Triggers are automatically <a href="lang_droptrigger.html">dropped</a>
          343  +when the table that they are 
          344  +associated with (the <i>table-name</i> table) is 
          345  +<a href="lang_droptable.html">dropped</a>.  However if the trigger actions reference
          346  +other tables, the trigger is not dropped or modified if those other
          347  +tables are <a href="lang_droptable.html">dropped</a> or <a href="lang_altertable.html">modified</a>.</p>
          348  +
          349  +<p>Triggers are removed using the <a href="lang_droptrigger.html">DROP TRIGGER</a> statement.</p>
          350  +
          351  +<h3>Syntax Restrictions On UPDATE, DELETE, and INSERT Statements Within
          352  +    Triggers</h3>
          353  +
          354  +<p>The <a href="lang_update.html">UPDATE</a>, <a href="lang_delete.html">DELETE</a>, and <a href="lang_insert.html">INSERT</a>
          355  +statements within triggers do not support
          356  +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
          357  +restrictions apply:</p>
          358  +
          359  +<ul>
          360  +<li><p>
          361  +  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>
          362  +  statement must be an unqualified table name.  In other words, one must
          363  +  use just "<i>tablename</i>" not "<i>database</i><b>.</b><i>tablename</i>"
          364  +  when specifying the table. </p></li>
          365  +
          366  +<li><p>
          367  + For non-TEMP triggers,
          368  +  the table to be modified or queried must exist in the
          369  +  same database as the table or view to which the trigger is attached.
          370  +  TEMP triggers are not subject to the same-database rule.  A TEMP
          371  +  trigger is allowed to query or modify any table in any <a href="lang_attach.html">ATTACH</a>-ed database.
          372  +  </p></li>
          373  +
          374  +<li><p>
          375  +  The "INSERT INTO <i>table</i> DEFAULT VALUES" form of the <a href="lang_insert.html">INSERT</a> statement
          376  +  is not supported.
          377  +  </p></li>
          378  +
          379  +<li><p>
          380  +  The INDEXED BY and NOT INDEXED clauses are not supported for <a href="lang_update.html">UPDATE</a> and
          381  +  <a href="lang_delete.html">DELETE</a> statements.
          382  +  </p></li>
          383  +
          384  +<li><p>
          385  +  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
          386  +  supported.  ORDER BY and LIMIT are not normally supported for <a href="lang_update.html">UPDATE</a> or
          387  +  <a href="lang_delete.html">DELETE</a> in any context but can be enabled for top-level statements
          388  +  using the <a href="compile.html#enable_update_delete_limit">SQLITE_ENABLE_UPDATE_DELETE_LIMIT</a> compile-time option.  However,
          389  +  that compile-time option only applies to top-level <a href="lang_update.html">UPDATE</a> and <a href="lang_delete.html">DELETE</a>
          390  +  statements, not <a href="lang_update.html">UPDATE</a> and <a href="lang_delete.html">DELETE</a> statements within triggers.
          391  +  </p></li>
          392  +
          393  +<li><p>
          394  +  <a href="syntax/common-table-expression.html">Common table expression</a> are not supported for
          395  +  statements inside of triggers.
          396  +  </p></li>
          397  +</ul>
          398  +
          399  +<a name="instead_of_trigger"></a>
          400  +
          401  +<h3>INSTEAD OF triggers</h3>
          402  +
          403  +<p>Triggers may be created on <a href="lang_createview.html">views</a>, as well as ordinary tables, by
          404  +specifying INSTEAD OF in the CREATE TRIGGER statement. 
          405  +If one or more ON INSERT, ON DELETE
          406  +or ON UPDATE triggers are defined on a view, then it is not an
          407  +error to execute an INSERT, DELETE or UPDATE statement on the view, 
          408  +respectively.  Instead,
          409  +executing an INSERT, DELETE or UPDATE on the view causes the associated
          410  +triggers to fire. The real tables underlying the view are not modified
          411  +(except possibly explicitly, by a trigger program).</p>
          412  +
          413  +<p>Note that the <a href="c3ref/changes.html">sqlite3_changes()</a> and <a href="c3ref/total_changes.html">sqlite3_total_changes()</a> interfaces
          414  +do not count INSTEAD OF trigger firings, but the
          415  +<a href="pragma.html#pragma_count_changes">count_changes pragma</a> does count INSTEAD OF trigger firing.</p>
          416  +
          417  +<h3>Some Example Triggers</h3>
          418  +
          419  +<p>Assuming that customer records are stored in the "customers" table, and
          420  +that order records are stored in the "orders" table, the following
          421  +UPDATE trigger
          422  +ensures that all associated orders are redirected when a customer changes
          423  +his or her address:</p>
          424  +
          425  +<blockquote><pre>
          426  +CREATE TRIGGER update_customer_address UPDATE OF address ON customers 
          427  +  BEGIN
          428  +    UPDATE orders SET address = new.address WHERE customer_name = old.name;
          429  +  END;
          430  +</pre></blockquote>
          431  +
          432  +<p>With this trigger installed, executing the statement:</p>
          433  +
          434  +<blockquote><pre>
          435  +UPDATE customers SET address = '1 Main St.' WHERE name = 'Jack Jones';
          436  +</pre></blockquote>
          437  +
          438  +<p>causes the following to be automatically executed:</p>
          439  +
          440  +<blockquote><pre>
          441  +UPDATE orders SET address = '1 Main St.' WHERE customer_name = 'Jack Jones';
          442  +</pre></blockquote>
          443  +
          444  +<p>For an example of an INSTEAD OF trigger, consider the following schema:
          445  +
          446  +<blockquote><pre>
          447  +CREATE TABLE customer(
          448  +  cust_id INTEGER PRIMARY KEY,
          449  +  cust_name TEXT,
          450  +  cust_addr TEXT
          451  +);
          452  +CREATE VIEW customer_address AS
          453  +   SELECT cust_id, cust_addr FROM customer;
          454  +CREATE TRIGGER cust_addr_chng
          455  +INSTEAD OF UPDATE OF cust_addr ON customer_address
          456  +BEGIN
          457  +  UPDATE customer SET cust_addr=NEW.cust_addr
          458  +   WHERE cust_id=NEW.cust_id;
          459  +END;
          460  +</pre></blockquote>
          461  +
          462  +<p>With the schema above, a statement of the form:</p>
          463  +
          464  +<blockquote><pre>
          465  +UPDATE customer_address SET cust_addr=$new_address WHERE cust_id=$cust_id;
          466  +</pre></blockquote>
          467  +
          468  +<p>Causes the customer.cust_addr field to be updated for a specific
          469  +customer entry that has customer.cust_id equal to the $cust_id parameter.
          470  +Note how the values assigned to the view are made available as field
          471  +in the special "NEW" table within the trigger body.</p>
          472  +
          473  +<a name="undef_before"></a>
          474  +
          475  +<h3>Cautions On The Use Of BEFORE triggers</h3>
          476  +
          477  +<p>If a BEFORE UPDATE or BEFORE DELETE trigger modifies or deletes a row
          478  +that was to have been updated or deleted, then the result of the subsequent
          479  +update or delete operation is undefined.  Furthermore, if a BEFORE trigger
          480  +modifies or deletes a row, then it is undefined whether or not AFTER triggers
          481  +that would have otherwise run on those rows will in fact run.
          482  +</p>
          483  +
          484  +<p>The value of NEW.rowid is undefined in a BEFORE INSERT trigger in which
          485  +the rowid is not explicitly set to an integer.</p>
          486  +
          487  +<p>Because of the behaviors described above, programmers are encouraged to
          488  +prefer AFTER triggers over BEFORE triggers.</p>
          489  +
          490  +<a name="raise"></a>
          491  +
          492  +<h3>The RAISE() function</h3>
          493  +
          494  +<p>A special SQL function RAISE() may be used within a trigger-program,
          495  +with the following syntax</p> 
          496  +
          497  +<p><b><a href="syntax/raise-function.html">raise-function:</a></b></p><div class='imgcontainer'>
          498  + <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif"></img>
          499  + </div>
          500  +
          501  +
          502  +<p>When one of RAISE(ROLLBACK,...), RAISE(ABORT,...) or RAISE(FAIL,...)
          503  +is called during trigger-program
          504  +execution, the specified <a href="lang_conflict.html">ON CONFLICT</a> processing is performed
          505  +the current query terminates.
          506  +An error code of <a href="rescode.html#constraint">SQLITE_CONSTRAINT</a> is returned to the application,
          507  +along with the specified error message.</p>
          508  +
          509  +<p>When RAISE(IGNORE) is called, the remainder of the current trigger program,
          510  +the statement that caused the trigger program to execute and any subsequent
          511  +trigger programs that would have been executed are abandoned. No database
          512  +changes are rolled back.  If the statement that caused the trigger program
          513  +to execute is itself part of a trigger program, then that trigger program
          514  +resumes execution at the beginning of the next step.
          515  +</p>
          516  +
          517  +<a name="temptrig"></a>
          518  +
          519  +<h3>TEMP Triggers on Non-TEMP Tables</h3>
          520  +
          521  +<p>A trigger normally exists in the same database as the table named
          522  +after the "ON" keyword in the CREATE TRIGGER statement.  Except, it is
          523  +possible to create a TEMP TRIGGER on a table in another database.  
          524  +Such a trigger will only fire when changes
          525  +are made to the target table by the application that defined the trigger.
          526  +Other applications that modify the database will not be able to see the
          527  +TEMP trigger and hence cannot run the trigger.</p>
          528  +
          529  +<p>When defining a TEMP trigger on a non-TEMP table, it is important to
          530  +specify the database holding the non-TEMP table.  For example,
          531  +in the following statement, it is important to say "main.tab1" instead
          532  +of just "tab1":</p>
          533  +
          534  +<blockquote><pre>
          535  +CREATE TEMP TRIGGER ex1 AFTER INSERT ON <b>main.</b>tab1 BEGIN ...
          536  +</pre></blockquote>
          537  +
          538  +<p>Failure to specify the schema name on the target table could result
          539  +in the TEMP trigger being reattached to a table with the same name in
          540  +another database whenever any schema change occurs.</p>
          541  +
          542  +

Added Doc/Extra/Core/lang_createview.html.

            1  +<!DOCTYPE html>
            2  +<html><head>
            3  +<meta name="viewport" content="width=device-width, initial-scale=1.0">
            4  +<meta http-equiv="content-type" content="text/html; charset=UTF-8">
            5  +<link href="sqlite.css" rel="stylesheet">
            6  +<title>SQLite Query Language: CREATE VIEW</title>
            7  +<!-- path= -->
            8  +</head>
            9  +<body>
           10  +<div class=nosearch>
           11  +<a href="index.html">
           12  +<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
           13  +</a>
           14  +<div><!-- IE hack to prevent disappearing logo --></div>
           15  +<div class="tagline desktoponly">
           16  +Small. Fast. Reliable.<br>Choose any three.
           17  +</div>
           18  +<div class="menu mainmenu">
           19  +<ul>
           20  +<li><a href="index.html">Home</a>
           21  +<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
           22  +<li class='wideonly'><a href='about.html'>About</a>
           23  +<li class='desktoponly'><a href="docs.html">Documentation</a>
           24  +<li class='desktoponly'><a href="download.html">Download</a>
           25  +<li class='wideonly'><a href='copyright.html'>License</a>
           26  +<li class='desktoponly'><a href="support.html">Support</a>
           27  +<li class='desktoponly'><a href="prosupport.html">Purchase</a>
           28  +<li class='search' id='search_menubutton'>
           29  +<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
           30  +</ul>
           31  +</div>
           32  +<div class="menu submenu" id="submenu">
           33  +<ul>
           34  +<li><a href='about.html'>About</a>
           35  +<li><a href='docs.html'>Documentation</a>
           36  +<li><a href='download.html'>Download</a>
           37  +<li><a href='support.html'>Support</a>
           38  +<li><a href='prosupport.html'>Purchase</a>
           39  +</ul>
           40  +</div>
           41  +<div class="searchmenu" id="searchmenu">
           42  +<form method="GET" action="search">
           43  +<select name="s" id="searchtype">
           44  +<option value="d">Search Documentation</option>
           45  +<option value="c">Search Changelog</option>
           46  +</select>
           47  +<input type="text" name="q" id="searchbox" value="">
           48  +<input type="submit" value="Go">
           49  +</form>
           50  +</div>
           51  +</div>
           52  +<script>
           53  +function toggle_div(nm) {
           54  +var w = document.getElementById(nm);
           55  +if( w.style.display=="block" ){
           56  +w.style.display = "none";
           57  +}else{
           58  +w.style.display = "block";
           59  +}
           60  +}
           61  +function toggle_search() {
           62  +var w = document.getElementById("searchmenu");
           63  +if( w.style.display=="block" ){
           64  +w.style.display = "none";
           65  +} else {
           66  +w.style.display = "block";
           67  +setTimeout(function(){
           68  +document.getElementById("searchbox").focus()
           69  +}, 30);
           70  +}
           71  +}
           72  +function div_off(nm){document.getElementById(nm).style.display="none";}
           73  +window.onbeforeunload = function(e){div_off("submenu");}
           74  +/* Disable the Search feature if we are not operating from CGI, since */
           75  +/* Search is accomplished using CGI and will not work without it. */
           76  +if( !location.origin.match || !location.origin.match(/http/) ){
           77  +document.getElementById("search_menubutton").style.display = "none";
           78  +}
           79  +/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
           80  +function hideorshow(btn,obj){
           81  +var x = document.getElementById(obj);
           82  +var b = document.getElementById(btn);
           83  +if( x.style.display!='none' ){
           84  +x.style.display = 'none';
           85  +b.innerHTML='show';
           86  +}else{
           87  +x.style.display = '';
           88  +b.innerHTML='hide';
           89  +}
           90  +return false;
           91  +}
           92  +</script>
           93  +</div>
           94  +<div class=nosearch><h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>CREATE VIEW</h2></div><p><b><a href="syntax/create-view-stmt.html">create-view-stmt:</a></b>
           95  +<button id='x1511' onclick='hideorshow("x1511","x1512")'>hide</button></p>
           96  + <div id='x1512' class='imgcontainer'>
           97  + <img alt="syntax diagram create-view-stmt" src="images/syntax/create-view-stmt.gif" />
           98  +<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
           99  +<button id='x1513' onclick='hideorshow("x1513","x1514")'>show</button></p>
          100  + <div id='x1514' style='display:none;' class='imgcontainer'>
          101  + <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
          102  +<p><b><a href="syntax/common-table-expression.html">common-table-expression:</a></b>
          103  +<button id='x1515' onclick='hideorshow("x1515","x1516")'>show</button></p>
          104  + <div id='x1516' style='display:none;' class='imgcontainer'>
          105  + <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
          106  +</div>
          107  +<p><b><a href="syntax/compound-operator.html">compound-operator:</a></b>
          108  +<button id='x1517' onclick='hideorshow("x1517","x1518")'>show</button></p>
          109  + <div id='x1518' style='display:none;' class='imgcontainer'>
          110  + <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
          111  +</div>
          112  +<p><b><a href="syntax/expr.html">expr:</a></b>
          113  +<button id='x1519' onclick='hideorshow("x1519","x1520")'>show</button></p>
          114  + <div id='x1520' style='display:none;' class='imgcontainer'>
          115  + <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
          116  +<p><b><a href="syntax/filter-clause.html">filter-clause:</a></b>
          117  +<button id='x1521' onclick='hideorshow("x1521","x1522")'>show</button></p>
          118  + <div id='x1522' style='display:none;' class='imgcontainer'>
          119  + <img alt="syntax diagram filter-clause" src="images/syntax/filter-clause.gif" />
          120  +</div>
          121  +<p><b><a href="syntax/literal-value.html">literal-value:</a></b>
          122  +<button id='x1523' onclick='hideorshow("x1523","x1524")'>show</button></p>
          123  + <div id='x1524' style='display:none;' class='imgcontainer'>
          124  + <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
          125  +</div>
          126  +<p><b><a href="syntax/over-clause.html">over-clause:</a></b>
          127  +<button id='x1525' onclick='hideorshow("x1525","x1526")'>show</button></p>
          128  + <div id='x1526' style='display:none;' class='imgcontainer'>
          129  + <img alt="syntax diagram over-clause" src="images/syntax/over-clause.gif" />
          130  +<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
          131  +<button id='x1527' onclick='hideorshow("x1527","x1528")'>show</button></p>
          132  + <div id='x1528' style='display:none;' class='imgcontainer'>
          133  + <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
          134  +</div>
          135  +</div>
          136  +<p><b><a href="syntax/raise-function.html">raise-function:</a></b>
          137  +<button id='x1529' onclick='hideorshow("x1529","x1530")'>show</button></p>
          138  + <div id='x1530' style='display:none;' class='imgcontainer'>
          139  + <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
          140  +</div>
          141  +<p><b><a href="syntax/type-name.html">type-name:</a></b>
          142  +<button id='x1531' onclick='hideorshow("x1531","x1532")'>show</button></p>
          143  + <div id='x1532' style='display:none;' class='imgcontainer'>
          144  + <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
          145  +<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
          146  +<button id='x1533' onclick='hideorshow("x1533","x1534")'>show</button></p>
          147  + <div id='x1534' style='display:none;' class='imgcontainer'>
          148  + <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
          149  +</div>
          150  +</div>
          151  +</div>
          152  +<p><b><a href="syntax/join-clause.html">join-clause:</a></b>
          153  +<button id='x1535' onclick='hideorshow("x1535","x1536")'>show</button></p>
          154  + <div id='x1536' style='display:none;' class='imgcontainer'>
          155  + <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
          156  +<p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
          157  +<button id='x1537' onclick='hideorshow("x1537","x1538")'>show</button></p>
          158  + <div id='x1538' style='display:none;' class='imgcontainer'>
          159  + <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
          160  +</div>
          161  +<p><b><a href="syntax/join-operator.html">join-operator:</a></b>
          162  +<button id='x1539' onclick='hideorshow("x1539","x1540")'>show</button></p>
          163  + <div id='x1540' style='display:none;' class='imgcontainer'>
          164  + <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
          165  +</div>
          166  +</div>
          167  +<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
          168  +<button id='x1541' onclick='hideorshow("x1541","x1542")'>show</button></p>
          169  + <div id='x1542' style='display:none;' class='imgcontainer'>
          170  + <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
          171  +</div>
          172  +<p><b><a href="syntax/result-column.html">result-column:</a></b>
          173  +<button id='x1543' onclick='hideorshow("x1543","x1544")'>show</button></p>
          174  + <div id='x1544' style='display:none;' class='imgcontainer'>
          175  + <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
          176  +</div>
          177  +<p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
          178  +<button id='x1545' onclick='hideorshow("x1545","x1546")'>show</button></p>
          179  + <div id='x1546' style='display:none;' class='imgcontainer'>
          180  + <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
          181  +</div>
          182  +<p><b><a href="syntax/window-defn.html">window-defn:</a></b>
          183  +<button id='x1547' onclick='hideorshow("x1547","x1548")'>show</button></p>
          184  + <div id='x1548' style='display:none;' class='imgcontainer'>
          185  + <img alt="syntax diagram window-defn" src="images/syntax/window-defn.gif" />
          186  +<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
          187  +<button id='x1549' onclick='hideorshow("x1549","x1550")'>show</button></p>
          188  + <div id='x1550' style='display:none;' class='imgcontainer'>
          189  + <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
          190  +</div>
          191  +</div>
          192  +</div>
          193  +</div>
          194  +
          195  +
          196  +<p>The CREATE VIEW command assigns a name to a pre-packaged 
          197  +<a href="lang_select.html">SELECT</a> statement. 
          198  +Once the view is created, it can be used in the FROM clause
          199  +of another <a href="lang_select.html">SELECT</a> in place of a table name.
          200  +</p>
          201  +
          202  +<p>If the "TEMP" or "TEMPORARY" keyword occurs in between "CREATE"
          203  +and "VIEW" then the view that is created is only visible to the
          204  +<a href="c3ref/sqlite3.html">database connection</a> that created it and is automatically deleted when
          205  +the database connection is closed.</p>
          206  +
          207  +<p> If a <span class='yyterm'>schema-name</span> is specified, then the view 
          208  +is created in the specified database.
          209  +It is an error to specify both a <span class='yyterm'>schema-name</span>
          210  +and the TEMP keyword on a VIEW, unless the <span class='yyterm'>schema-name</span> 
          211  +is "temp".
          212  +If no schema name is specified, and the TEMP keyword is not present,
          213  +the VIEW is created in the main database.</p>
          214  +
          215  +<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 
          216  +in SQLite.  However, in many cases you can use an
          217  +<a href="lang_createtrigger.html#instead_of_trigger">INSTEAD OF trigger</a> on the view to accomplish 
          218  +the same thing.  Views are removed 
          219  +with the <a href="lang_dropview.html">DROP VIEW</a> command.</p>
          220  +
          221  +<p>If a <span class='yyterm'>column-name</span> list follows 
          222  +the <span class='yyterm'>view-name</span>, then that list determines
          223  +the names of the columns for the view.  If the <span class='yyterm'>column-name</span>
          224  +list is omitted, then the names of the columns in the view are derived
          225  +from the names of the result-set columns in the <a href="syntax/select-stmt.html">select-stmt</a>.
          226  +The use of <span class='yyterm'>column-name</span> list is recommended.  Or, if
          227  +<span class='yyterm'>column-name</span> list is omitted, then the result
          228  +columns in the <a href="lang_select.html">SELECT</a> statement that defines the view should have
          229  +well-defined names using the 
          230  +"<a href="syntax/result-column.html">AS column-alias</a>" syntax.
          231  +SQLite allows you to create views that depend on automatically 
          232  +generated column names, but you should avoid using them since the 
          233  +rules used to generate column names are not a defined part of the
          234  +interface and might change in future releases of SQLite.
          235  +
          236  +<p>The <span class='yyterm'>column-name</span> list syntax was added in
          237  +SQLite versions 3.9.0 (2015-10-14).
          238  +
          239  +

Added Doc/Extra/Core/lang_createvtab.html.

            1  +<!DOCTYPE html>
            2  +<html><head>
            3  +<meta name="viewport" content="width=device-width, initial-scale=1.0">
            4  +<meta http-equiv="content-type" content="text/html; charset=UTF-8">
            5  +<link href="sqlite.css" rel="stylesheet">
            6  +<title>SQLite Query Language: CREATE VIRTUAL TABLE</title>
            7  +<!-- path= -->
            8  +</head>
            9  +<body>
           10  +<div class=nosearch>
           11  +<a href="index.html">
           12  +<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
           13  +</a>
           14  +<div><!-- IE hack to prevent disappearing logo --></div>
           15  +<div class="tagline desktoponly">
           16  +Small. Fast. Reliable.<br>Choose any three.
           17  +</div>
           18  +<div class="menu mainmenu">
           19  +<ul>
           20  +<li><a href="index.html">Home</a>
           21  +<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
           22  +<li class='wideonly'><a href='about.html'>About</a>
           23  +<li class='desktoponly'><a href="docs.html">Documentation</a>
           24  +<li class='desktoponly'><a href="download.html">Download</a>
           25  +<li class='wideonly'><a href='copyright.html'>License</a>
           26  +<li class='desktoponly'><a href="support.html">Support</a>
           27  +<li class='desktoponly'><a href="prosupport.html">Purchase</a>
           28  +<li class='search' id='search_menubutton'>
           29  +<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
           30  +</ul>
           31  +</div>
           32  +<div class="menu submenu" id="submenu">
           33  +<ul>
           34  +<li><a href='about.html'>About</a>
           35  +<li><a href='docs.html'>Documentation</a>
           36  +<li><a href='download.html'>Download</a>
           37  +<li><a href='support.html'>Support</a>
           38  +<li><a href='prosupport.html'>Purchase</a>
           39  +</ul>
           40  +</div>
           41  +<div class="searchmenu" id="searchmenu">
           42  +<form method="GET" action="search">
           43  +<select name="s" id="searchtype">
           44  +<option value="d">Search Documentation</option>
           45  +<option value="c">Search Changelog</option>
           46  +</select>
           47  +<input type="text" name="q" id="searchbox" value="">
           48  +<input type="submit" value="Go">
           49  +</form>
           50  +</div>
           51  +</div>
           52  +<script>
           53  +function toggle_div(nm) {
           54  +var w = document.getElementById(nm);
           55  +if( w.style.display=="block" ){
           56  +w.style.display = "none";
           57  +}else{
           58  +w.style.display = "block";
           59  +}
           60  +}
           61  +function toggle_search() {
           62  +var w = document.getElementById("searchmenu");
           63  +if( w.style.display=="block" ){
           64  +w.style.display = "none";
           65  +} else {
           66  +w.style.display = "block";
           67  +setTimeout(function(){
           68  +document.getElementById("searchbox").focus()
           69  +}, 30);
           70  +}
           71  +}
           72  +function div_off(nm){document.getElementById(nm).style.display="none";}
           73  +window.onbeforeunload = function(e){div_off("submenu");}
           74  +/* Disable the Search feature if we are not operating from CGI, since */
           75  +/* Search is accomplished using CGI and will not work without it. */
           76  +if( !location.origin.match || !location.origin.match(/http/) ){
           77  +document.getElementById("search_menubutton").style.display = "none";
           78  +}
           79  +/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
           80  +function hideorshow(btn,obj){
           81  +var x = document.getElementById(obj);
           82  +var b = document.getElementById(btn);
           83  +if( x.style.display!='none' ){
           84  +x.style.display = 'none';
           85  +b.innerHTML='show';
           86  +}else{
           87  +x.style.display = '';
           88  +b.innerHTML='hide';
           89  +}
           90  +return false;
           91  +}
           92  +</script>
           93  +</div>
           94  +<div class=nosearch><h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>CREATE VIRTUAL TABLE</h2></div><p><b><a href="syntax/create-virtual-table-stmt.html">create-virtual-table-stmt:</a></b>
           95  +<button id='x1551' onclick='hideorshow("x1551","x1552")'>hide</button></p>
           96  + <div id='x1552' class='imgcontainer'>
           97  + <img alt="syntax diagram create-virtual-table-stmt" src="images/syntax/create-virtual-table-stmt.gif" />
           98  +</div>
           99  +
          100  +
          101  +<p>A <a href="vtab.html">virtual table</a> is an interface to an external storage or computation
          102  +engine that appears to be a table but does not actually store information
          103  +in the database file.</p>
          104  +
          105  +<p>In general, you can do anything with a <a href="vtab.html">virtual table</a> that can be done
          106  +with an ordinary table, except that you cannot create indices or triggers on a
          107  +virtual table.  Some virtual table implementations might impose additional
          108  +restrictions.  For example, many virtual tables are read-only.</p>
          109  +
          110  +<p>The <span class='yyterm'>module-name</span> is the name of an object that implements
          111  +the virtual table.  The <span class='yyterm'>module-name</span> must be registered with
          112  +the SQLite database connection using
          113  +<a href="c3ref/create_module.html">sqlite3_create_module()</a> or <a href="c3ref/create_module.html">sqlite3_create_module_v2()</a>
          114  +prior to issuing the CREATE VIRTUAL TABLE statement.
          115  +The module takes zero or more comma-separated arguments.
          116  +The arguments can be just about any text as long as it has balanced
          117  +parentheses.  The argument syntax is sufficiently general that the
          118  +arguments can be made to appear as <a href="lang_createtable.html#tablecoldef">column definitions</a> in a traditional
          119  +<a href="lang_createtable.html">CREATE TABLE</a> statement.  
          120  +SQLite passes the module arguments directly
          121  +to the <a href="vtab.html#xcreate">xCreate</a> and <a href="vtab.html#xconnect">xConnect</a> methods of the module implementation
          122  +without any interpretation.  It is the responsibility
          123  +of the module implementation to parse and interpret its own arguments.</p>
          124  +
          125  +<p>A virtual table is destroyed using the ordinary
          126  +<a href="lang_droptable.html">DROP TABLE</a> statement.  There is no
          127  +DROP VIRTUAL TABLE statement.</p>
          128  +
          129  +

Added Doc/Extra/Core/lang_datefunc.html.

            1  +<!DOCTYPE html>
            2  +<html><head>
            3  +<meta name="viewport" content="width=device-width, initial-scale=1.0">
            4  +<meta http-equiv="content-type" content="text/html; charset=UTF-8">
            5  +<link href="sqlite.css" rel="stylesheet">
            6  +<title>SQLite Query Language: Date And Time Functions</title>
            7  +<!-- path= -->
            8  +</head>
            9  +<body>
           10  +<div class=nosearch>
           11  +<a href="index.html">
           12  +<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
           13  +</a>
           14  +<div><!-- IE hack to prevent disappearing logo --></div>
           15  +<div class="tagline desktoponly">
           16  +Small. Fast. Reliable.<br>Choose any three.
           17  +</div>
           18  +<div class="menu mainmenu">
           19  +<ul>
           20  +<li><a href="index.html">Home</a>
           21  +<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
           22  +<li class='wideonly'><a href='about.html'>About</a>
           23  +<li class='desktoponly'><a href="docs.html">Documentation</a>
           24  +<li class='desktoponly'><a href="download.html">Download</a>
           25  +<li class='wideonly'><a href='copyright.html'>License</a>
           26  +<li class='desktoponly'><a href="support.html">Support</a>
           27  +<li class='desktoponly'><a href="prosupport.html">Purchase</a>
           28  +<li class='search' id='search_menubutton'>
           29  +<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
           30  +</ul>
           31  +</div>
           32  +<div class="menu submenu" id="submenu">
           33  +<ul>
           34  +<li><a href='about.html'>About</a>
           35  +<li><a href='docs.html'>Documentation</a>
           36  +<li><a href='download.html'>Download</a>
           37  +<li><a href='support.html'>Support</a>
           38  +<li><a href='prosupport.html'>Purchase</a>
           39  +</ul>
           40  +</div>
           41  +<div class="searchmenu" id="searchmenu">
           42  +<form method="GET" action="search">
           43  +<select name="s" id="searchtype">
           44  +<option value="d">Search Documentation</option>
           45  +<option value="c">Search Changelog</option>
           46  +</select>
           47  +<input type="text" name="q" id="searchbox" value="">
           48  +<input type="submit" value="Go">
           49  +</form>
           50  +</div>
           51  +</div>
           52  +<script>
           53  +function toggle_div(nm) {
           54  +var w = document.getElementById(nm);
           55  +if( w.style.display=="block" ){
           56  +w.style.display = "none";
           57  +}else{
           58  +w.style.display = "block";
           59  +}
           60  +}
           61  +function toggle_search() {
           62  +var w = document.getElementById("searchmenu");
           63  +if( w.style.display=="block" ){
           64  +w.style.display = "none";
           65  +} else {
           66  +w.style.display = "block";
           67  +setTimeout(function(){
           68  +document.getElementById("searchbox").focus()
           69  +}, 30);
           70  +}
           71  +}
           72  +function div_off(nm){document.getElementById(nm).style.display="none";}
           73  +window.onbeforeunload = function(e){div_off("submenu");}
           74  +/* Disable the Search feature if we are not operating from CGI, since */
           75  +/* Search is accomplished using CGI and will not work without it. */
           76  +if( !location.origin.match || !location.origin.match(/http/) ){
           77  +document.getElementById("search_menubutton").style.display = "none";
           78  +}
           79  +/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
           80  +function hideorshow(btn,obj){
           81  +var x = document.getElementById(obj);
           82  +var b = document.getElementById(btn);
           83  +if( x.style.display!='none' ){
           84  +x.style.display = 'none';
           85  +b.innerHTML='show';
           86  +}else{
           87  +x.style.display = '';
           88  +b.innerHTML='hide';
           89  +}
           90  +return false;
           91  +}
           92  +</script>
           93  +</div>
           94  +<div class=nosearch><h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>Date And Time Functions</h2></div>
           95  +
           96  +<p>
           97  +SQLite supports five date and time functions as follows:
           98  +</p>
           99  +
          100  +<p>
          101  +<ol>
          102  +<li> <b>date(</b><i>timestring, modifier, modifier, ...</i><b>)</b> </li>
          103  +<li> <b>time(</b><i>timestring, modifier, modifier, ...</i><b>)</b> </li>
          104  +<li> <b>datetime(</b><i>timestring, modifier, modifier, ...</i><b>)</b> </li>
          105  +<li> <b>julianday(</b><i>timestring, modifier, modifier, ...</i><b>)</b> </li>
          106  +<li> <b>strftime(</b><i>format, timestring, modifier, modifier, ...</i><b>)</b> </li>
          107  +</ol>
          108  +
          109  +<p>
          110  +All five date and time functions take a time string as an argument. 
          111  +The time string is followed by zero or more modifiers. 
          112  +The strftime() function also takes a format string as its first argument.
          113  +</p>
          114  +
          115  +<p>
          116  +The date and time functions use a subset of
          117  +<a href="http://en.wikipedia.org/wiki/ISO_8601">IS0-8601</a> date and time
          118  +formats.
          119  +The date() function returns the date in this format: YYYY-MM-DD. 
          120  +The time() function returns the time as HH:MM:SS. 
          121  +The datetime() function returns "YYYY-MM-DD HH:MM:SS". 
          122  +The julianday() function returns the 
          123  +<a href="http://en.wikipedia.org/wiki/Julian_day">Julian day</a> - the
          124  +number of days since noon in Greenwich on November 24, 4714 B.C. 
          125  +(<a href="http://en.wikipedia.org/wiki/Proleptic_Gregorian_calendar">Proleptic Gregorian calendar</a>).
          126  +The strftime() routine returns the date formatted according to 
          127  +the format string specified as the first argument.
          128  +The format string supports the most common substitutions found in the 
          129  +<a href="http://opengroup.org/onlinepubs/007908799/xsh/strftime.html">strftime() function</a>
          130  +from the standard C library plus two new substitutions, %f and %J.
          131  +The following is a complete list of valid strftime() substitutions:
          132  +</p>
          133  +
          134  +<blockquote>
          135  +<table border="0" cellpadding="0" cellspacing="0">
          136  +<tr><td><td width="10"><td></tr>
          137  +
          138  +<tr><td> %d <td><td> day of month: 00
          139  +<tr><td> %f <td><td> fractional seconds: SS.SSS
          140  +<tr><td> %H <td><td> hour: 00-24 
          141  +<tr><td> %j <td><td> day of year: 001-366
          142  +<tr><td> %J <td><td> Julian day number
          143  +<tr><td> %m <td><td> month: 01-12
          144  +<tr><td> %M <td><td> minute: 00-59
          145  +<tr><td> %s <td><td> seconds since 1970-01-01
          146  +<tr><td> %S <td><td> seconds: 00-59
          147  +<tr><td> %w <td><td> day of week 0-6 with Sunday==0
          148  +<tr><td> %W <td><td> week of year: 00-53
          149  +<tr><td> %Y <td><td> year: 0000-9999
          150  +<tr><td> %% <td><td> %
          151  +</table>
          152  +</blockquote>
          153  +
          154  +<p>
          155  +Notice that all other date and time functions can be expressed
          156  +in terms of strftime():
          157  +</p>
          158  +
          159  +<blockquote>
          160  +<table border="0" cellpadding="0" cellspacing="0">
          161  +<tr><td><b>Function</b><td width="30"><td><b>Equivalent strftime()</b>
          162  +<tr><td>   date(...)      <td><td>  strftime('%Y-%m-%d', ...)
          163  +<tr><td>   time(...)      <td><td>  strftime('%H:%M:%S', ...)
          164  +<tr><td>   datetime(...)  <td><td>  strftime('%Y-%m-%d %H:%M:%S', ...)
          165  +<tr><td>   julianday(...) <td><td>  strftime('%J', ...)
          166  +</table>
          167  +</blockquote>
          168  +
          169  +<p>
          170  +The only reasons for providing functions other than strftime() is
          171  +for convenience and for efficiency.
          172  +</p>
          173  +
          174  +<h3>Time Strings</h3>
          175  +
          176  +<p>A time string can be in any of the following formats:</p>
          177  +
          178  +<ol>
          179  +<li> <i>YYYY-MM-DD</i>
          180  +<li> <i>YYYY-MM-DD HH:MM</i>
          181  +<li> <i>YYYY-MM-DD HH:MM:SS</i>
          182  +<li> <i>YYYY-MM-DD HH:MM:SS.SSS</i>
          183  +<li> <i>YYYY-MM-DD</i><b>T</b><i>HH:MM</i>
          184  +<li> <i>YYYY-MM-DD</i><b>T</b><i>HH:MM:SS</i>
          185  +<li> <i>YYYY-MM-DD</i><b>T</b><i>HH:MM:SS.SSS</i>
          186  +<li> <i>HH:MM</i>
          187  +<li> <i>HH:MM:SS</i>
          188  +<li> <i>HH:MM:SS.SSS</i>
          189  +<li> <b>now</b>
          190  +<li> <i>DDDDDDDDDD</i>
          191  +</ol>
          192  +
          193  +<p>
          194  +In formats 5 through 7, the "T" is a literal character separating 
          195  +the date and the time, as required by 
          196  +<a href="http://www.w3c.org/TR/NOTE-datetime">ISO-8601</a>. 
          197  +Formats 8 through 10 that specify only a time assume a date of 
          198  +2000-01-01. Format 11, the string 'now', is converted into the 
          199  +current date and time as obtained from the xCurrentTime method
          200  +of the <a href="c3ref/vfs.html">sqlite3_vfs</a> object in use.
          201  +The 'now' argument to date and time functions always returns exactly the
          202  +same value for multiple invocations within the same <a href="c3ref/step.html">sqlite3_step()</a> call.
          203  +<a href="http://en.wikipedia.org/wiki/Coordinated_Universal_Time">Universal Coordinated Time (UTC)</a> is used. 
          204  +Format 12 is the 
          205  +<a href="http://en.wikipedia.org/wiki/Julian_day">Julian day number</a>
          206  +expressed as a floating point value.
          207  +</p>
          208  +
          209  +<p>
          210  +Formats 2 through 10 may be optionally followed by a timezone indicator of the form
          211  +"<i>&#91;+-&#93;HH:MM</i>" or just "<i>Z</i>".  The date and time functions use UTC or "zulu"
          212  +time internally, and so the "Z" suffix is a no-op.  Any non-zero "HH:MM" suffix is
          213  +subtracted from the indicated date and time in order to compute zulu time.
          214  +For example, all of the following time strings are equivalent:
          215  +</p>
          216  +
          217  +<blockquote>
          218  +2013-10-07 08:23:19.120<br>
          219  +2013-10-07T08:23:19.120Z<br>
          220  +2013-10-07 04:23:19.120-04:00<br>
          221  +2456572.84952685
          222  +</blockquote>
          223  +
          224  +<p>
          225  +In formats 4, 7, and 10, the fractional seconds value SS.SSS can have
          226  +one or more digits following the decimal point.  Exactly three digits are
          227  +shown in the examples because only the first three digits are significant
          228  +to the result, but the input string can have fewer or more than three digits
          229  +and the date/time functions will still operate correctly.
          230  +Similarly, format 12 is shown with 10 significant digits, but the date/time
          231  +functions will really accept as many or as few digits as are necessary to
          232  +represent the Julian day number.
          233  +</p>
          234  +
          235  +<h3>Modifiers</h3>
          236  +
          237  +<p>The time string can be followed by zero or more modifiers that 
          238  +alter date and/or time. Each modifier
          239  +is a transformation that is applied to the time value to its left.
          240  +Modifiers are applied from left to right; order is important.
          241  +The available modifiers are as follows.</p>
          242  +
          243  +<ol>
          244  +<li> NNN days
          245  +<li> NNN hours
          246  +<li> NNN minutes
          247  +<li> NNN.NNNN seconds
          248  +<li> NNN months
          249  +<li> NNN years
          250  +<li> start of month
          251  +<li> start of year
          252  +<li> start of day
          253  +<li> weekday N
          254  +<li> unixepoch
          255  +<li> localtime
          256  +<li> utc 
          257  +</ol>
          258  +
          259  +<p>The first six modifiers (1 through 6) 
          260  +simply add the specified amount of time to the date and time 
          261  +specified by the preceding timestring and modifiers.
          262  +The 's' character at the end of the modifier names is optional.
          263  +Note that "&plusmn;NNN months" works by rendering the original date into
          264  +the YYYY-MM-DD format, adding the &plusmn;NNN to the MM month value, then
          265  +normalizing the result.  Thus, for example, the data 2001-03-31 modified
          266  +by '+1 month' initially yields 2001-04-31, but April only has 30 days
          267  +so the date is normalized to 2001-05-01.  A similar effect occurs when
          268  +the original date is February 29 of a leapyear and the modifier is
          269  +&plusmn;N years where N is not a multiple of four.</p>
          270  +
          271  +<p>The "start of" modifiers (7 through 9) shift the date backwards 
          272  +to the beginning of the current month, year or day.</p>
          273  +
          274  +<p>The "weekday" modifier advances the date forward, if necessary,
          275  +to the next date where the weekday number is N. Sunday is 0, Monday is 1,
          276  +and so forth.
          277  +If the date is already on the desired weekday, the "weekday" modifier
          278  +leaves the date unchanged.  </p>
          279  +
          280  +<p>The "unixepoch" modifier (11) only works if it immediately follows 
          281  +a timestring in the DDDDDDDDDD format. 
          282  +This modifier causes the DDDDDDDDDD to be interpreted not 
          283  +as a Julian day number as it normally would be, but as
          284  +<a href="http://en.wikipedia.org/wiki/Unix_time">Unix Time</a> - the 
          285  +number of seconds since 1970.  If the "unixepoch" modifier does not
          286  +follow a timestring of the form DDDDDDDDDD which expresses the number
          287  +of seconds since 1970 or if other modifiers
          288  +separate the "unixepoch" modifier from prior DDDDDDDDDD then the
          289  +behavior is undefined.
          290  +For SQLite versions before 3.16.0 (2017-01-02), 
          291  +the "unixepoch" modifier only works for
          292  +dates between 0000-01-01 00:00:00 and 5352-11-01 10:52:47 (unix times
          293  +of -62167219200 through 106751991167).</p>
          294  +
          295  +<a name="localtime"></a>
          296  +
          297  +<p>The "localtime" modifier (12) assumes the time string to its left is in
          298  +Universal Coordinated Time (UTC) and adjusts the time
          299  +string so that it displays localtime.  If "localtime"
          300  +follows a time that is not UTC, then the behavior is undefined.
          301  +The "utc" modifier is the opposite of "localtime".  
          302  +"utc" assumes that the string
          303  +to its left is in the local timezone and adjusts that string to be in UTC.
          304  +If the prior string is not in localtime, then the result of "utc" is
          305  +undefined.</p>
          306  +
          307  +<h3>Examples</h3>
          308  +
          309  +<p>Compute the current date.<p>
          310  +
          311  +<blockquote>SELECT date('now');</blockquote>
          312  +
          313  +<p>Compute the last day of the current month.</p>
          314  +
          315  +<blockquote>SELECT date('now','start of month','+1 month','-1 day');
          316  +</blockquote>
          317  +
          318  +<p>Compute the date and time given a unix timestamp 1092941466.</p>
          319  +
          320  +<blockquote>
          321  +    SELECT datetime(1092941466, 'unixepoch');
          322  +</blockquote>
          323  +
          324  +<p>Compute the date and time given a unix timestamp 1092941466, and 
          325  +compensate for your local timezone.</p>
          326  +
          327  +<blockquote>
          328  +  SELECT datetime(1092941466, 'unixepoch', 'localtime');
          329  +</blockquote>
          330  +
          331  +<p>Compute the current unix timestamp.</p>
          332  +
          333  +<blockquote>
          334  +  SELECT strftime('%s','now');
          335  +</blockquote>
          336  +
          337  +<p>Compute the number of days since the signing of the US Declaration
          338  +of Independence.</p>
          339  +
          340  +<blockquote>
          341  +  SELECT julianday('now') - julianday('1776-07-04');
          342  +</blockquote>
          343  +
          344  +<p>Compute the number of seconds since a particular moment in 2004:</p>
          345  +
          346  +<blockquote>
          347  +  SELECT strftime('%s','now') - strftime('%s','2004-01-01 02:34:56');
          348  +</blockquote>
          349  +
          350  +<p>
          351  +Compute the date of the first Tuesday in October
          352  +for the current year.
          353  +</p>
          354  +
          355  +<blockquote>
          356  +  SELECT date('now','start of year','+9 months','weekday 2');
          357  +</blockquote>
          358  +
          359  +<p>Compute the time since the unix epoch in seconds 
          360  +(like strftime('%s','now') except includes fractional part):</p>
          361  +
          362  +<blockquote>
          363  +  SELECT (julianday('now') - 2440587.5)*86400.0;
          364  +</blockquote>
          365  +
          366  +<h3>Caveats And Bugs</h3>
          367  +
          368  +<p>The computation of local time depends heavily on the whim 
          369  +of politicians and is thus difficult to get correct for 
          370  +all locales. In this implementation, the standard C library 
          371  +function localtime_r() is used to assist in the calculation of 
          372  +local time.  The 
          373  +localtime_r() C function normally only works for years
          374  +between 1970 and 2037. For dates outside this range, SQLite 
          375  +attempts to map the year into an equivalent year within 
          376  +this range, do the calculation, then map the year back.</p>
          377  +
          378  +
          379  +<p>These functions only work for dates between 0000-01-01 00:00:00
          380  +and 9999-12-31 23:59:59 (julian day numbers 1721059.5 through 5373484.5).
          381  +For dates outside that range, the results of these
          382  +functions are undefined.</p>
          383  +
          384  +<p>Non-Vista Windows platforms only support one set of DST rules. 
          385  +Vista only supports two. Therefore, on these platforms, 
          386  +historical DST calculations will be incorrect. 
          387  +For example, in the US, in 2007 the DST rules changed. 
          388  +Non-Vista Windows platforms apply the new 2007 DST rules 
          389  +to all previous years as well. Vista does somewhat better
          390  +getting results correct back to 1986, when the rules were also changed.</p>
          391  +
          392  +<p>All internal computations assume the 
          393  +<a href="http://en.wikipedia.org/wiki/Gregorian_calendar">Gregorian calendar</a>
          394  +system.  It is also assumed that every
          395  +day is exactly 86400 seconds in duration.</p>
          396  +
          397  +

Added Doc/Extra/Core/lang_delete.html.

            1  +<!DOCTYPE html>
            2  +<html><head>
            3  +<meta name="viewport" content="width=device-width, initial-scale=1.0">
            4  +<meta http-equiv="content-type" content="text/html; charset=UTF-8">
            5  +<link href="sqlite.css" rel="stylesheet">
            6  +<title>SQLite Query Language: DELETE</title>
            7  +<!-- path= -->
            8  +</head>
            9  +<body>
           10  +<div class=nosearch>
           11  +<a href="index.html">
           12  +<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
           13  +</a>
           14  +<div><!-- IE hack to prevent disappearing logo --></div>
           15  +<div class="tagline desktoponly">
           16  +Small. Fast. Reliable.<br>Choose any three.
           17  +</div>
           18  +<div class="menu mainmenu">
           19  +<ul>
           20  +<li><a href="index.html">Home</a>
           21  +<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
           22  +<li class='wideonly'><a href='about.html'>About</a>
           23  +<li class='desktoponly'><a href="docs.html">Documentation</a>
           24  +<li class='desktoponly'><a href="download.html">Download</a>
           25  +<li class='wideonly'><a href='copyright.html'>License</a>
           26  +<li class='desktoponly'><a href="support.html">Support</a>
           27  +<li class='desktoponly'><a href="prosupport.html">Purchase</a>
           28  +<li class='search' id='search_menubutton'>
           29  +<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
           30  +</ul>
           31  +</div>
           32  +<div class="menu submenu" id="submenu">
           33  +<ul>
           34  +<li><a href='about.html'>About</a>
           35  +<li><a href='docs.html'>Documentation</a>
           36  +<li><a href='download.html'>Download</a>
           37  +<li><a href='support.html'>Support</a>
           38  +<li><a href='prosupport.html'>Purchase</a>
           39  +</ul>
           40  +</div>
           41  +<div class="searchmenu" id="searchmenu">
           42  +<form method="GET" action="search">
           43  +<select name="s" id="searchtype">
           44  +<option value="d">Search Documentation</option>
           45  +<option value="c">Search Changelog</option>
           46  +</select>
           47  +<input type="text" name="q" id="searchbox" value="">
           48  +<input type="submit" value="Go">
           49  +</form>
           50  +</div>
           51  +</div>
           52  +<script>
           53  +function toggle_div(nm) {
           54  +var w = document.getElementById(nm);
           55  +if( w.style.display=="block" ){
           56  +w.style.display = "none";
           57  +}else{
           58  +w.style.display = "block";
           59  +}
           60  +}
           61  +function toggle_search() {
           62  +var w = document.getElementById("searchmenu");
           63  +if( w.style.display=="block" ){
           64  +w.style.display = "none";
           65  +} else {
           66  +w.style.display = "block";
           67  +setTimeout(function(){
           68  +document.getElementById("searchbox").focus()
           69  +}, 30);
           70  +}
           71  +}
           72  +function div_off(nm){document.getElementById(nm).style.display="none";}
           73  +window.onbeforeunload = function(e){div_off("submenu");}
           74  +/* Disable the Search feature if we are not operating from CGI, since */
           75  +/* Search is accomplished using CGI and will not work without it. */
           76  +if( !location.origin.match || !location.origin.match(/http/) ){
           77  +document.getElementById("search_menubutton").style.display = "none";
           78  +}
           79  +/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
           80  +function hideorshow(btn,obj){
           81  +var x = document.getElementById(obj);
           82  +var b = document.getElementById(btn);
           83  +if( x.style.display!='none' ){
           84  +x.style.display = 'none';
           85  +b.innerHTML='show';
           86  +}else{
           87  +x.style.display = '';
           88  +b.innerHTML='hide';
           89  +}
           90  +return false;
           91  +}
           92  +</script>
           93  +</div>
           94  +<div class=nosearch><h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>DELETE</h2></div><p><b><a href="syntax/delete-stmt.html">delete-stmt:</a></b>
           95  +<button id='x1553' onclick='hideorshow("x1553","x1554")'>hide</button></p>
           96  + <div id='x1554' class='imgcontainer'>
           97  + <img alt="syntax diagram delete-stmt" src="images/syntax/delete-stmt.gif" />
           98  +<p><b><a href="syntax/expr.html">expr:</a></b>
           99  +<button id='x1555' onclick='hideorshow("x1555","x1556")'>show</button></p>
          100  + <div id='x1556' style='display:none;' class='imgcontainer'>
          101  + <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
          102  +<p><b><a href="syntax/filter-clause.html">filter-clause:</a></b>
          103  +<button id='x1557' onclick='hideorshow("x1557","x1558")'>show</button></p>
          104  + <div id='x1558' style='display:none;' class='imgcontainer'>
          105  + <img alt="syntax diagram filter-clause" src="images/syntax/filter-clause.gif" />
          106  +</div>
          107  +<p><b><a href="syntax/literal-value.html">literal-value:</a></b>
          108  +<button id='x1559' onclick='hideorshow("x1559","x1560")'>show</button></p>
          109  + <div id='x1560' style='display:none;' class='imgcontainer'>
          110  + <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
          111  +</div>
          112  +<p><b><a href="syntax/over-clause.html">over-clause:</a></b>
          113  +<button id='x1561' onclick='hideorshow("x1561","x1562")'>show</button></p>
          114  + <div id='x1562' style='display:none;' class='imgcontainer'>
          115  + <img alt="syntax diagram over-clause" src="images/syntax/over-clause.gif" />
          116  +<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
          117  +<button id='x1563' onclick='hideorshow("x1563","x1564")'>show</button></p>
          118  + <div id='x1564' style='display:none;' class='imgcontainer'>
          119  + <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
          120  +</div>
          121  +<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
          122  +<button id='x1565' onclick='hideorshow("x1565","x1566")'>show</button></p>
          123  + <div id='x1566' style='display:none;' class='imgcontainer'>
          124  + <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
          125  +</div>
          126  +</div>
          127  +<p><b><a href="syntax/raise-function.html">raise-function:</a></b>
          128  +<button id='x1567' onclick='hideorshow("x1567","x1568")'>show</button></p>
          129  + <div id='x1568' style='display:none;' class='imgcontainer'>
          130  + <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
          131  +</div>
          132  +<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
          133  +<button id='x1569' onclick='hideorshow("x1569","x1570")'>show</button></p>
          134  + <div id='x1570' style='display:none;' class='imgcontainer'>
          135  + <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
          136  +<p><b><a href="syntax/common-table-expression.html">common-table-expression:</a></b>
          137  +<button id='x1571' onclick='hideorshow("x1571","x1572")'>show</button></p>
          138  + <div id='x1572' style='display:none;' class='imgcontainer'>
          139  + <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
          140  +</div>
          141  +<p><b><a href="syntax/compound-operator.html">compound-operator:</a></b>
          142  +<button id='x1573' onclick='hideorshow("x1573","x1574")'>show</button></p>
          143  + <div id='x1574' style='display:none;' class='imgcontainer'>
          144  + <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
          145  +</div>
          146  +<p><b><a href="syntax/join-clause.html">join-clause:</a></b>
          147  +<button id='x1575' onclick='hideorshow("x1575","x1576")'>show</button></p>
          148  + <div id='x1576' style='display:none;' class='imgcontainer'>
          149  + <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
          150  +<p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
          151  +<button id='x1577' onclick='hideorshow("x1577","x1578")'>show</button></p>
          152  + <div id='x1578' style='display:none;' class='imgcontainer'>
          153  + <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
          154  +</div>
          155  +<p><b><a href="syntax/join-operator.html">join-operator:</a></b>
          156  +<button id='x1579' onclick='hideorshow("x1579","x1580")'>show</button></p>
          157  + <div id='x1580' style='display:none;' class='imgcontainer'>
          158  + <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
          159  +</div>
          160  +</div>
          161  +<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
          162  +<button id='x1581' onclick='hideorshow("x1581","x1582")'>show</button></p>
          163  + <div id='x1582' style='display:none;' class='imgcontainer'>
          164  + <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
          165  +</div>
          166  +<p><b><a href="syntax/result-column.html">result-column:</a></b>
          167  +<button id='x1583' onclick='hideorshow("x1583","x1584")'>show</button></p>
          168  + <div id='x1584' style='display:none;' class='imgcontainer'>
          169  + <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
          170  +</div>
          171  +<p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
          172  +<button id='x1585' onclick='hideorshow("x1585","x1586")'>show</button></p>
          173  + <div id='x1586' style='display:none;' class='imgcontainer'>
          174  + <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
          175  +</div>
          176  +<p><b><a href="syntax/window-defn.html">window-defn:</a></b>
          177  +<button id='x1587' onclick='hideorshow("x1587","x1588")'>show</button></p>
          178  + <div id='x1588' style='display:none;' class='imgcontainer'>
          179  + <img alt="syntax diagram window-defn" src="images/syntax/window-defn.gif" />
          180  +<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
          181  +<button id='x1589' onclick='hideorshow("x1589","x1590")'>show</button></p>
          182  + <div id='x1590' style='display:none;' class='imgcontainer'>
          183  + <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
          184  +</div>
          185  +</div>
          186  +</div>
          187  +<p><b><a href="syntax/type-name.html">type-name:</a></b>
          188  +<button id='x1591' onclick='hideorshow("x1591","x1592")'>show</button></p>
          189  + <div id='x1592' style='display:none;' class='imgcontainer'>
          190  + <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
          191  +<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
          192  +<button id='x1593' onclick='hideorshow("x1593","x1594")'>show</button></p>
          193  + <div id='x1594' style='display:none;' class='imgcontainer'>
          194  + <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
          195  +</div>
          196  +</div>
          197  +</div>
          198  +<p><b><a href="syntax/qualified-table-name.html">qualified-table-name:</a></b>
          199  +<button id='x1595' onclick='hideorshow("x1595","x1596")'>show</button></p>
          200  + <div id='x1596' style='display:none;' class='imgcontainer'>
          201  + <img alt="syntax diagram qualified-table-name" src="images/syntax/qualified-table-name.gif" />
          202  +</div>
          203  +<p><b><a href="syntax/with-clause.html">with-clause:</a></b>
          204  +<button id='x1597' onclick='hideorshow("x1597","x1598")'>show</button></p>
          205  + <div id='x1598' style='display:none;' class='imgcontainer'>
          206  + <img alt="syntax diagram with-clause" src="images/syntax/with-clause.gif" />
          207  +<p><b><a href="syntax/cte-table-name.html">cte-table-name:</a></b>
          208  +<button id='x1599' onclick='hideorshow("x1599","x1600")'>show</button></p>
          209  + <div id='x1600' style='display:none;' class='imgcontainer'>
          210  + <img alt="syntax diagram cte-table-name" src="images/syntax/cte-table-name.gif" />
          211  +</div>
          212  +<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
          213  +<button id='x1601' onclick='hideorshow("x1601","x1602")'>show</button></p>
          214  + <div id='x1602' style='display:none;' class='imgcontainer'>
          215  + <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
          216  +<p><b><a href="syntax/common-table-expression.html">common-table-expression:</a></b>
          217  +<button id='x1603' onclick='hideorshow("x1603","x1604")'>show</button></p>
          218  + <div id='x1604' style='display:none;' class='imgcontainer'>
          219  + <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
          220  +</div>
          221  +<p><b><a href="syntax/compound-operator.html">compound-operator:</a></b>
          222  +<button id='x1605' onclick='hideorshow("x1605","x1606")'>show</button></p>
          223  + <div id='x1606' style='display:none;' class='imgcontainer'>
          224  + <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
          225  +</div>
          226  +<p><b><a href="syntax/join-clause.html">join-clause:</a></b>
          227  +<button id='x1607' onclick='hideorshow("x1607","x1608")'>show</button></p>
          228  + <div id='x1608' style='display:none;' class='imgcontainer'>
          229  + <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
          230  +<p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
          231  +<button id='x1609' onclick='hideorshow("x1609","x1610")'>show</button></p>
          232  + <div id='x1610' style='display:none;' class='imgcontainer'>
          233  + <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
          234  +</div>
          235  +<p><b><a href="syntax/join-operator.html">join-operator:</a></b>
          236  +<button id='x1611' onclick='hideorshow("x1611","x1612")'>show</button></p>
          237  + <div id='x1612' style='display:none;' class='imgcontainer'>
          238  + <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
          239  +</div>
          240  +</div>
          241  +<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
          242  +<button id='x1613' onclick='hideorshow("x1613","x1614")'>show</button></p>
          243  + <div id='x1614' style='display:none;' class='imgcontainer'>
          244  + <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
          245  +</div>
          246  +<p><b><a href="syntax/result-column.html">result-column:</a></b>
          247  +<button id='x1615' onclick='hideorshow("x1615","x1616")'>show</button></p>
          248  + <div id='x1616' style='display:none;' class='imgcontainer'>
          249  + <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
          250  +</div>
          251  +<p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
          252  +<button id='x1617' onclick='hideorshow("x1617","x1618")'>show</button></p>
          253  + <div id='x1618' style='display:none;' class='imgcontainer'>
          254  + <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
          255  +</div>
          256  +<p><b><a href="syntax/window-defn.html">window-defn:</a></b>
          257  +<button id='x1619' onclick='hideorshow("x1619","x1620")'>show</button></p>
          258  + <div id='x1620' style='display:none;' class='imgcontainer'>
          259  + <img alt="syntax diagram window-defn" src="images/syntax/window-defn.gif" />
          260  +<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
          261  +<button id='x1621' onclick='hideorshow("x1621","x1622")'>show</button></p>
          262  + <div id='x1622' style='display:none;' class='imgcontainer'>
          263  + <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
          264  +</div>
          265  +</div>
          266  +</div>
          267  +</div>
          268  +</div>
          269  +
          270  +
          271  +<p>The DELETE command removes records from the table identified by the
          272  +   <a href="syntax/qualified-table-name.html">qualified-table-name</a>.
          273  +
          274  +<p>If the WHERE clause is not present, all records in the table are deleted.
          275  +   If a WHERE clause is supplied, then only those rows for which the
          276  +   WHERE clause <a href="lang_expr.html#booleanexpr">boolean expression</a> is true are deleted.
          277  +   Rows for which the expression is false or NULL are retained.
          278  +
          279  +<h3>Restrictions on DELETE Statements Within CREATE TRIGGER</h3>
          280  +
          281  +<p>The following restrictions apply to DELETE statements that occur within the
          282  +   body of a <a href="lang_createtrigger.html">CREATE TRIGGER</a> statement:
          283  +
          284  +<ul>
          285  +  <li><p>The <span class='yyterm'>table-name</span> specified as part of a 
          286  +    DELETE statement within
          287  +    a trigger body must be unqualified.  In other words, the
          288  +    <i>schema-name</i><b>.</b> prefix on the table name is not allowed 
          289  +    within triggers. If the table to which the trigger is attached is
          290  +    not in the temp database, then DELETE statements within the trigger
          291  +    body must operate on tables within the same database as it. If the table
          292  +    to which the trigger is attached is in the TEMP database, then the
          293  +    unqualified name of the table being deleted is resolved in the same way as
          294  +    it is for a top-level statement (by searching first the TEMP database, then
          295  +    the main database, then any other databases in the order they were
          296  +    attached).
          297  +    
          298  +  <li><p>The INDEXED BY and NOT INDEXED clauses are not allowed on DELETE
          299  +    statements within triggers.</p>
          300  +
          301  +  <li><p>The LIMIT and ORDER BY clauses (described below) are unsupported for
          302  +    DELETE statements within triggers.</p>
          303  +</ul>
          304  +
          305  +<h3>Optional LIMIT and ORDER BY clauses</h3>
          306  +
          307  +<p>If SQLite is compiled with the <a href="compile.html#enable_update_delete_limit">SQLITE_ENABLE_UPDATE_DELETE_LIMIT</a>
          308  +compile-time option, then the syntax of the DELETE statement is
          309  +extended by the addition of optional ORDER BY and LIMIT clauses:</p>
          310  +
          311  +<p><b><a href="syntax/delete-stmt-limited.html">delete-stmt-limited:</a></b></p><div class='imgcontainer'>
          312  + <img alt="syntax diagram delete-stmt-limited" src="images/syntax/delete-stmt-limited.gif"></img>
          313  + </div>
          314  +
          315  +
          316  +<p>If a DELETE statement has a LIMIT clause, the maximum number of rows that
          317  +will be deleted is found by evaluating the accompanying expression and casting
          318  +it to an integer value. If the result of the evaluating the LIMIT clause
          319  +cannot be losslessly converted to an integer value, it is an error. A 
          320  +negative LIMIT value is interpreted as "no limit". If the DELETE statement 
          321  +also has an OFFSET clause, then it is similarly evaluated and cast to an
          322  +integer value. Again, it is an error if the value cannot be losslessly
          323  +converted to an integer. If there is no OFFSET clause, or the calculated
          324  +integer value is negative, the effective OFFSET value is zero.
          325  +
          326  +<p>If the DELETE statement has an ORDER BY clause, then all rows that would 
          327  +be deleted in the absence of the LIMIT clause are sorted according to the 
          328  +ORDER BY. The first <i>M</i> rows, where <i>M</i> is the value found by
          329  +evaluating the OFFSET clause expression, are skipped, and the following 
          330  +<i>N</i>, where <i>N</i> is the value of the LIMIT expression, are deleted.
          331  +If there are less than <i>N</i> rows remaining after taking the OFFSET clause
          332  +into account, or if the LIMIT clause evaluated to a negative value, then all
          333  +remaining rows are deleted.
          334  +
          335  +<p>If the DELETE statement has no ORDER BY clause, then all rows that
          336  +would be deleted in the absence of the LIMIT clause are assembled in an
          337  +arbitrary order before applying the LIMIT and OFFSET clauses to determine 
          338  +the subset that are actually deleted.
          339  +
          340  +<p>The ORDER BY clause on a DELETE statement is used only to determine which
          341  +rows fall within the LIMIT. The order in which rows are deleted is arbitrary
          342  +and is not influenced by the ORDER BY clause.
          343  +
          344  +<a name="truncateopt"></a>
          345  +
          346  +<h3>The Truncate Optimization</h3>
          347  +
          348  +<p>When the WHERE is omitted from a DELETE statement and the table
          349  +being deleted has no triggers,
          350  +SQLite uses an optimization to erase the entire table content
          351  +without having to visit each row of the table individually.
          352  +This "truncate" optimization makes the delete run much faster.
          353  +Prior to SQLite <a href="releaselog/3_6_5.html">version 3.6.5</a> (2008-11-12), the truncate optimization
          354  +also meant that the <a href="c3ref/changes.html">sqlite3_changes()</a> and
          355  +<a href="c3ref/total_changes.html">sqlite3_total_changes()</a> interfaces
          356  +and the <a href="pragma.html#pragma_count_changes">count_changes pragma</a>
          357  +will not actually return the number of deleted rows.  
          358  +That problem has been fixed as of <a href="releaselog/3_6_5.html">version 3.6.5</a> (2008-11-12).
          359  +
          360  +<p>The truncate optimization can be permanently disabled for all queries
          361  +by recompiling
          362  +SQLite with the <a href="compile.html#omit_truncate_optimization">SQLITE_OMIT_TRUNCATE_OPTIMIZATION</a> compile-time switch.</p>
          363  +
          364  +<p>The truncate optimization can also be disabled at runtime using
          365  +the <a href="c3ref/set_authorizer.html">sqlite3_set_authorizer()</a> interface.  If an authorizer callback
          366  +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
          367  +the DELETE operation will proceed but the truncate optimization will
          368  +be bypassed and rows will be deleted one by one.</p>
          369  +
          370  +

Added Doc/Extra/Core/lang_detach.html.

            1  +<!DOCTYPE html>
            2  +<html><head>
            3  +<meta name="viewport" content="width=device-width, initial-scale=1.0">
            4  +<meta http-equiv="content-type" content="text/html; charset=UTF-8">
            5  +<link href="sqlite.css" rel="stylesheet">
            6  +<title>SQLite Query Language: DETACH DATABASE</title>
            7  +<!-- path= -->
            8  +</head>
            9  +<body>
           10  +<div class=nosearch>
           11  +<a href="index.html">
           12  +<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
           13  +</a>
           14  +<div><!-- IE hack to prevent disappearing logo --></div>
           15  +<div class="tagline desktoponly">
           16  +Small. Fast. Reliable.<br>Choose any three.
           17  +</div>
           18  +<div class="menu mainmenu">
           19  +<ul>
           20  +<li><a href="index.html">Home</a>
           21  +<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
           22  +<li class='wideonly'><a href='about.html'>About</a>
           23  +<li class='desktoponly'><a href="docs.html">Documentation</a>
           24  +<li class='desktoponly'><a href="download.html">Download</a>
           25  +<li class='wideonly'><a href='copyright.html'>License</a>
           26  +<li class='desktoponly'><a href="support.html">Support</a>
           27  +<li class='desktoponly'><a href="prosupport.html">Purchase</a>
           28  +<li class='search' id='search_menubutton'>
           29  +<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
           30  +</ul>
           31  +</div>
           32  +<div class="menu submenu" id="submenu">
           33  +<ul>
           34  +<li><a href='about.html'>About</a>
           35  +<li><a href='docs.html'>Documentation</a>
           36  +<li><a href='download.html'>Download</a>
           37  +<li><a href='support.html'>Support</a>
           38  +<li><a href='prosupport.html'>Purchase</a>
           39  +</ul>
           40  +</div>
           41  +<div class="searchmenu" id="searchmenu">
           42  +<form method="GET" action="search">
           43  +<select name="s" id="searchtype">
           44  +<option value="d">Search Documentation</option>
           45  +<option value="c">Search Changelog</option>
           46  +</select>
           47  +<input type="text" name="q" id="searchbox" value="">
           48  +<input type="submit" value="Go">
           49  +</form>
           50  +</div>
           51  +</div>
           52  +<script>
           53  +function toggle_div(nm) {
           54  +var w = document.getElementById(nm);
           55  +if( w.style.display=="block" ){
           56  +w.style.display = "none";
           57  +}else{
           58  +w.style.display = "block";
           59  +}
           60  +}
           61  +function toggle_search() {
           62  +var w = document.getElementById("searchmenu");
           63  +if( w.style.display=="block" ){
           64  +w.style.display = "none";
           65  +} else {
           66  +w.style.display = "block";
           67  +setTimeout(function(){
           68  +document.getElementById("searchbox").focus()
           69  +}, 30);
           70  +}
           71  +}
           72  +function div_off(nm){document.getElementById(nm).style.display="none";}
           73  +window.onbeforeunload = function(e){div_off("submenu");}
           74  +/* Disable the Search feature if we are not operating from CGI, since */
           75  +/* Search is accomplished using CGI and will not work without it. */
           76  +if( !location.origin.match || !location.origin.match(/http/) ){
           77  +document.getElementById("search_menubutton").style.display = "none";
           78  +}
           79  +/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
           80  +function hideorshow(btn,obj){
           81  +var x = document.getElementById(obj);
           82  +var b = document.getElementById(btn);
           83  +if( x.style.display!='none' ){
           84  +x.style.display = 'none';
           85  +b.innerHTML='show';
           86  +}else{
           87  +x.style.display = '';
           88  +b.innerHTML='hide';
           89  +}
           90  +return false;
           91  +}
           92  +</script>
           93  +</div>
           94  +<div class=nosearch><h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>DETACH DATABASE</h2></div><p><b><a href="syntax/detach-stmt.html">detach-stmt:</a></b>
           95  +<button id='x1623' onclick='hideorshow("x1623","x1624")'>hide</button></p>
           96  + <div id='x1624' class='imgcontainer'>
           97  + <img alt="syntax diagram detach-stmt" src="images/syntax/detach-stmt.gif" />
           98  +</div>
           99  +
          100  +
          101  +<p>This statement detaches an additional database connection previously 
          102  +attached using the <a href="lang_attach.html">ATTACH</a> statement.  
          103  +When not in <a href="sharedcache.html">shared cache mode</a>, 
          104  +it is possible to have the same database file attached multiple times using 
          105  +different names, and detaching one connection to a file will leave the 
          106  +others intact.</p>
          107  +In <a href="sharedcache.html">shared cache mode</a>, attempting to attach the same database file more
          108  +than once results in an error.
          109  +
          110  +
          111  +

Added Doc/Extra/Core/lang_dropindex.html.

            1  +<!DOCTYPE html>
            2  +<html><head>
            3  +<meta name="viewport" content="width=device-width, initial-scale=1.0">
            4  +<meta http-equiv="content-type" content="text/html; charset=UTF-8">
            5  +<link href="sqlite.css" rel="stylesheet">
            6  +<title>SQLite Query Language: DROP INDEX</title>
            7  +<!-- path= -->
            8  +</head>
            9  +<body>
           10  +<div class=nosearch>
           11  +<a href="index.html">
           12  +<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
           13  +</a>
           14  +<div><!-- IE hack to prevent disappearing logo --></div>
           15  +<div class="tagline desktoponly">
           16  +Small. Fast. Reliable.<br>Choose any three.
           17  +</div>
           18  +<div class="menu mainmenu">
           19  +<ul>
           20  +<li><a href="index.html">Home</a>
           21  +<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
           22  +<li class='wideonly'><a href='about.html'>About</a>
           23  +<li class='desktoponly'><a href="docs.html">Documentation</a>
           24  +<li class='desktoponly'><a href="download.html">Download</a>
           25  +<li class='wideonly'><a href='copyright.html'>License</a>
           26  +<li class='desktoponly'><a href="support.html">Support</a>
           27  +<li class='desktoponly'><a href="prosupport.html">Purchase</a>
           28  +<li class='search' id='search_menubutton'>
           29  +<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
           30  +</ul>
           31  +</div>
           32  +<div class="menu submenu" id="submenu">
           33  +<ul>
           34  +<li><a href='about.html'>About</a>
           35  +<li><a href='docs.html'>Documentation</a>
           36  +<li><a href='download.html'>Download</a>
           37  +<li><a href='support.html'>Support</a>
           38  +<li><a href='prosupport.html'>Purchase</a>
           39  +</ul>
           40  +</div>
           41  +<div class="searchmenu" id="searchmenu">
           42  +<form method="GET" action="search">
           43  +<select name="s" id="searchtype">
           44  +<option value="d">Search Documentation</option>
           45  +<option value="c">Search Changelog</option>
           46  +</select>
           47  +<input type="text" name="q" id="searchbox" value="">
           48  +<input type="submit" value="Go">
           49  +</form>
           50  +</div>
           51  +</div>
           52  +<script>
           53  +function toggle_div(nm) {
           54  +var w = document.getElementById(nm);
           55  +if( w.style.display=="block" ){
           56  +w.style.display = "none";
           57  +}else{
           58  +w.style.display = "block";
           59  +}
           60  +}
           61  +function toggle_search() {
           62  +var w = document.getElementById("searchmenu");
           63  +if( w.style.display=="block" ){
           64  +w.style.display = "none";
           65  +} else {
           66  +w.style.display = "block";
           67  +setTimeout(function(){
           68  +document.getElementById("searchbox").focus()
           69  +}, 30);
           70  +}
           71  +}
           72  +function div_off(nm){document.getElementById(nm).style.display="none";}
           73  +window.onbeforeunload = function(e){div_off("submenu");}
           74  +/* Disable the Search feature if we are not operating from CGI, since */
           75  +/* Search is accomplished using CGI and will not work without it. */
           76  +if( !location.origin.match || !location.origin.match(/http/) ){
           77  +document.getElementById("search_menubutton").style.display = "none";
           78  +}
           79  +/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
           80  +function hideorshow(btn,obj){
           81  +var x = document.getElementById(obj);
           82  +var b = document.getElementById(btn);
           83  +if( x.style.display!='none' ){
           84  +x.style.display = 'none';
           85  +b.innerHTML='show';
           86  +}else{
           87  +x.style.display = '';
           88  +b.innerHTML='hide';
           89  +}
           90  +return false;
           91  +}
           92  +</script>
           93  +</div>
           94  +<div class=nosearch><h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>DROP INDEX</h2></div><p><b><a href="syntax/drop-index-stmt.html">drop-index-stmt:</a></b>
           95  +<button id='x1625' onclick='hideorshow("x1625","x1626")'>hide</button></p>
           96  + <div id='x1626' class='imgcontainer'>
           97  + <img alt="syntax diagram drop-index-stmt" src="images/syntax/drop-index-stmt.gif" />
           98  +</div>
           99  +
          100  +
          101  +<p>The DROP INDEX statement removes an index added
          102  +with the <a href="lang_createindex.html">CREATE INDEX</a> statement.  The index is completely removed from
          103  +the disk.  The only way to recover the index is to reenter the
          104  +appropriate <a href="lang_createindex.html">CREATE INDEX</a> command.</p>
          105  +
          106  +

Added Doc/Extra/Core/lang_droptable.html.

            1  +<!DOCTYPE html>
            2  +<html><head>
            3  +<meta name="viewport" content="width=device-width, initial-scale=1.0">
            4  +<meta http-equiv="content-type" content="text/html; charset=UTF-8">
            5  +<link href="sqlite.css" rel="stylesheet">
            6  +<title>SQLite Query Language: DROP TABLE</title>
            7  +<!-- path= -->
            8  +</head>
            9  +<body>
           10  +<div class=nosearch>
           11  +<a href="index.html">
           12  +<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
           13  +</a>
           14  +<div><!-- IE hack to prevent disappearing logo --></div>
           15  +<div class="tagline desktoponly">
           16  +Small. Fast. Reliable.<br>Choose any three.
           17  +</div>
           18  +<div class="menu mainmenu">
           19  +<ul>
           20  +<li><a href="index.html">Home</a>
           21  +<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
           22  +<li class='wideonly'><a href='about.html'>About</a>
           23  +<li class='desktoponly'><a href="docs.html">Documentation</a>
           24  +<li class='desktoponly'><a href="download.html">Download</a>
           25  +<li class='wideonly'><a href='copyright.html'>License</a>
           26  +<li class='desktoponly'><a href="support.html">Support</a>
           27  +<li class='desktoponly'><a href="prosupport.html">Purchase</a>
           28  +<li class='search' id='search_menubutton'>
           29  +<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
           30  +</ul>
           31  +</div>
           32  +<div class="menu submenu" id="submenu">
           33  +<ul>
           34  +<li><a href='about.html'>About</a>
           35  +<li><a href='docs.html'>Documentation</a>
           36  +<li><a href='download.html'>Download</a>
           37  +<li><a href='support.html'>Support</a>
           38  +<li><a href='prosupport.html'>Purchase</a>
           39  +</ul>
           40  +</div>
           41  +<div class="searchmenu" id="searchmenu">
           42  +<form method="GET" action="search">
           43  +<select name="s" id="searchtype">
           44  +<option value="d">Search Documentation</option>
           45  +<option value="c">Search Changelog</option>
           46  +</select>
           47  +<input type="text" name="q" id="searchbox" value="">
           48  +<input type="submit" value="Go">
           49  +</form>
           50  +</div>
           51  +</div>
           52  +<script>
           53  +function toggle_div(nm) {
           54  +var w = document.getElementById(nm);
           55  +if( w.style.display=="block" ){
           56  +w.style.display = "none";
           57  +}else{
           58  +w.style.display = "block";
           59  +}
           60  +}
           61  +function toggle_search() {
           62  +var w = document.getElementById("searchmenu");
           63  +if( w.style.display=="block" ){
           64  +w.style.display = "none";
           65  +} else {
           66  +w.style.display = "block";
           67  +setTimeout(function(){
           68  +document.getElementById("searchbox").focus()
           69  +}, 30);
           70  +}
           71  +}
           72  +function div_off(nm){document.getElementById(nm).style.display="none";}
           73  +window.onbeforeunload = function(e){div_off("submenu");}
           74  +/* Disable the Search feature if we are not operating from CGI, since */
           75  +/* Search is accomplished using CGI and will not work without it. */
           76  +if( !location.origin.match || !location.origin.match(/http/) ){
           77  +document.getElementById("search_menubutton").style.display = "none";
           78  +}
           79  +/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
           80  +function hideorshow(btn,obj){
           81  +var x = document.getElementById(obj);
           82  +var b = document.getElementById(btn);
           83  +if( x.style.display!='none' ){
           84  +x.style.display = 'none';
           85  +b.innerHTML='show';
           86  +}else{
           87  +x.style.display = '';
           88  +b.innerHTML='hide';
           89  +}
           90  +return false;
           91  +}
           92  +</script>
           93  +</div>
           94  +<div class=nosearch><h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>DROP TABLE</h2></div><p><b><a href="syntax/drop-table-stmt.html">drop-table-stmt:</a></b>
           95  +<button id='x1627' onclick='hideorshow("x1627","x1628")'>hide</button></p>
           96  + <div id='x1628' class='imgcontainer'>
           97  + <img alt="syntax diagram drop-table-stmt" src="images/syntax/drop-table-stmt.gif" />
           98  +</div>
           99  +
          100  +
          101  +<p>The DROP TABLE statement removes a table added with the
          102  +<a href="lang_createtable.html">CREATE TABLE</a> statement.  The name specified is the
          103  +table name.  The dropped table is completely removed from the database 
          104  +schema and the disk file.  The table can not be recovered.  
          105  +All indices and triggers
          106  +associated with the table are also deleted.</p>
          107  +
          108  +<p>The optional IF EXISTS clause suppresses the error that would normally
          109  +result if the table does not exist.</p>
          110  +
          111  +<p>If <a href="foreignkeys.html">foreign key constraints</a> are enabled, a DROP TABLE command performs an
          112  +implicit <a href="lang_delete.html">DELETE FROM</a> command before removing the
          113  +table from the database schema. Any triggers attached to the table are
          114  +dropped from the database schema before the implicit DELETE FROM
          115  +is executed, so this cannot cause any triggers to fire. By contrast, an
          116  +implicit DELETE FROM does cause any configured
          117  +<a href="foreignkeys.html#fk_actions">foreign key actions</a> to take place. 
          118  +If the implicit DELETE FROM executed
          119  +as part of a DROP TABLE command violates any immediate foreign key constraints,
          120  +an error is returned and the table is not dropped. If 
          121  +the implicit DELETE FROM causes any 
          122  +deferred foreign key constraints to be violated, and the violations still
          123  +exist when the transaction is committed, an error is returned at the time
          124  +of commit.
          125  +
          126  +

Added Doc/Extra/Core/lang_droptrigger.html.

            1  +<!DOCTYPE html>
            2  +<html><head>
            3  +<meta name="viewport" content="width=device-width, initial-scale=1.0">
            4  +<meta http-equiv="content-type" content="text/html; charset=UTF-8">
            5  +<link href="sqlite.css" rel="stylesheet">
            6  +<title>SQLite Query Language: DROP TRIGGER</title>
            7  +<!-- path= -->
            8  +</head>
            9  +<body>
           10  +<div class=nosearch>
           11  +<a href="index.html">
           12  +<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
           13  +</a>
           14  +<div><!-- IE hack to prevent disappearing logo --></div>
           15  +<div class="tagline desktoponly">
           16  +Small. Fast. Reliable.<br>Choose any three.
           17  +</div>
           18  +<div class="menu mainmenu">
           19  +<ul>
           20  +<li><a href="index.html">Home</a>
           21  +<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
           22  +<li class='wideonly'><a href='about.html'>About</a>
           23  +<li class='desktoponly'><a href="docs.html">Documentation</a>
           24  +<li class='desktoponly'><a href="download.html">Download</a>
           25  +<li class='wideonly'><a href='copyright.html'>License</a>
           26  +<li class='desktoponly'><a href="support.html">Support</a>
           27  +<li class='desktoponly'><a href="prosupport.html">Purchase</a>
           28  +<li class='search' id='search_menubutton'>
           29  +<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
           30  +</ul>
           31  +</div>
           32  +<div class="menu submenu" id="submenu">
           33  +<ul>
           34  +<li><a href='about.html'>About</a>
           35  +<li><a href='docs.html'>Documentation</a>
           36  +<li><a href='download.html'>Download</a>
           37  +<li><a href='support.html'>Support</a>
           38  +<li><a href='prosupport.html'>Purchase</a>
           39  +</ul>
           40  +</div>
           41  +<div class="searchmenu" id="searchmenu">
           42  +<form method="GET" action="search">
           43  +<select name="s" id="searchtype">
           44  +<option value="d">Search Documentation</option>
           45  +<option value="c">Search Changelog</option>
           46  +</select>
           47  +<input type="text" name="q" id="searchbox" value="">
           48  +<input type="submit" value="Go">
           49  +</form>
           50  +</div>
           51  +</div>
           52  +<script>
           53  +function toggle_div(nm) {
           54  +var w = document.getElementById(nm);
           55  +if( w.style.display=="block" ){
           56  +w.style.display = "none";
           57  +}else{
           58  +w.style.display = "block";
           59  +}
           60  +}
           61  +function toggle_search() {
           62  +var w = document.getElementById("searchmenu");
           63  +if( w.style.display=="block" ){
           64  +w.style.display = "none";
           65  +} else {
           66  +w.style.display = "block";
           67  +setTimeout(function(){
           68  +document.getElementById("searchbox").focus()
           69  +}, 30);
           70  +}
           71  +}
           72  +function div_off(nm){document.getElementById(nm).style.display="none";}
           73  +window.onbeforeunload = function(e){div_off("submenu");}
           74  +/* Disable the Search feature if we are not operating from CGI, since */
           75  +/* Search is accomplished using CGI and will not work without it. */
           76  +if( !location.origin.match || !location.origin.match(/http/) ){
           77  +document.getElementById("search_menubutton").style.display = "none";
           78  +}
           79  +/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
           80  +function hideorshow(btn,obj){
           81  +var x = document.getElementById(obj);
           82  +var b = document.getElementById(btn);
           83  +if( x.style.display!='none' ){
           84  +x.style.display = 'none';
           85  +b.innerHTML='show';
           86  +}else{
           87  +x.style.display = '';
           88  +b.innerHTML='hide';
           89  +}
           90  +return false;
           91  +}
           92  +</script>
           93  +</div>
           94  +<div class=nosearch><h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>DROP TRIGGER</h2></div><p><b><a href="syntax/drop-trigger-stmt.html">drop-trigger-stmt:</a></b>
           95  +<button id='x1629' onclick='hideorshow("x1629","x1630")'>hide</button></p>
           96  + <div id='x1630' class='imgcontainer'>
           97  + <img alt="syntax diagram drop-trigger-stmt" src="images/syntax/drop-trigger-stmt.gif" />
           98  +</div>
           99  +
          100  +
          101  +<p>The DROP TRIGGER statement removes a trigger created by the 
          102  +<a href="lang_createtrigger.html">CREATE TRIGGER</a> statement. Once removed, the trigger definition is no
          103  +longer present in the sqlite_master (or sqlite_temp_master) table and is
          104  +not fired by any subsequent INSERT, UPDATE or DELETE statements.
          105  +
          106  +<p>Note that triggers are automatically dropped when the associated table is
          107  +dropped.
          108  +
          109  +

Added Doc/Extra/Core/lang_dropview.html.

            1  +<!DOCTYPE html>
            2  +<html><head>
            3  +<meta name="viewport" content="width=device-width, initial-scale=1.0">
            4  +<meta http-equiv="content-type" content="text/html; charset=UTF-8">
            5  +<link href="sqlite.css" rel="stylesheet">
            6  +<title>SQLite Query Language: DROP VIEW</title>
            7  +<!-- path= -->
            8  +</head>
            9  +<body>
           10  +<div class=nosearch>
           11  +<a href="index.html">
           12  +<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
           13  +</a>
           14  +<div><!-- IE hack to prevent disappearing logo --></div>
           15  +<div class="tagline desktoponly">
           16  +Small. Fast. Reliable.<br>Choose any three.
           17  +</div>
           18  +<div class="menu mainmenu">
           19  +<ul>
           20  +<li><a href="index.html">Home</a>
           21  +<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
           22  +<li class='wideonly'><a href='about.html'>About</a>
           23  +<li class='desktoponly'><a href="docs.html">Documentation</a>
           24  +<li class='desktoponly'><a href="download.html">Download</a>
           25  +<li class='wideonly'><a href='copyright.html'>License</a>
           26  +<li class='desktoponly'><a href="support.html">Support</a>
           27  +<li class='desktoponly'><a href="prosupport.html">Purchase</a>
           28  +<li class='search' id='search_menubutton'>
           29  +<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
           30  +</ul>
           31  +</div>
           32  +<div class="menu submenu" id="submenu">
           33  +<ul>
           34  +<li><a href='about.html'>About</a>
           35  +<li><a href='docs.html'>Documentation</a>
           36  +<li><a href='download.html'>Download</a>
           37  +<li><a href='support.html'>Support</a>
           38  +<li><a href='prosupport.html'>Purchase</a>
           39  +</ul>
           40  +</div>
           41  +<div class="searchmenu" id="searchmenu">
           42  +<form method="GET" action="search">
           43  +<select name="s" id="searchtype">
           44  +<option value="d">Search Documentation</option>
           45  +<option value="c">Search Changelog</option>
           46  +</select>
           47  +<input type="text" name="q" id="searchbox" value="">
           48  +<input type="submit" value="Go">
           49  +</form>
           50  +</div>
           51  +</div>
           52  +<script>
           53  +function toggle_div(nm) {
           54  +var w = document.getElementById(nm);
           55  +if( w.style.display=="block" ){
           56  +w.style.display = "none";
           57  +}else{
           58  +w.style.display = "block";
           59  +}
           60  +}
           61  +function toggle_search() {
           62  +var w = document.getElementById("searchmenu");
           63  +if( w.style.display=="block" ){
           64  +w.style.display = "none";
           65  +} else {
           66  +w.style.display = "block";
           67  +setTimeout(function(){
           68  +document.getElementById("searchbox").focus()
           69  +}, 30);
           70  +}
           71  +}
           72  +function div_off(nm){document.getElementById(nm).style.display="none";}
           73  +window.onbeforeunload = function(e){div_off("submenu");}
           74  +/* Disable the Search feature if we are not operating from CGI, since */
           75  +/* Search is accomplished using CGI and will not work without it. */
           76  +if( !location.origin.match || !location.origin.match(/http/) ){
           77  +document.getElementById("search_menubutton").style.display = "none";
           78  +}
           79  +/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
           80  +function hideorshow(btn,obj){
           81  +var x = document.getElementById(obj);
           82  +var b = document.getElementById(btn);
           83  +if( x.style.display!='none' ){
           84  +x.style.display = 'none';
           85  +b.innerHTML='show';
           86  +}else{
           87  +x.style.display = '';
           88  +b.innerHTML='hide';
           89  +}
           90  +return false;
           91  +}
           92  +</script>
           93  +</div>
           94  +<div class=nosearch><h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>DROP VIEW</h2></div><p><b><a href="syntax/drop-view-stmt.html">drop-view-stmt:</a></b>
           95  +<button id='x1631' onclick='hideorshow("x1631","x1632")'>hide</button></p>
           96  + <div id='x1632' class='imgcontainer'>
           97  + <img alt="syntax diagram drop-view-stmt" src="images/syntax/drop-view-stmt.gif" />
           98  +</div>
           99  +
          100  +
          101  +<p>The DROP VIEW statement removes a view created by the <a href="lang_createview.html">CREATE VIEW</a> 
          102  +  statement. The view definition is removed from the database schema, but 
          103  +  no actual data in the underlying base tables is modified.
          104  +
          105  +<p>The view to drop is identified by the view-name and optional 
          106  +  schema-name specified as part of the DROP VIEW statement. This 
          107  +  reference is resolved using the standard procedure for <a href="lang_naming.html">object resolution</a>.
          108  +
          109  +<p>
          110  +  If the specified view cannot be found and the IF EXISTS clause is not 
          111  +  present, it is an error. If the specified view cannot be found and an IF
          112  +  EXISTS clause is present in the DROP VIEW statement, then the statement
          113  +  is a no-op.
          114  +
          115  +
          116  +

Added Doc/Extra/Core/lang_explain.html.

            1  +<!DOCTYPE html>
            2  +<html><head>
            3  +<meta name="viewport" content="width=device-width, initial-scale=1.0">
            4  +<meta http-equiv="content-type" content="text/html; charset=UTF-8">
            5  +<link href="sqlite.css" rel="stylesheet">
            6  +<title>SQLite Query Language: EXPLAIN</title>
            7  +<!-- path= -->
            8  +</head>
            9  +<body>
           10  +<div class=nosearch>
           11  +<a href="index.html">
           12  +<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
           13  +</a>
           14  +<div><!-- IE hack to prevent disappearing logo --></div>
           15  +<div class="tagline desktoponly">
           16  +Small. Fast. Reliable.<br>Choose any three.
           17  +</div>
           18  +<div class="menu mainmenu">
           19  +<ul>
           20  +<li><a href="index.html">Home</a>
           21  +<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
           22  +<li class='wideonly'><a href='about.html'>About</a>
           23  +<li class='desktoponly'><a href="docs.html">Documentation</a>
           24  +<li class='desktoponly'><a href="download.html">Download</a>
           25  +<li class='wideonly'><a href='copyright.html'>License</a>
           26  +<li class='desktoponly'><a href="support.html">Support</a>
           27  +<li class='desktoponly'><a href="prosupport.html">Purchase</a>
           28  +<li class='search' id='search_menubutton'>
           29  +<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
           30  +</ul>
           31  +</div>
           32  +<div class="menu submenu" id="submenu">
           33  +<ul>
           34  +<li><a href='about.html'>About</a>
           35  +<li><a href='docs.html'>Documentation</a>
           36  +<li><a href='download.html'>Download</a>
           37  +<li><a href='support.html'>Support</a>
           38  +<li><a href='prosupport.html'>Purchase</a>
           39  +</ul>
           40  +</div>
           41  +<div class="searchmenu" id="searchmenu">
           42  +<form method="GET" action="search">
           43  +<select name="s" id="searchtype">
           44  +<option value="d">Search Documentation</option>
           45  +<option value="c">Search Changelog</option>
           46  +</select>
           47  +<input type="text" name="q" id="searchbox" value="">
           48  +<input type="submit" value="Go">
           49  +</form>
           50  +</div>
           51  +</div>
           52  +<script>
           53  +function toggle_div(nm) {
           54  +var w = document.getElementById(nm);
           55  +if( w.style.display=="block" ){
           56  +w.style.display = "none";
           57  +}else{
           58  +w.style.display = "block";
           59  +}
           60  +}
           61  +function toggle_search() {
           62  +var w = document.getElementById("searchmenu");
           63  +if( w.style.display=="block" ){
           64  +w.style.display = "none";
           65  +} else {
           66  +w.style.display = "block";
           67  +setTimeout(function(){
           68  +document.getElementById("searchbox").focus()
           69  +}, 30);
           70  +}
           71  +}
           72  +function div_off(nm){document.getElementById(nm).style.display="none";}
           73  +window.onbeforeunload = function(e){div_off("submenu");}
           74  +/* Disable the Search feature if we are not operating from CGI, since */
           75  +/* Search is accomplished using CGI and will not work without it. */
           76  +if( !location.origin.match || !location.origin.match(/http/) ){
           77  +document.getElementById("search_menubutton").style.display = "none";
           78  +}
           79  +/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
           80  +function hideorshow(btn,obj){
           81  +var x = document.getElementById(obj);
           82  +var b = document.getElementById(btn);
           83  +if( x.style.display!='none' ){
           84  +x.style.display = 'none';
           85  +b.innerHTML='show';
           86  +}else{
           87  +x.style.display = '';
           88  +b.innerHTML='hide';
           89  +}
           90  +return false;
           91  +}
           92  +</script>
           93  +</div>
           94  +<div class=nosearch><h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>EXPLAIN</h2></div><p><b><a href="syntax/sql-stmt.html">sql-stmt:</a></b></p><div class='imgcontainer'>
           95  + <img alt="syntax diagram sql-stmt" src="images/syntax/sql-stmt.gif"></img>
           96  + </div>
           97  +
           98  +
           99  +<p>An SQL statement can be preceded by the keyword "EXPLAIN" or
          100  +by the phrase "EXPLAIN QUERY PLAN".  Either modification causes the
          101  +SQL statement to behave as a query and to return information about
          102  +how the SQL statement would have operated if the EXPLAIN keyword or
          103  +phrase had been omitted.</p>
          104  +
          105  +<p>The output from EXPLAIN and EXPLAIN QUERY PLAN is intended for
          106  +interactive analysis and troubleshooting only.  The details of the 
          107  +output format are subject to change from one release of SQLite to the next.
          108  +Applications should not use EXPLAIN or EXPLAIN QUERY PLAN since
          109  +their exact behavior is variable and only partially documented.</p>
          110  +
          111  +<p>When the EXPLAIN keyword appears by itself it causes the statement
          112  +to behave as a query that returns the sequence of 
          113  +<a href="opcode.html">virtual machine instructions</a> it would have used to execute the command had
          114  +the EXPLAIN keyword not been present. When the EXPLAIN QUERY PLAN phrase
          115  +appears, the statement returns high-level information regarding the query
          116  +plan that would have been used.
          117  +
          118  +<p>The EXPLAIN QUERY PLAN command is described in 
          119  +<a href="eqp.html">more detail here</a>.
          120  +
          121  +<h3>EXPLAIN operates at run-time, not at prepare-time</h3>
          122  +
          123  +<p>The EXPLAIN and EXPLAIN QUERY PLAN prefixes affect the behavior of
          124  +running a <a href="c3ref/stmt.html">prepared statement</a> using <a href="c3ref/step.html">sqlite3_step()</a>.  The process of
          125  +generating a new prepared statement using <a href="c3ref/prepare.html">sqlite3_prepare()</a> or similar
          126  +is (mostly) unaffected by EXPLAIN.  (The exception to the previous sentence
          127  +is that some special opcodes used by EXPLAIN QUERY PLAN are omitted when
          128  +building an EXPLAIN QUERY PLAN prepared statement, as a performance
          129  +optimization.)
          130  +
          131  +<p>This means that actions that occur during sqlite3_prepare() are
          132  +unaffected by EXPLAIN.
          133  +
          134  +<ul>
          135  +<li><p>
          136  +Some <a href="pragma.html#syntax">PRAGMA</a> statements do their work during sqlite3_prepare() rather
          137  +than during sqlite3_step().  Those PRAGMA statements are unaffected
          138  +by EXPLAIN.  They operate the same with or without the EXPLAIN prefix.
          139  +The set of PRAGMA statements that are unaffected by EXPLAIN can vary
          140  +from one release to the next.  Some PRAGMA statements operate during
          141  +sqlite3_prepare() depending on their arguments.  For consistent
          142  +results, avoid using EXPLAIN on PRAGMA statements.
          143  +
          144  +<li><p>
          145  +The <a href="c3ref/set_authorizer.html">authorizer callback</a> is invoked regardless of the presence of
          146  +EXPLAIN or EXPLAIN QUERY PLAN.
          147  +</ul>
          148  +

Added Doc/Extra/Core/lang_expr.html.

            1  +<!DOCTYPE html>
            2  +<html><head>
            3  +<meta name="viewport" content="width=device-width, initial-scale=1.0">
            4  +<meta http-equiv="content-type" content="text/html; charset=UTF-8">
            5  +<link href="sqlite.css" rel="stylesheet">
            6  +<title>SQLite Query Language: expression</title>
            7  +<!-- path= -->
            8  +</head>
            9  +<body>
           10  +<div class=nosearch>
           11  +<a href="index.html">
           12  +<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
           13  +</a>
           14  +<div><!-- IE hack to prevent disappearing logo --></div>
           15  +<div class="tagline desktoponly">
           16  +Small. Fast. Reliable.<br>Choose any three.
           17  +</div>
           18  +<div class="menu mainmenu">
           19  +<ul>
           20  +<li><a href="index.html">Home</a>
           21  +<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
           22  +<li class='wideonly'><a href='about.html'>About</a>
           23  +<li class='desktoponly'><a href="docs.html">Documentation</a>
           24  +<li class='desktoponly'><a href="download.html">Download</a>
           25  +<li class='wideonly'><a href='copyright.html'>License</a>
           26  +<li class='desktoponly'><a href="support.html">Support</a>
           27  +<li class='desktoponly'><a href="prosupport.html">Purchase</a>
           28  +<li class='search' id='search_menubutton'>
           29  +<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
           30  +</ul>
           31  +</div>
           32  +<div class="menu submenu" id="submenu">
           33  +<ul>
           34  +<li><a href='about.html'>About</a>
           35  +<li><a href='docs.html'>Documentation</a>
           36  +<li><a href='download.html'>Download</a>
           37  +<li><a href='support.html'>Support</a>
           38  +<li><a href='prosupport.html'>Purchase</a>
           39  +</ul>
           40  +</div>
           41  +<div class="searchmenu" id="searchmenu">
           42  +<form method="GET" action="search">
           43  +<select name="s" id="searchtype">
           44  +<option value="d">Search Documentation</option>
           45  +<option value="c">Search Changelog</option>
           46  +</select>
           47  +<input type="text" name="q" id="searchbox" value="">
           48  +<input type="submit" value="Go">
           49  +</form>
           50  +</div>
           51  +</div>
           52  +<script>
           53  +function toggle_div(nm) {
           54  +var w = document.getElementById(nm);
           55  +if( w.style.display=="block" ){
           56  +w.style.display = "none";
           57  +}else{
           58  +w.style.display = "block";
           59  +}
           60  +}
           61  +function toggle_search() {
           62  +var w = document.getElementById("searchmenu");
           63  +if( w.style.display=="block" ){
           64  +w.style.display = "none";
           65  +} else {
           66  +w.style.display = "block";
           67  +setTimeout(function(){
           68  +document.getElementById("searchbox").focus()
           69  +}, 30);
           70  +}
           71  +}
           72  +function div_off(nm){document.getElementById(nm).style.display="none";}
           73  +window.onbeforeunload = function(e){div_off("submenu");}
           74  +/* Disable the Search feature if we are not operating from CGI, since */
           75  +/* Search is accomplished using CGI and will not work without it. */
           76  +if( !location.origin.match || !location.origin.match(/http/) ){
           77  +document.getElementById("search_menubutton").style.display = "none";
           78  +}
           79  +/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
           80  +function hideorshow(btn,obj){
           81  +var x = document.getElementById(obj);
           82  +var b = document.getElementById(btn);
           83  +if( x.style.display!='none' ){
           84  +x.style.display = 'none';
           85  +b.innerHTML='show';
           86  +}else{
           87  +x.style.display = '';
           88  +b.innerHTML='hide';
           89  +}
           90  +return false;
           91  +}
           92  +</script>
           93  +</div>
           94  +<div class=nosearch><h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>expression</h2></div><p><b><a href="syntax/expr.html">expr:</a></b>
           95  +<button id='x1633' onclick='hideorshow("x1633","x1634")'>hide</button></p>
           96  + <div id='x1634' class='imgcontainer'>
           97  + <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
           98  +<p><b><a href="syntax/filter-clause.html">filter-clause:</a></b>
           99  +<button id='x1635' onclick='hideorshow("x1635","x1636")'>show</button></p>
          100  + <div id='x1636' style='display:none;' class='imgcontainer'>
          101  + <img alt="syntax diagram filter-clause" src="images/syntax/filter-clause.gif" />
          102  +</div>
          103  +<p><b><a href="syntax/literal-value.html">literal-value:</a></b>
          104  +<button id='x1637' onclick='hideorshow("x1637","x1638")'>show</button></p>
          105  + <div id='x1638' style='display:none;' class='imgcontainer'>
          106  + <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
          107  +</div>
          108  +<p><b><a href="syntax/over-clause.html">over-clause:</a></b>
          109  +<button id='x1639' onclick='hideorshow("x1639","x1640")'>show</button></p>
          110  + <div id='x1640' style='display:none;' class='imgcontainer'>
          111  + <img alt="syntax diagram over-clause" src="images/syntax/over-clause.gif" />
          112  +<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
          113  +<button id='x1641' onclick='hideorshow("x1641","x1642")'>show</button></p>
          114  + <div id='x1642' style='display:none;' class='imgcontainer'>
          115  + <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
          116  +</div>
          117  +<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
          118  +<button id='x1643' onclick='hideorshow("x1643","x1644")'>show</button></p>
          119  + <div id='x1644' style='display:none;' class='imgcontainer'>
          120  + <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
          121  +</div>
          122  +</div>
          123  +<p><b><a href="syntax/raise-function.html">raise-function:</a></b>
          124  +<button id='x1645' onclick='hideorshow("x1645","x1646")'>show</button></p>
          125  + <div id='x1646' style='display:none;' class='imgcontainer'>
          126  + <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
          127  +</div>
          128  +<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
          129  +<button id='x1647' onclick='hideorshow("x1647","x1648")'>show</button></p>
          130  + <div id='x1648' style='display:none;' class='imgcontainer'>
          131  + <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
          132  +<p><b><a href="syntax/common-table-expression.html">common-table-expression:</a></b>
          133  +<button id='x1649' onclick='hideorshow("x1649","x1650")'>show</button></p>
          134  + <div id='x1650' style='display:none;' class='imgcontainer'>
          135  + <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
          136  +</div>
          137  +<p><b><a href="syntax/compound-operator.html">compound-operator:</a></b>
          138  +<button id='x1651' onclick='hideorshow("x1651","x1652")'>show</button></p>
          139  + <div id='x1652' style='display:none;' class='imgcontainer'>
          140  + <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
          141  +</div>
          142  +<p><b><a href="syntax/join-clause.html">join-clause:</a></b>
          143  +<button id='x1653' onclick='hideorshow("x1653","x1654")'>show</button></p>
          144  + <div id='x1654' style='display:none;' class='imgcontainer'>
          145  + <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
          146  +<p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
          147  +<button id='x1655' onclick='hideorshow("x1655","x1656")'>show</button></p>
          148  + <div id='x1656' style='display:none;' class='imgcontainer'>
          149  + <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
          150  +</div>
          151  +<p><b><a href="syntax/join-operator.html">join-operator:</a></b>
          152  +<button id='x1657' onclick='hideorshow("x1657","x1658")'>show</button></p>
          153  + <div id='x1658' style='display:none;' class='imgcontainer'>
          154  + <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
          155  +</div>
          156  +</div>
          157  +<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
          158  +<button id='x1659' onclick='hideorshow("x1659","x1660")'>show</button></p>
          159  + <div id='x1660' style='display:none;' class='imgcontainer'>
          160  + <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
          161  +</div>
          162  +<p><b><a href="syntax/result-column.html">result-column:</a></b>
          163  +<button id='x1661' onclick='hideorshow("x1661","x1662")'>show</button></p>
          164  + <div id='x1662' style='display:none;' class='imgcontainer'>
          165  + <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
          166  +</div>
          167  +<p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
          168  +<button id='x1663' onclick='hideorshow("x1663","x1664")'>show</button></p>
          169  + <div id='x1664' style='display:none;' class='imgcontainer'>
          170  + <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
          171  +</div>
          172  +<p><b><a href="syntax/window-defn.html">window-defn:</a></b>
          173  +<button id='x1665' onclick='hideorshow("x1665","x1666")'>show</button></p>
          174  + <div id='x1666' style='display:none;' class='imgcontainer'>
          175  + <img alt="syntax diagram window-defn" src="images/syntax/window-defn.gif" />
          176  +<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
          177  +<button id='x1667' onclick='hideorshow("x1667","x1668")'>show</button></p>
          178  + <div id='x1668' style='display:none;' class='imgcontainer'>
          179  + <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
          180  +</div>
          181  +</div>
          182  +</div>
          183  +<p><b><a href="syntax/type-name.html">type-name:</a></b>
          184  +<button id='x1669' onclick='hideorshow("x1669","x1670")'>show</button></p>
          185  + <div id='x1670' style='display:none;' class='imgcontainer'>
          186  + <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
          187  +<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
          188  +<button id='x1671' onclick='hideorshow("x1671","x1672")'>show</button></p>
          189  + <div id='x1672' style='display:none;' class='imgcontainer'>
          190  + <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
          191  +</div>
          192  +</div>
          193  +</div>
          194  +
          195  +
          196  +<p>This section is different from the others.  Most other sections of
          197  +this document talks about a particular SQL command.  This section does
          198  +not talk about a standalone command but about "expressions" which are 
          199  +subcomponents of most other commands.</p>
          200  +
          201  +<a name="binaryops"></a>
          202  +
          203  +<h3>Operators</h3>
          204  +<p>SQLite understands the following binary operators, in order from
          205  +highest to lowest precedence:</p>
          206  +
          207  +<blockquote><pre>
          208  +<font color="#2c2cf0"><big>||
          209  +*    /    %
          210  ++    -
          211  +&lt;&lt;   &gt;&gt;   &amp;    |
          212  +&lt;    &lt;=   &gt;    &gt;=
          213  +=    ==   !=   &lt;&gt;   </big>IS   IS NOT   IN   LIKE   GLOB   MATCH   REGEXP
          214  +AND   
          215  +OR</font>
          216  +</pre></blockquote>
          217  +
          218  +<p>Supported unary prefix operators are these:</p>
          219  +
          220  +<blockquote><pre>
          221  +<font color="#2c2cf0"><big>-    +    ~    NOT</big></font>
          222  +</pre></blockquote>
          223  +
          224  +<a name="collateop"></a>
          225  +
          226  +<p>The COLLATE operator is a unary postfix
          227  +operator that assigns a <a href="datatype3.html#collation">collating sequence</a> to an expression.
          228  +The COLLATE operator has a higher precedence (binds more tightly) than any
          229  +binary operator and any unary prefix operator except "~".
          230  +(COLLATE and "~" are associative so their binding order does not matter.)
          231  +The collating sequence set by the COLLATE operator overrides the
          232  +collating sequence determined by the COLLATE clause in a table
          233  +<a href="lang_createtable.html#tablecoldef">column definition</a>.
          234  +See the <a href="datatype3.html#collation">detailed discussion on collating sequences</a>
          235  +in the <a href="datatype3.html">Datatype In SQLite3</a> document for additional information.
          236  +</p>
          237  +
          238  +
          239  +<p>The unary operator <font color="#2c2cf0"><big>+</big></font> is a no-op.  It can be applied
          240  +to strings, numbers, blobs or NULL and it always returns a result
          241  +with the same value as the operand.</p>
          242  +
          243  +<p>Note that there are two variations of the equals and not equals
          244  +operators.  Equals can be either
          245  +
          246  +<font color="#2c2cf0"><big>=</big></font> or <font color="#2c2cf0"><big>==</big></font>.
          247  +The non-equals operator can be either
          248  +<font color="#2c2cf0"><big>!=</big></font> or <font color="#2c2cf0"><big>&lt;&gt;</big></font>.
          249  +The <font color="#2c2cf0"><big>||</big></font> operator is "concatenate" - it joins together
          250  +the two strings of its operands.
          251  +The operator <font color="#2c2cf0"><big>%</big></font> outputs the integer value of its left 
          252  +operand modulo its right operand.  In other words, the
          253  +operator <font color="#2c2cf0"><big>%</big></font> works in SQLite the same as it does
          254  +in ANSI-C.</p>
          255  +
          256  +<p>The result of any binary operator is either a numeric value or 
          257  +NULL, except for the <font color="#2c2cf0"><big>||</big></font> concatenation operator which always 
          258  +evaluates to either NULL or a text value.</p><a name="isisnot"></a>
          259  +<p>The <font color="#2c2cf0"><big>IS</big></font> and <font color="#2c2cf0"><big>IS NOT</big></font> operators work
          260  +like <font color="#2c2cf0"><big>=</big></font> and <font color="#2c2cf0"><big>!=</big></font> except when one or both of the
          261  +operands are NULL. In this case, if both operands are NULL, then the
          262  +IS operator evaluates to 1 (true) and the IS NOT operator evaluates
          263  +to 0 (false). If one operand is NULL and the other is not, then the
          264  +IS operator evaluates to 0 (false) and the IS NOT operator is 1 (true).
          265  +It is not possible for an IS or IS NOT expression to evaluate to NULL.
          266  +Operators <font color="#2c2cf0"><big>IS</big></font> and <font color="#2c2cf0"><big>IS NOT</big></font> have the same 
          267  +precedence as <font color="#2c2cf0"><big>=</big></font>.<a name="litvalue"></a>
          268  +
          269  +<h3>Literal Values (Constants)</h3>
          270  +<p>
          271  +A literal value represents a constant.
          272  +Literal values may be integers, floating point numbers, strings,
          273  +BLOBs, or NULLs.
          274  +<p>
          275  +The syntax for integer and floating point literals (collectively
          276  +"numeric literals") is shown by the following diagram:</p>
          277  +
          278  +<p><b><a href="syntax/numeric-literal.html">numeric-literal:</a></b></p><div class='imgcontainer'>
          279  + <img alt="syntax diagram numeric-literal" src="images/syntax/numeric-literal.gif"></img>
          280  + </div>
          281  +
          282  +
          283  +<p>
          284  +If a numeric literal has a decimal point or an exponentiation
          285  +clause or if its magnitude is less than -9223372036854775808 or
          286  +greater than 9223372036854775807, then it is a floating point literal.
          287  +Otherwise is it is an  integer literal.
          288  +The "E" character that begins the exponentiation
          289  +clause of a floating point literal can be either upper or lower case.
          290  +The "." character is always used 
          291  +as the decimal point even if the locale setting specifies "," for
          292  +this role - the use of "," for the decimal point would result in
          293  +syntactic ambiguity.
          294  +
          295  +<a name="hexint"></a>
          296  +
          297  +<p>Hexadecimal integer literals follow the C-language notation of
          298  +"0x" or "0X" followed by hexadecimal digits.
          299  +For example, 0x1234 means the same as 4660
          300  +and 0x8000000000000000 means the same as -9223372036854775808.
          301  + Hexadecimal integer literals are interpreted as 64-bit
          302  +two's-complement integers and are thus limited
          303  +to sixteen significant digits of precision.
          304  +Support for hexadecimal integers was added to SQLite
          305  +version 3.8.6 (2014-08-15).
          306  +For backwards compatibility, the "0x" hexadecimal integer
          307  +notation is only understood by the SQL language parser, not by the
          308  +type conversions routines.
          309  +String variables that
          310  +contain text formatted like hexadecimal integers are not
          311  +interpreted as hexadecimal integers when coercing the string value
          312  +into an integer due to a <a href="lang_expr.html#castexpr">CAST expression</a> or for a <a href="datatype3.html#affinity">column affinity</a>
          313  +transformation or prior to performing a numeric operation or for
          314  +any other run-time conversions.  When coercing a
          315  +string value in the format of a hexadecimal integer into an integer
          316  +value, the conversion process stops when the 'x' character is seen
          317  +so the resulting integer value is always zero.
          318  +SQLite only understands the hexadecimal integer notation when it
          319  +appears in the SQL statement text, not when it appears as
          320  +part of the content of the database.
          321  +
          322  +<p> A string constant is formed by enclosing the
          323  +string in single quotes (').  A single quote within the string can
          324  +be encoded by putting two single quotes in a row - as in Pascal.
          325  +C-style escapes using the backslash character are not supported because
          326  +they are not standard SQL.
          327  +
          328  +<p> BLOB literals are string literals containing hexadecimal data and
          329  +preceded by a single "x" or "X" character.  Example: X'53514C697465'
          330  +
          331  +<p>
          332  +A literal value can also be the token "NULL".
          333  +</p>
          334  +
          335  +<a name="varparam"></a>
          336  +
          337  +<h3>Parameters</h3>
          338  +<p>
          339  +A "variable" or "parameter" token
          340  +specifies a placeholder in the expression for a 
          341  +value that is filled in at runtime using the
          342  +<a href="c3ref/bind_blob.html">sqlite3_bind()</a> family of C/C++ interfaces.
          343  +Parameters can take several forms:
          344  +</p>
          345  +
          346  +<blockquote>
          347  +<table>
          348  +<tr>
          349  +<td align="right" valign="top"><b>?</b><i>NNN</i></td><td width="20"></td>
          350  +<td>A question mark followed by a number <i>NNN</i> holds a spot for the
          351  +NNN-th parameter.  NNN must be between 1 and <a href="limits.html#max_variable_number">SQLITE_MAX_VARIABLE_NUMBER</a>.
          352  +</td>
          353  +</tr>
          354  +<tr>
          355  +<td align="right" valign="top"><b>?</b></td><td width="20"></td>
          356  +<td>A question mark that is not followed by a number creates a parameter
          357  +with a number one greater than the largest parameter number already assigned.
          358  +If this means the parameter number is greater than
          359  +<a href="limits.html#max_variable_number">SQLITE_MAX_VARIABLE_NUMBER</a>, it is an error.
          360  +This parameter format is provided for compatibility with other database
          361  +engines.  But because it is easy to miscount the question marks, the
          362  +use of this parameter format is discouraged.  Programmers are encouraged
          363  +to use one of the symbolic formats below or the ?NNN format above instead.
          364  +</td>
          365  +</tr>
          366  +<tr>
          367  +<td align="right" valign="top"><b>:</b><i>AAAA</i></td><td width="20"></td>
          368  +<td>A colon followed by an identifier name holds a spot for a 
          369  +<a href="c3ref/bind_parameter_name.html">named parameter</a> with the name :AAAA.  
          370  +Named parameters are also numbered. The number assigned is one greater than
          371  +the largest parameter number already assigned. If this means the parameter
          372  +would be assigned a number greater than <a href="limits.html#max_variable_number">SQLITE_MAX_VARIABLE_NUMBER</a>, it is
          373  +an error. To avoid confusion, it is best to avoid mixing named and numbered
          374  +parameters.</td>
          375  +</tr>
          376  +<tr>
          377  +<td align="right" valign="top"><b>@</b><i>AAAA</i></td><td width="20"></td>
          378  +<td>An "at" sign works exactly like a colon, except that the name of
          379  +the parameter created is @AAAA.</td>
          380  +</tr>
          381  +<tr>
          382  +<td align="right" valign="top"><b>$</b><i>AAAA</i></td><td width="20"></td>
          383  +<td>A dollar-sign followed by an identifier name also holds a spot for a named
          384  +parameter with the name $AAAA.  The identifier name in this case can include
          385  +one or more occurrences of "::" and a suffix enclosed in "(...)" containing
          386  +any text at all.  This syntax is the form of a variable name in the
          387  +<a href="http://www.tcl-lang.org/">Tcl programming language</a>.  The presence
          388  +of this syntax results from the fact that SQLite is really a 
          389  +<a href="tclsqlite.html">Tcl extension</a> that has escaped into the wild.</td>
          390  +</tr>
          391  +</table>
          392  +</blockquote>
          393  +
          394  +<p>Parameters that are not assigned values using
          395  +<a href="c3ref/bind_blob.html">sqlite3_bind()</a> are treated
          396  +as NULL.  The <a href="c3ref/bind_parameter_index.html">sqlite3_bind_parameter_index()</a> interface can be used
          397  +to translate a symbolic parameter name into its equivalent numeric index.</p>
          398  +
          399  +<p>The maximum parameter number is set at compile-time by
          400  +the <a href="limits.html#max_variable_number">SQLITE_MAX_VARIABLE_NUMBER</a> macro.  An individual <a href="c3ref/sqlite3.html">database connection</a>
          401  +D can reduce its maximum parameter number below the compile-time maximum
          402  +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.
          403  +</p>
          404  +
          405  +<a name="like"></a>
          406  +
          407  +<h3>The LIKE, GLOB, REGEXP, and MATCH operators</h3>
          408  +<p>The LIKE operator does a pattern matching comparison. The operand
          409  +to the right of the LIKE operator contains the pattern and the left hand
          410  +operand contains the string to match against the pattern.
          411  +
          412  +A percent symbol ("%") in the LIKE pattern matches any
          413  +sequence of zero or more characters in the string.  An underscore
          414  +("_") in the LIKE pattern matches any single character in the
          415  +string.  Any other character matches itself or its lower/upper case
          416  +equivalent (i.e. case-insensitive matching).
          417  +
          418  +<u>Important Note:</u> SQLite only
          419  +understands upper/lower case for ASCII characters by default.  The
          420  +LIKE operator is case sensitive by default for unicode characters that are
          421  +beyond the ASCII range.  For example,
          422  +the expression <b>'a'&nbsp;LIKE&nbsp;'A'</b>
          423  +is TRUE but <b>'&aelig;'&nbsp;LIKE&nbsp;'&AElig;'</b> is FALSE.
          424  +The ICU extension to SQLite includes an enhanced version of the
          425  +LIKE operator that does case folding across all unicode characters.</p>
          426  +
          427  +<p>If the optional ESCAPE clause is present, then the expression
          428  +following the ESCAPE keyword must evaluate to a string consisting of
          429  +a single character. This character may be used in the LIKE pattern
          430  +to include literal percent or underscore characters. The escape
          431  +character followed by a percent symbol (%), underscore (_), or a second
          432  +instance of the escape character itself matches a
          433  +literal percent symbol, underscore, or a single escape character,
          434  +respectively.
          435  +
          436  +<p>The infix LIKE operator is implemented by calling the
          437  +application-defined SQL functions <a href="lang_corefunc.html#like">like(<i>Y</i>,<i>X</i>)</a> or
          438  +<a href="lang_corefunc.html#like">like(<i>Y</i>,<i>X</i>,<i>Z</i>)</a></a>.</p>
          439  +
          440  +<p>The LIKE operator can be made case sensitive using the
          441  +<a href="pragma.html#pragma_case_sensitive_like">case_sensitive_like pragma</a>.</p>
          442  +
          443  +<a name="glob"></a>
          444  +
          445  +<p>The GLOB operator is similar to LIKE but uses the Unix
          446  +file globbing syntax for its wildcards.  Also, GLOB is case
          447  +sensitive, unlike LIKE.  Both GLOB and LIKE may be preceded by
          448  +the NOT keyword to invert the sense of the test.  The infix GLOB 
          449  +operator is implemented by calling the function
          450  +<a href="lang_corefunc.html#glob">glob(<i>Y</i>,<i>X</i>)</a> and can be modified by overriding
          451  +that function.</p>
          452  +
          453  +<a name="regexp"></a>
          454  +
          455  +<p>The REGEXP operator is a special syntax for the regexp()
          456  +user function.  No regexp() user function is defined by default
          457  +and so use of the REGEXP operator will normally result in an
          458  +error message.  If an <a href="c3ref/create_function.html">application-defined SQL function</a> named "regexp"
          459  +is added at run-time, then the "<i>X</i> REGEXP <i>Y</i>" operator will
          460  +be implemented as a call to "regexp(<i>Y</i>,<i>X</i>)".</p>
          461  +
          462  +<a name="match"></a>
          463  +
          464  +<p>The MATCH operator is a special syntax for the match()
          465  +application-defined function.  The default match() function implementation
          466  +raises an exception and is not really useful for anything.
          467  +But extensions can override the match() function with more
          468  +helpful logic.</p>
          469  +
          470  +<a name="between"></a>
          471  +
          472  +<h3>The BETWEEN operator</h3>
          473  +<p>The BETWEEN operator is logically equivalent to a pair of comparisons.
          474  +"<i>x</i> <b>BETWEEN</b> <i>y</i> <b>AND</b> <i>z</i>" is 
          475  +equivalent to 
          476  +"<i>x</i><b>&gt;=</b><i>y</i> <b>AND</b> <i>x</i><b>&lt;=</b><i>z</i>" except
          477  +that with BETWEEN, the <i>x</i> expression is only evaluated once.
          478  +The precedence of the BETWEEN operator is the same as the precedence
          479  +as operators <b>==</b> and <b>!=</b> and <b>LIKE</b> and groups left to right.
          480  +
          481  +<a name="case"></a>
          482  +
          483  +<h3>The CASE expression</h3>
          484  +<p>A CASE expression serves a role similar to IF-THEN-ELSE in other
          485  +programming languages.  
          486  +
          487  +<p>The optional expression that occurs in between the CASE keyword and the
          488  +first WHEN keyword is called the "base" expression. There are two basic forms
          489  +of the CASE expression: those with a base expression and those without.
          490  +
          491  +<p>In a CASE without a base expression, each WHEN expression is evaluated
          492  +and the result treated as a boolean, starting with the leftmost and continuing
          493  +to the right. The result of the CASE expression is the evaluation of the THEN
          494  +expression that corresponds to the first WHEN expression that evaluates to
          495  +true. Or, if none of the WHEN expressions evaluate to true, the result of
          496  +evaluating the ELSE expression, if any. If there is no ELSE expression and
          497  +none of the WHEN expressions are true, then the overall result is NULL.
          498  +
          499  +<p>A NULL result is considered untrue when evaluating WHEN terms.
          500  +
          501  +<p>In a CASE with a base expression, the base expression is evaluated just
          502  +once and the result is compared against the evaluation of each WHEN 
          503  +expression from left to right. The result of the CASE expression is the 
          504  +evaluation of the THEN expression that corresponds to the first WHEN
          505  +expression for which the comparison is true. Or, if none of the WHEN
          506  +expressions evaluate to a value equal to the base expression, the result
          507  +of evaluating the ELSE expression, if any. If there is no ELSE expression and
          508  +none of the WHEN expressions produce a result equal to the base expression,
          509  +the overall result is NULL.
          510  +
          511  +<p>When comparing a base expression against a WHEN expression, the same
          512  +collating sequence, affinity, and NULL-handling rules apply as if the
          513  +base expression and WHEN expression are respectively the left- and
          514  +right-hand operands of an <big><b>=</b></big> operator.</p> If the base 
          515  +expression is NULL then the result of the CASE is always the result 
          516  +of evaluating the ELSE expression if it exists, or NULL if it does not.
          517  +
          518  +<p>Both forms of the CASE expression use lazy, or short-circuit, 
          519  +evaluation.
          520  +
          521  +<p>The only difference between the following two CASE expressions is that 
          522  +the <i>x</i> expression is evaluated exactly once in the first example but 
          523  +might be evaluated multiple times in the second:
          524  +
          525  +<ul><pre>
          526  +<li>CASE x WHEN w1 THEN r1 WHEN w2 THEN r2 ELSE r3 END
          527  +<li>CASE WHEN x=w1 THEN r1 WHEN x=w2 THEN r2 ELSE r3 END
          528  +</pre></ul>
          529  +
          530  +
          531  +<a name="in_op"></a>
          532  +
          533  +<h3>The IN and NOT IN operators</h3>
          534  +<p>The IN and NOT IN operators take an expression on the
          535  +left and a list of values or a subquery on the right.
          536  +When the right operand of an IN or NOT IN operator is a subquery, the
          537  +subquery must have the same number of columns as there are columns in
          538  +the <a href="rowvalue.html">row value</a> of the left operand.  The subquery on the
          539  +right of an IN or NOT IN operator must be a scalar subquery if the left
          540  +expression is not a <a href="rowvalue.html">row value</a> expression.
          541  +If the right operand of an IN or NOT IN operator is a list of values,
          542  +each of those values must be scalars and the left expression must also
          543  +be a scalar.
          544  +The right-hand side of an IN or NOT IN operator can be a
          545  +table <i>name</i> or <a href="vtab.html#tabfunc2">table-valued function</a> <i>name</i> in which 
          546  +case the right-hand side is understood to be subquery of
          547  +the form "(SELECT * FROM <i>name</i>)".
          548  +When the right operand is an empty set, the result of IN is false and the
          549  +result of NOT IN is true, regardless of the left operand and even if the
          550  +left operand is NULL.
          551  +<p>The result of an IN or NOT IN operator is determined by the following
          552  +matrix:
          553  +
          554  +<center>
          555  +<table border=1>
          556  +<tr>
          557  +<th>Left operand <br>is NULL
          558  +<th>Right operand <br>contains NULL
          559  +<th>Right operand <br>is an empty set
          560  +<th>Left operand found <br>within right operand
          561  +<th>Result of <br>IN operator
          562  +<th>Result of <br>NOT IN operator
          563  +<tr>
          564  +<td align="center">no
          565  +<td align="center">no
          566  +<td align="center">no
          567  +<td align="center">no
          568  +<td align="center">false
          569  +<td align="center">true
          570  +<tr>
          571  +<td align="center">does not matter
          572  +<td align="center">no
          573  +<td align="center">yes
          574  +<td align="center">no
          575  +<td align="center">false
          576  +<td align="center">true
          577  +<tr>
          578  +<td align="center">no
          579  +<td align="center">does not matter
          580  +<td align="center">no
          581  +<td align="center">yes
          582  +<td align="center">true
          583  +<td align="center">false
          584  +<tr>
          585  +<td align="center">no
          586  +<td align="center">yes
          587  +<td align="center">no
          588  +<td align="center">no
          589  +<td align="center">NULL
          590  +<td align="center">NULL
          591  +<tr>
          592  +<td align="center">yes
          593  +<td align="center">does not matter
          594  +<td align="center">no
          595  +<td align="center">does not matter
          596  +<td align="center">NULL
          597  +<td align="center">NULL
          598  +</table>
          599  +</center>
          600  +
          601  +<p>Note that SQLite allows the parenthesized list of scalar values on
          602  +the right-hand side of an IN or NOT IN operator to be an empty list but
          603  +most other SQL database database engines and the SQL92 standard require
          604  +the list to contain at least one element.</p>
          605  +
          606  +<h3>Table Column Names</h3>
          607  +
          608  +<p>A column name can be any of the names defined in the <a href="lang_createtable.html">CREATE TABLE</a>
          609  +statement or one of the following special identifiers: "<b>ROWID</b>",
          610  +"<b>OID</b>", or "<b>_ROWID_</b>".
          611  +The three special identifiers describe the
          612  +unique integer key (the <a href="lang_createtable.html#rowid">rowid</a>) associated with every 
          613  +row of every table and so are not available on <a href="withoutrowid.html">WITHOUT ROWID</a> tables.
          614  +The special identifiers only refer to the row key if the <a href="lang_createtable.html">CREATE TABLE</a>
          615  +statement does not define a real column with the same name.
          616  +The rowid can be used anywhere a regular
          617  +column can be used.</p>
          618  +
          619  +<a name="exists_op"></a>
          620  +
          621  +<h3>The EXISTS operator</h3>
          622  +
          623  +<p>The EXISTS operator always evaluates to one of the integer values 0 
          624  +and 1. If executing the SELECT statement specified as the right-hand 
          625  +operand of the EXISTS operator would return one or more rows, then the
          626  +EXISTS operator evaluates to 1. If executing the SELECT would return
          627  +no rows at all, then the EXISTS operator evaluates to 0. 
          628  +
          629  +<p>The number of columns in each row returned by the SELECT statement
          630  +(if any) and the specific values returned have no effect on the results
          631  +of the EXISTS operator. In particular, rows containing NULL values are
          632  +not handled any differently from rows without NULL values.
          633  +
          634  +<a name="subq"></a>
          635  +
          636  +<h3>Subquery Expressions</h3>
          637  +
          638  +<p>A <a href="lang_select.html">SELECT</a> statement enclosed in parentheses is a subquery.
          639  +All types of SELECT statement, including
          640  +aggregate and compound SELECT queries (queries with keywords like
          641  +UNION or EXCEPT) are allowed as scalar subqueries.
          642  +The value of a subquery expression is the first row of the result
          643  +from the enclosed <a href="lang_select.html">SELECT</a> statement.
          644  +The value of a subquery expression is NULL if the enclosed
          645  +<a href="lang_select.html">SELECT</a> statement returns no rows.
          646  +
          647  +<p>A subquery that returns a single column is a scalar subquery and can
          648  +be used most anywhere.
          649  +A subquery that returns two or more columns is a <a href="rowvalue.html">row value</a>
          650  +subquery and can only be used as the operand of a comparison operator.
          651  +
          652  +<a name="cosub"></a>
          653  +
          654  +<h3>Correlated Subqueries</h3>
          655  +
          656  +<p>A <a href="lang_select.html">SELECT</a> statement used as either a scalar subquery or as the 
          657  +right-hand operand of an IN, NOT IN or EXISTS expression may contain 
          658  +references to columns in the outer query. Such a subquery is known as
          659  +a correlated subquery. A correlated subquery is reevaluated each time
          660  +its result is required. An uncorrelated subquery is evaluated only once
          661  +and the result reused as necessary.
          662  +
          663  +<a name="castexpr"></a>
          664  +
          665  +<h3>CAST expressions</h3>
          666  +
          667  +<p>A CAST expression of the form "CAST(<i>expr</i> AS <i>type-name</i>)"
          668  +is used to convert the value of <i>expr</i> to 
          669  +a different <a href="datatype3.html#storageclasses">storage class</a> specified by <span class='yyterm'>type-name</span>.
          670  +A CAST conversion is similar to the conversion that takes
          671  +place when a <a href="datatype3.html#affinity">column affinity</a> is applied to a value except that with
          672  +the CAST operator the conversion always takes place even if the conversion
          673  +lossy and irreversible, whereas column affinity only changes the data type
          674  +of a value if the change is lossless and reversible.
          675  +
          676  +<p>If the value of <i>expr</i> is NULL, then the result of the CAST
          677  +expression is also NULL. Otherwise, the storage class of the result
          678  +is determined by applying the <a href="datatype3.html#affname">rules for determining column affinity</a> to
          679  +the <span class='yyterm'>type-name</span>.
          680  +
          681  +<table border=1>
          682  +<tr>
          683  +  <th> Affinity of <span class='yyterm'><nobr>type-name</nobr></span>
          684  +  <th> Conversion Processing
          685  +<tr>
          686  +  <td> NONE 
          687  +  <td> Casting a value to a <span class='yyterm'>type-name</span> with no affinity 
          688  +  causes the value to
          689  +  be converted into a BLOB.  Casting to a BLOB consists of first casting
          690  +  the value to TEXT in the <a href="pragma.html#pragma_encoding">encoding</a> of the database connection, then
          691  +  interpreting the resulting byte sequence as a BLOB instead of as TEXT.
          692  +
          693  +<tr>
          694  +  <td> TEXT
          695  +  <td> To cast a BLOB value to TEXT, the sequence of bytes that make up the
          696  +  BLOB is interpreted as text encoded using the database encoding.
          697  +  <p>
          698  +   Casting an INTEGER or REAL value into TEXT renders the value as if via 
          699  +    <a href="c3ref/mprintf.html">sqlite3_snprintf()</a> except that the resulting TEXT uses the <a href="pragma.html#pragma_encoding">encoding</a> of
          700  +    the database connection.
          701  +
          702  +<tr>
          703  +  <td> REAL
          704  +  <td> When casting a BLOB value to a REAL, the value is first converted to
          705  +        TEXT.
          706  +       <p>When casting a TEXT value to REAL, the longest possible prefix of
          707  +        the value that can be interpreted as a real number is extracted from
          708  +        the TEXT value and the remainder ignored. Any leading spaces in the
          709  +        TEXT value are ignored when converging from TEXT to REAL. If there is
          710  +        no prefix that can be interpreted as a real number, the result of the
          711  +        conversion is 0.0.
          712  +
          713  +<tr>
          714  +  <td> INTEGER
          715  +  <td> When casting a BLOB value to INTEGER, the value is first converted to
          716  +        TEXT.
          717  +       <p>When casting a TEXT value to INTEGER, the longest possible prefix of
          718  +        the value that can be interpreted as an integer number is extracted from
          719  +        the TEXT value and the remainder ignored. Any leading spaces in the
          720  +        TEXT value when converting from TEXT to INTEGER are ignored. If there
          721  +        is no prefix that can be interpreted as an integer number, the result
          722  +        of the conversion is 0.  If the prefix integer is greater than
          723  +        +9223372036854775807 then the result of the cast is exactly
          724  +        +9223372036854775807.  Similarly, if the prefix integer is
          725  +        less than -9223372036854775808 then the result of the cast is
          726  +        exactly -9223372036854775808.
          727  +
          728  +        <p>When casting to INTEGER, if the text looks like a floating point
          729  +        value with an exponent, the exponent will be ignored because it is
          730  +        no part of the integer prefix.  For example,
          731  +        "(CAST '123e+5' AS INTEGER)" results in 123, not in 12300000.
          732  +
          733  +        <p> The CAST operator understands decimal
          734  +        integers only &mdash; conversion of <a href="lang_expr.html#hexint">hexadecimal integers</a> stops 
          735  +        at the "x" in the "0x" prefix of the hexadecimal integer string 
          736  +        and thus result of the CAST is always zero.
          737  +
          738  +      <p>A cast of a REAL value into an INTEGER results in the integer
          739  +      between the REAL value and zero that is closest to the REAL value.
          740  +      If a REAL is greater than the greatest possible signed
          741  +      integer (+9223372036854775807) then the result is the greatest possible
          742  +      signed integer and if the REAL is less than the least possible signed
          743  +      integer (-9223372036854775808) then the result is the least possible
          744  +      signed integer.
          745  +
          746  +      <p>Prior to SQLite version 3.8.2 (2013-12-06),
          747  +      casting a REAL value greater than
          748  +      +9223372036854775807.0 into an integer resulted in the most negative
          749  +      integer, -9223372036854775808.  This behavior was meant to emulate the
          750  +      behavior of x86/x64 hardware when doing the equivalent cast.
          751  +
          752  +<tr>
          753  +  <td> NUMERIC
          754  +  <td> Casting a TEXT or BLOB value into NUMERIC yields either an INTEGER or
          755  +   a REAL result.
          756  +   If the input text looks like an integer (there is no decimal point nor
          757  +   exponent) and the value is small enough to fit in a 64-bit signed integer,
          758  +   then the result will be INTEGER.
          759  +   Input text that looks like floating point (there is a decimal point and/or
          760  +   an exponent) and the text describes a value that 
          761  +   can be losslessly converted back and forth between IEEE 754 64-bit float and a
          762  +   51-bit signed integer, then the result is INTEGER.
          763  +   (In the previous sentence, a 51-bit integer is specified since that is one
          764  +   bit less than the length of the mantissa of an IEEE 754 64-bit float and
          765  +   thus provides a 1-bit of margin for the text-to-float conversion operation.)
          766  +   Any text input that describes a value outside the range of a 64-bit
          767  +   signed integer yields a REAL result.
          768  +   <p> Casting a REAL or INTEGER value to NUMERIC is a no-op, even if a real
          769  +   value could be losslessly converted to an integer.
          770  +
          771  +</tr>
          772  +
          773  +</table>
          774  +
          775  +<p>Note that the result from casting any non-BLOB value into a 
          776  +BLOB and the result from casting any BLOB value into a non-BLOB value
          777  +may be different depending on whether the database <a href="pragma.html#pragma_encoding">encoding</a> is UTF-8,
          778  +UTF-16be, or UTF-16le.
          779  +
          780  +
          781  +<a name="booleanexpr"></a>
          782  +
          783  +<h3>Boolean Expressions</h3>
          784  +
          785  +<p>The SQL language features several contexts where an expression is 
          786  +evaluated and the result converted to a boolean (true or false) value. These
          787  +contexts are:
          788  +
          789  +  <ul>
          790  +    <li> the WHERE clause of a SELECT, UPDATE or DELETE statement,
          791  +    <li> the ON or USING clause of a join in a SELECT statement,
          792  +    <li> the HAVING clause of a SELECT statement,
          793  +    <li> the WHEN clause of an SQL trigger, and
          794  +    <li> the WHEN clause or clauses of some CASE expressions.
          795  +  </ul>
          796  +
          797  +<p>To convert the results of an SQL expression to a boolean value, SQLite
          798  +first casts the result to a NUMERIC value in the same way as a 
          799  +<a href="lang_expr.html#castexpr">CAST expression</a>. A numeric zero value (integer value 0 or real 
          800  +value 0.0) is considered to be false.  A NULL value is still NULL.
          801  +All other values are considered true.
          802  +
          803  +<p>For example, the values NULL, 0.0, 0, 'english' and '0' are all considered
          804  +to be false. Values 1, 1.0, 0.1, -0.1 and '1english' are considered to 
          805  +be true.
          806  +
          807  +<p>Beginning with SQLite 3.23.0 (2018-04-02), SQLite recognizes the
          808  +identifiers "TRUE" and "FALSE" as boolean literals, if and only if those
          809  +identifiers are not already used for some other meaning.  If there already
          810  +exists columns or tables or other objects named TRUE or FALSE, then for
          811  +the sake of backwards compatibility, the TRUE and FALSE identifiers refer
          812  +to those other objects, not to the boolean values.
          813  +
          814  +<p>The boolean identifiers TRUE and FALSE are usually just aliases for
          815  +the integer values 1 and 0, respectively.  However, if TRUE or FALSE
          816  +occur on the right-hand side of an IS operator, then they form new
          817  +unary postfix operators "IS TRUE" and "IS FALSE" which test the boolean
          818  +value of the operand on the left.
          819  +
          820  +<h3>Functions</h3>
          821  +<p>SQLite supports many <a href="lang_corefunc.html">simple</a>, <a href="lang_aggfunc.html">aggregate</a>,
          822  +and <a href="windowfunctions.html">window</a>
          823  +SQL functions.  For presentation purposes, simple functions are further
          824  +subdivided into <a href="lang_corefunc.html">core functions</a>, <a href="lang_datefunc.html">date-time functions</a>,
          825  +and <a href="json1.html">JSON functions</a>.
          826  +Applications can add new functions, written in C/C++, using the
          827  +<a href="c3ref/create_function.html">sqlite3_create_function()</a> interface.
          828  +</p>
          829  +
          830  +<p>
          831  +The main expression bubble diagram above shows a single syntax for
          832  +all function invocations.  But this is merely to simplify the expression
          833  +bubble diagram.  In reality, each type of function has a slightly different
          834  +syntax, shown below.  The function invocation syntax shown in the main
          835  +expression bubble diagram is the union of the three syntaxes shown here:
          836  +
          837  +<p><b><a href="syntax/simple-function-invocation.html">simple-function-invocation:</a></b></p><div class='imgcontainer'>
          838  + <img alt="syntax diagram simple-function-invocation" src="images/syntax/simple-function-invocation.gif"></img>
          839  + </div>
          840  +<p><b><a href="syntax/aggregate-function-invocation.html">aggregate-function-invocation:</a></b></p><div class='imgcontainer'>
          841  + <img alt="syntax diagram aggregate-function-invocation" src="images/syntax/aggregate-function-invocation.gif"></img>
          842  + </div>
          843  +<p><b><a href="syntax/window-function-invocation.html">window-function-invocation:</a></b></p><div class='imgcontainer'>
          844  + <img alt="syntax diagram window-function-invocation" src="images/syntax/window-function-invocation.gif"></img>
          845  + </div>
          846  +
          847  +
          848  +<p>
          849  +The OVER clause is required for <a href="windowfunctions.html">window functions</a> and is prohibited
          850  +otherwise.  The DISTINCT keyword is only allowed in <a href="lang_aggfunc.html">aggregate functions</a>.
          851  +The FILTER clause may not appear on a <a href="lang_corefunc.html">simple function</a>.
          852  +
          853  +<p>It is possible to have an aggregate function with the same name as a
          854  +simple function, as long as the number of arguments for the two forms of the
          855  +function are different.  For example, the <a href="lang_aggfunc.html#maxggunc">max()</a> function with a
          856  +single argument is an aggregate and the <a href="lang_corefunc.html#maxoreunc">max()</a> function with two or more
          857  +arguments is a simple function.  Aggregate functions can usually also
          858  +be used as window functions.
          859  +
          860  +

Added Doc/Extra/Core/lang_indexedby.html.

            1  +<!DOCTYPE html>
            2  +<html><head>
            3  +<meta name="viewport" content="width=device-width, initial-scale=1.0">
            4  +<meta http-equiv="content-type" content="text/html; charset=UTF-8">
            5  +<link href="sqlite.css" rel="stylesheet">
            6  +<title>SQLite Query Language: INDEXED BY</title>
            7  +<!-- path= -->
            8  +</head>
            9  +<body>
           10  +<div class=nosearch>
           11  +<a href="index.html">
           12  +<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
           13  +</a>
           14  +<div><!-- IE hack to prevent disappearing logo --></div>
           15  +<div class="tagline desktoponly">
           16  +Small. Fast. Reliable.<br>Choose any three.
           17  +</div>
           18  +<div class="menu mainmenu">
           19  +<ul>
           20  +<li><a href="index.html">Home</a>
           21  +<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
           22  +<li class='wideonly'><a href='about.html'>About</a>
           23  +<li class='desktoponly'><a href="docs.html">Documentation</a>
           24  +<li class='desktoponly'><a href="download.html">Download</a>
           25  +<li class='wideonly'><a href='copyright.html'>License</a>
           26  +<li class='desktoponly'><a href="support.html">Support</a>
           27  +<li class='desktoponly'><a href="prosupport.html">Purchase</a>
           28  +<li class='search' id='search_menubutton'>
           29  +<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
           30  +</ul>
           31  +</div>
           32  +<div class="menu submenu" id="submenu">
           33  +<ul>
           34  +<li><a href='about.html'>About</a>
           35  +<li><a href='docs.html'>Documentation</a>
           36  +<li><a href='download.html'>Download</a>
           37  +<li><a href='support.html'>Support</a>
           38  +<li><a href='prosupport.html'>Purchase</a>
           39  +</ul>
           40  +</div>
           41  +<div class="searchmenu" id="searchmenu">
           42  +<form method="GET" action="search">
           43  +<select name="s" id="searchtype">
           44  +<option value="d">Search Documentation</option>
           45  +<option value="c">Search Changelog</option>
           46  +</select>
           47  +<input type="text" name="q" id="searchbox" value="">
           48  +<input type="submit" value="Go">
           49  +</form>
           50  +</div>
           51  +</div>
           52  +<script>
           53  +function toggle_div(nm) {
           54  +var w = document.getElementById(nm);
           55  +if( w.style.display=="block" ){
           56  +w.style.display = "none";
           57  +}else{
           58  +w.style.display = "block";
           59  +}
           60  +}
           61  +function toggle_search() {
           62  +var w = document.getElementById("searchmenu");
           63  +if( w.style.display=="block" ){
           64  +w.style.display = "none";
           65  +} else {
           66  +w.style.display = "block";
           67  +setTimeout(function(){
           68  +document.getElementById("searchbox").focus()
           69  +}, 30);
           70  +}
           71  +}
           72  +function div_off(nm){document.getElementById(nm).style.display="none";}
           73  +window.onbeforeunload = function(e){div_off("submenu");}
           74  +/* Disable the Search feature if we are not operating from CGI, since */
           75  +/* Search is accomplished using CGI and will not work without it. */
           76  +if( !location.origin.match || !location.origin.match(/http/) ){
           77  +document.getElementById("search_menubutton").style.display = "none";
           78  +}
           79  +/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
           80  +function hideorshow(btn,obj){
           81  +var x = document.getElementById(obj);
           82  +var b = document.getElementById(btn);
           83  +if( x.style.display!='none' ){
           84  +x.style.display = 'none';
           85  +b.innerHTML='show';
           86  +}else{
           87  +x.style.display = '';
           88  +b.innerHTML='hide';
           89  +}
           90  +return false;
           91  +}
           92  +</script>
           93  +</div>
           94  +<div class=nosearch><h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>INDEXED BY</h2></div>
           95  +<p>The INDEXED BY phrase forces the <a href="optoverview.html">SQLite query planner</a> to use a
           96  +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.
           97  +The INDEXED BY phrase is an SQLite extension and
           98  +is not portable to other SQL database engines.</p>
           99  +
          100  +<p><b><a href="syntax/qualified-table-name.html">qualified-table-name:</a></b>
          101  +<button id='x2205' onclick='hideorshow("x2205","x2206")'>hide</button></p>
          102  + <div id='x2206' class='imgcontainer'>
          103  + <img alt="syntax diagram qualified-table-name" src="images/syntax/qualified-table-name.gif" />
          104  +</div>
          105  +
          106  +
          107  +<p>The "INDEXED BY <span class='yyterm'>index-name</span>" phrase specifies 
          108  +that the named index
          109  +must be used in order to look up values on the preceding table.
          110  +If <span class='yyterm'>index-name</span> does not exist or cannot be used 
          111  +for the query, then the preparation of the SQL statement fails.
          112  +The "NOT INDEXED" clause specifies that no index shall be used when
          113  +accessing the preceding table, including implied indices create by
          114  +UNIQUE and PRIMARY KEY constraints.  However, the <a href="lang_createtable.html#rowid">rowid</a>
          115  +can still be used to look up entries even when "NOT INDEXED" is specified.</p>
          116  +
          117  +<p>Some SQL database engines provide non-standard "hint" mechanisms which
          118  +can be used to give the query optimizer clues about what indices it should
          119  +use for a particular statement.  The INDEX BY clause of SQLite is 
          120  +<em>not</em> a hinting mechanism and it should not be used as such.
          121  +The INDEXED BY clause does not give the optimizer hints about which index
          122  +to use; it gives the optimizer a requirement of which index to use.
          123  +If the query optimizer is unable to use the index specified by the
          124  +INDEX BY clause, then the query will fail with an error.</p>
          125  +
          126  +<p>The INDEXED BY clause is <em>not</em> intended for use in tuning
          127  +the performance of a query.  The intent of the INDEXED BY clause is
          128  +to raise a run-time error if a schema change, such as dropping or
          129  +creating an index, causes the query plan for a time-sensitive query
          130  +to change.  The INDEXED BY clause is designed to help detect
          131  +undesirable query plan changes during regression testing.
          132  +Application 
          133  +developers are admonished to omit all use of INDEXED BY during
          134  +application design, implementation, testing, and tuning.  If
          135  +INDEXED BY is to be used at all, it should be inserted at the very
          136  +end of the development process when "locking down" a design.</p>
          137  +
          138  +<h3>See Also:</h3>
          139  +
          140  +<ol>
          141  +<li><p>The <a href="queryplanner-ng.html#howtofix">query planner checklist</a> describes steps that application
          142  +developers should following to help resolve query planner problems.
          143  +Notice the that the use of INDEXED BY is a last resort, to be used only
          144  +when all other measures fail.</p>
          145  +
          146  +<li><p><a href="optoverview.html#uplus">The unary "+" operator</a>
          147  +can be used to disqualify terms in the WHERE clause from use by indices.
          148  +Careful use of unary + can sometimes help prevent the query planner from
          149  +choosing a poor index without restricting it to using one specific index.
          150  +Careful placement of unary + operators is a better method for controlling 
          151  +which indices are used by a query.</p>
          152  +
          153  +<li><p>The <a href="c3ref/stmt_status.html">sqlite3_stmt_status()</a> C/C++ interface together with the
          154  +<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
          155  +can be used to detect at run-time when an SQL statement is not
          156  +making effective use of indices.  Many applications may prefer to
          157  +use the <a href="c3ref/stmt_status.html">sqlite3_stmt_status()</a> interface to detect index misuse
          158  +rather than the INDEXED BY phrase described here.</p>
          159  +</ol>
          160  +
          161  +<DIV class="pdf_section">

Added Doc/Extra/Core/lang_insert.html.

            1  +<!DOCTYPE html>
            2  +<html><head>
            3  +<meta name="viewport" content="width=device-width, initial-scale=1.0">
            4  +<meta http-equiv="content-type" content="text/html; charset=UTF-8">
            5  +<link href="sqlite.css" rel="stylesheet">
            6  +<title>SQLite Query Language: INSERT</title>
            7  +<!-- path= -->
            8  +</head>
            9  +<body>
           10  +<div class=nosearch>
           11  +<a href="index.html">
           12  +<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
           13  +</a>
           14  +<div><!-- IE hack to prevent disappearing logo --></div>
           15  +<div class="tagline desktoponly">
           16  +Small. Fast. Reliable.<br>Choose any three.
           17  +</div>
           18  +<div class="menu mainmenu">
           19  +<ul>
           20  +<li><a href="index.html">Home</a>
           21  +<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
           22  +<li class='wideonly'><a href='about.html'>About</a>
           23  +<li class='desktoponly'><a href="docs.html">Documentation</a>
           24  +<li class='desktoponly'><a href="download.html">Download</a>
           25  +<li class='wideonly'><a href='copyright.html'>License</a>
           26  +<li class='desktoponly'><a href="support.html">Support</a>
           27  +<li class='desktoponly'><a href="prosupport.html">Purchase</a>
           28  +<li class='search' id='search_menubutton'>
           29  +<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
           30  +</ul>
           31  +</div>
           32  +<div class="menu submenu" id="submenu">
           33  +<ul>
           34  +<li><a href='about.html'>About</a>
           35  +<li><a href='docs.html'>Documentation</a>
           36  +<li><a href='download.html'>Download</a>
           37  +<li><a href='support.html'>Support</a>
           38  +<li><a href='prosupport.html'>Purchase</a>
           39  +</ul>
           40  +</div>
           41  +<div class="searchmenu" id="searchmenu">
           42  +<form method="GET" action="search">
           43  +<select name="s" id="searchtype">
           44  +<option value="d">Search Documentation</option>
           45  +<option value="c">Search Changelog</option>
           46  +</select>
           47  +<input type="text" name="q" id="searchbox" value="">
           48  +<input type="submit" value="Go">
           49  +</form>
           50  +</div>
           51  +</div>
           52  +<script>
           53  +function toggle_div(nm) {
           54  +var w = document.getElementById(nm);
           55  +if( w.style.display=="block" ){
           56  +w.style.display = "none";
           57  +}else{
           58  +w.style.display = "block";
           59  +}
           60  +}
           61  +function toggle_search() {
           62  +var w = document.getElementById("searchmenu");
           63  +if( w.style.display=="block" ){
           64  +w.style.display = "none";
           65  +} else {
           66  +w.style.display = "block";
           67  +setTimeout(function(){
           68  +document.getElementById("searchbox").focus()
           69  +}, 30);
           70  +}
           71  +}
           72  +function div_off(nm){document.getElementById(nm).style.display="none";}
           73  +window.onbeforeunload = function(e){div_off("submenu");}
           74  +/* Disable the Search feature if we are not operating from CGI, since */
           75  +/* Search is accomplished using CGI and will not work without it. */
           76  +if( !location.origin.match || !location.origin.match(/http/) ){
           77  +document.getElementById("search_menubutton").style.display = "none";
           78  +}
           79  +/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
           80  +function hideorshow(btn,obj){
           81  +var x = document.getElementById(obj);
           82  +var b = document.getElementById(btn);
           83  +if( x.style.display!='none' ){
           84  +x.style.display = 'none';
           85  +b.innerHTML='show';
           86  +}else{
           87  +x.style.display = '';
           88  +b.innerHTML='hide';
           89  +}
           90  +return false;
           91  +}
           92  +</script>
           93  +</div>
           94  +<div class=nosearch><h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>INSERT</h2></div><p><b><a href="syntax/insert-stmt.html">insert-stmt:</a></b>
           95  +<button id='x1715' onclick='hideorshow("x1715","x1716")'>hide</button></p>
           96  + <div id='x1716' class='imgcontainer'>
           97  + <img alt="syntax diagram insert-stmt" src="images/syntax/insert-stmt.gif" />
           98  +<p><b><a href="syntax/expr.html">expr:</a></b>
           99  +<button id='x1717' onclick='hideorshow("x1717","x1718")'>show</button></p>
          100  + <div id='x1718' style='display:none;' class='imgcontainer'>
          101  + <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
          102  +<p><b><a href="syntax/filter-clause.html">filter-clause:</a></b>
          103  +<button id='x1719' onclick='hideorshow("x1719","x1720")'>show</button></p>
          104  + <div id='x1720' style='display:none;' class='imgcontainer'>
          105  + <img alt="syntax diagram filter-clause" src="images/syntax/filter-clause.gif" />
          106  +</div>
          107  +<p><b><a href="syntax/literal-value.html">literal-value:</a></b>
          108  +<button id='x1721' onclick='hideorshow("x1721","x1722")'>show</button></p>
          109  + <div id='x1722' style='display:none;' class='imgcontainer'>
          110  + <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
          111  +</div>
          112  +<p><b><a href="syntax/over-clause.html">over-clause:</a></b>
          113  +<button id='x1723' onclick='hideorshow("x1723","x1724")'>show</button></p>
          114  + <div id='x1724' style='display:none;' class='imgcontainer'>
          115  + <img alt="syntax diagram over-clause" src="images/syntax/over-clause.gif" />
          116  +<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
          117  +<button id='x1725' onclick='hideorshow("x1725","x1726")'>show</button></p>
          118  + <div id='x1726' style='display:none;' class='imgcontainer'>
          119  + <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
          120  +</div>
          121  +<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
          122  +<button id='x1727' onclick='hideorshow("x1727","x1728")'>show</button></p>
          123  + <div id='x1728' style='display:none;' class='imgcontainer'>
          124  + <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
          125  +</div>
          126  +</div>
          127  +<p><b><a href="syntax/raise-function.html">raise-function:</a></b>
          128  +<button id='x1729' onclick='hideorshow("x1729","x1730")'>show</button></p>
          129  + <div id='x1730' style='display:none;' class='imgcontainer'>
          130  + <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
          131  +</div>
          132  +<p><b><a href="syntax/type-name.html">type-name:</a></b>
          133  +<button id='x1731' onclick='hideorshow("x1731","x1732")'>show</button></p>
          134  + <div id='x1732' style='display:none;' class='imgcontainer'>
          135  + <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
          136  +<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
          137  +<button id='x1733' onclick='hideorshow("x1733","x1734")'>show</button></p>
          138  + <div id='x1734' style='display:none;' class='imgcontainer'>
          139  + <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
          140  +</div>
          141  +</div>
          142  +</div>
          143  +<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
          144  +<button id='x1735' onclick='hideorshow("x1735","x1736")'>show</button></p>
          145  + <div id='x1736' style='display:none;' class='imgcontainer'>
          146  + <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
          147  +<p><b><a href="syntax/common-table-expression.html">common-table-expression:</a></b>
          148  +<button id='x1737' onclick='hideorshow("x1737","x1738")'>show</button></p>
          149  + <div id='x1738' style='display:none;' class='imgcontainer'>
          150  + <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
          151  +</div>
          152  +<p><b><a href="syntax/compound-operator.html">compound-operator:</a></b>
          153  +<button id='x1739' onclick='hideorshow("x1739","x1740")'>show</button></p>
          154  + <div id='x1740' style='display:none;' class='imgcontainer'>
          155  + <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
          156  +</div>
          157  +<p><b><a href="syntax/join-clause.html">join-clause:</a></b>
          158  +<button id='x1741' onclick='hideorshow("x1741","x1742")'>show</button></p>
          159  + <div id='x1742' style='display:none;' class='imgcontainer'>
          160  + <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
          161  +<p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
          162  +<button id='x1743' onclick='hideorshow("x1743","x1744")'>show</button></p>
          163  + <div id='x1744' style='display:none;' class='imgcontainer'>
          164  + <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
          165  +</div>
          166  +<p><b><a href="syntax/join-operator.html">join-operator:</a></b>
          167  +<button id='x1745' onclick='hideorshow("x1745","x1746")'>show</button></p>
          168  + <div id='x1746' style='display:none;' class='imgcontainer'>
          169  + <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
          170  +</div>
          171  +</div>
          172  +<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
          173  +<button id='x1747' onclick='hideorshow("x1747","x1748")'>show</button></p>
          174  + <div id='x1748' style='display:none;' class='imgcontainer'>
          175  + <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
          176  +</div>
          177  +<p><b><a href="syntax/result-column.html">result-column:</a></b>
          178  +<button id='x1749' onclick='hideorshow("x1749","x1750")'>show</button></p>
          179  + <div id='x1750' style='display:none;' class='imgcontainer'>
          180  + <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
          181  +</div>
          182  +<p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
          183  +<button id='x1751' onclick='hideorshow("x1751","x1752")'>show</button></p>
          184  + <div id='x1752' style='display:none;' class='imgcontainer'>
          185  + <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
          186  +</div>
          187  +<p><b><a href="syntax/window-defn.html">window-defn:</a></b>
          188  +<button id='x1753' onclick='hideorshow("x1753","x1754")'>show</button></p>
          189  + <div id='x1754' style='display:none;' class='imgcontainer'>
          190  + <img alt="syntax diagram window-defn" src="images/syntax/window-defn.gif" />
          191  +<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
          192  +<button id='x1755' onclick='hideorshow("x1755","x1756")'>show</button></p>
          193  + <div id='x1756' style='display:none;' class='imgcontainer'>
          194  + <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
          195  +</div>
          196  +</div>
          197  +</div>
          198  +<p><b><a href="syntax/upsert-clause.html">upsert-clause:</a></b>
          199  +<button id='x1757' onclick='hideorshow("x1757","x1758")'>show</button></p>
          200  + <div id='x1758' style='display:none;' class='imgcontainer'>
          201  + <img alt="syntax diagram upsert-clause" src="images/syntax/upsert-clause.gif" />
          202  +<p><b><a href="syntax/column-name-list.html">column-name-list:</a></b>
          203  +<button id='x1759' onclick='hideorshow("x1759","x1760")'>show</button></p>
          204  + <div id='x1760' style='display:none;' class='imgcontainer'>
          205  + <img alt="syntax diagram column-name-list" src="images/syntax/column-name-list.gif" />
          206  +</div>
          207  +<p><b><a href="syntax/indexed-column.html">indexed-column:</a></b>
          208  +<button id='x1761' onclick='hideorshow("x1761","x1762")'>show</button></p>
          209  + <div id='x1762' style='display:none;' class='imgcontainer'>
          210  + <img alt="syntax diagram indexed-column" src="images/syntax/indexed-column.gif" />
          211  +</div>
          212  +</div>
          213  +<p><b><a href="syntax/with-clause.html">with-clause:</a></b>
          214  +<button id='x1763' onclick='hideorshow("x1763","x1764")'>show</button></p>
          215  + <div id='x1764' style='display:none;' class='imgcontainer'>
          216  + <img alt="syntax diagram with-clause" src="images/syntax/with-clause.gif" />
          217  +<p><b><a href="syntax/cte-table-name.html">cte-table-name:</a></b>
          218  +<button id='x1765' onclick='hideorshow("x1765","x1766")'>show</button></p>
          219  + <div id='x1766' style='display:none;' class='imgcontainer'>
          220  + <img alt="syntax diagram cte-table-name" src="images/syntax/cte-table-name.gif" />
          221  +</div>
          222  +</div>
          223  +</div>
          224  +
          225  +
          226  +<p>The INSERT statement comes in three basic forms.  
          227  +<ol>
          228  +<li><p><b>INSERT INTO </b><i>table</i><b> VALUES(...);</b>
          229  +<p>The first form (with the "VALUES" keyword) creates one or more
          230  +new rows in
          231  +an existing table. If the <span class='yyterm'>column-name</span> list after
          232  +<span class='yyterm'>table-name</span> is omitted then the number
          233  +of values inserted into each row
          234  +must be the same as the number of columns in the table. In this case
          235  +the result of evaluating the left-most expression from each term of
          236  +the VALUES list is inserted into the left-most column of each new row,
          237  +and so forth for each subsequent expression. If a <span class='yyterm'>column-name</span>
          238  +list is specified, then the number of values in each term of the
          239  +VALUE list must match the number of
          240  +specified columns. Each of the named columns of the new row is populated
          241  +with the results of evaluating the corresponding VALUES expression. Table
          242  +columns that do not appear in the column list are populated with the 
          243  +<a href="lang_createtable.html#dfltval">default column value</a> (specified as part of the <a href="lang_createtable.html">CREATE TABLE</a> statement), or
          244  +with NULL if no <a href="lang_createtable.html#dfltval">default value</a> is specified.
          245  +
          246  +<li><p><b>INSERT INTO </b><i>table</i><b> SELECT ...;</b>
          247  +<p>The second form of the INSERT statement contains a <a href="lang_select.html">SELECT</a> statement
          248  +instead of a VALUES clause. A new entry is inserted into the table for each
          249  +row of data returned by executing the SELECT statement. If a column-list is
          250  +specified, the number of columns in the result of the SELECT must be the same
          251  +as the number of items in the column-list. Otherwise, if no column-list is
          252  +specified, the number of columns in the result of the SELECT must be the same
          253  +as the number of columns in the table. Any SELECT statement, including
          254  +<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, 
          255  +may be used in an INSERT statement of this form.
          256  +
          257  +<p>To avoid a parsing ambiguity, the SELECT statement should always
          258  +contain a WHERE clause, even if that clause is simply "WHERE true",
          259  +if the <a href="syntax/upsert-clause.html">upsert-clause</a> is present.  Without the WHERE clause, the
          260  +parser does not know if the token "ON" is part of a join constraint
          261  +on the SELECT, or the beginning of the <a href="syntax/upsert-clause.html">upsert-clause</a>.
          262  +
          263  +<li><p><b>INSERT INTO </b><i>table</i><b> DEFAULT VALUES;</b>
          264  +<p>The third form of an INSERT statement is with DEFAULT VALUES.
          265  +The INSERT ... DEFAULT VALUES statement inserts a single new row into the
          266  +named table. Each column of the new row is populated with its 
          267  +<a href="lang_createtable.html#dfltval">default value</a>, or with a NULL if no default value is specified 
          268  +as part of the column definition in the <a href="lang_createtable.html">CREATE TABLE</a> statement.
          269  +The <a href="syntax/upsert-clause.html">upsert-clause</a> is not supported after DEFAULT VALUES.
          270  +
          271  +</ol>
          272  +
          273  +<p>
          274  +The initial "INSERT" keyword can be replaced by
          275  +"REPLACE" or "INSERT OR <i>action</i>" to specify an alternative
          276  +constraint <a href="lang_conflict.html">conflict resolution algorithm</a> to use during 
          277  +that one INSERT command.
          278  +For compatibility with MySQL, the parser allows the use of the
          279  +single keyword <a href="lang_replace.html">REPLACE</a> as an 
          280  +alias for "INSERT OR REPLACE".
          281  +
          282  +<p>The optional "<i>schema-name</i><b>.</b>" prefix on the 
          283  +<span class='yyterm'>table-name</span>
          284  +is supported for top-level INSERT statements only.  The table name must be
          285  +unqualified for INSERT statements that occur within <a href="lang_createtrigger.html">CREATE TRIGGER</a> statements.
          286  +Similarly, the "DEFAULT VALUES" form of the INSERT statement is supported for
          287  +top-level INSERT statements only and not for INSERT statements within
          288  +triggers.
          289  +<p>
          290  +
          291  +<p>The optional "AS <span class='yyterm'>alias</span>" phrase provides an alternative
          292  +name for the table into which content is being inserted.  The alias name
          293  +can be used within WHERE and SET clauses of the <a href="lang_UPSERT.html">UPSERT</a>.  If there is no
          294  +<a href="syntax/upsert-clause.html">upsert-clause</a>, then the <span class='yyterm'>alias</span> is pointless, but also
          295  +harmless.
          296  +
          297  +<p>See the separate <a href="lang_UPSERT.html">UPSERT</a> documentation for the additional trailing
          298  +syntax that can cause an INSERT to behave as an UPDATE if the INSERT would
          299  +otherwise violate a uniqueness constraint.  The <a href="lang_UPSERT.html">upsert clause</a> is not
          300  +allowed on an "INSERT ... DEFAULT VALUES".
          301  +
          302  +
          303  +

Added Doc/Extra/Core/lang_keywords.html.

            1  +<!DOCTYPE html>
            2  +<html><head>
            3  +<meta name="viewport" content="width=device-width, initial-scale=1.0">
            4  +<meta http-equiv="content-type" content="text/html; charset=UTF-8">
            5  +<link href="sqlite.css" rel="stylesheet">
            6  +<title>SQLite Query Language: SQLite Keywords</title>
            7  +<!-- path= -->
            8  +</head>
            9  +<body>
           10  +<div class=nosearch>
           11  +<a href="index.html">
           12  +<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
           13  +</a>
           14  +<div><!-- IE hack to prevent disappearing logo --></div>
           15  +<div class="tagline desktoponly">
           16  +Small. Fast. Reliable.<br>Choose any three.
           17  +</div>
           18  +<div class="menu mainmenu">
           19  +<ul>
           20  +<li><a href="index.html">Home</a>
           21  +<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
           22  +<li class='wideonly'><a href='about.html'>About</a>
           23  +<li class='desktoponly'><a href="docs.html">Documentation</a>
           24  +<li class='desktoponly'><a href="download.html">Download</a>
           25  +<li class='wideonly'><a href='copyright.html'>License</a>
           26  +<li class='desktoponly'><a href="support.html">Support</a>
           27  +<li class='desktoponly'><a href="prosupport.html">Purchase</a>
           28  +<li class='search' id='search_menubutton'>
           29  +<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
           30  +</ul>
           31  +</div>
           32  +<div class="menu submenu" id="submenu">
           33  +<ul>
           34  +<li><a href='about.html'>About</a>
           35  +<li><a href='docs.html'>Documentation</a>
           36  +<li><a href='download.html'>Download</a>
           37  +<li><a href='support.html'>Support</a>
           38  +<li><a href='prosupport.html'>Purchase</a>
           39  +</ul>
           40  +</div>
           41  +<div class="searchmenu" id="searchmenu">
           42  +<form method="GET" action="search">
           43  +<select name="s" id="searchtype">
           44  +<option value="d">Search Documentation</option>
           45  +<option value="c">Search Changelog</option>
           46  +</select>
           47  +<input type="text" name="q" id="searchbox" value="">
           48  +<input type="submit" value="Go">
           49  +</form>
           50  +</div>
           51  +</div>
           52  +<script>
           53  +function toggle_div(nm) {
           54  +var w = document.getElementById(nm);
           55  +if( w.style.display=="block" ){
           56  +w.style.display = "none";
           57  +}else{
           58  +w.style.display = "block";
           59  +}
           60  +}
           61  +function toggle_search() {
           62  +var w = document.getElementById("searchmenu");
           63  +if( w.style.display=="block" ){
           64  +w.style.display = "none";
           65  +} else {
           66  +w.style.display = "block";
           67  +setTimeout(function(){
           68  +document.getElementById("searchbox").focus()
           69  +}, 30);
           70  +}
           71  +}
           72  +function div_off(nm){document.getElementById(nm).style.display="none";}
           73  +window.onbeforeunload = function(e){div_off("submenu");}
           74  +/* Disable the Search feature if we are not operating from CGI, since */
           75  +/* Search is accomplished using CGI and will not work without it. */
           76  +if( !location.origin.match || !location.origin.match(/http/) ){
           77  +document.getElementById("search_menubutton").style.display = "none";
           78  +}
           79  +/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
           80  +function hideorshow(btn,obj){
           81  +var x = document.getElementById(obj);
           82  +var b = document.getElementById(btn);
           83  +if( x.style.display!='none' ){
           84  +x.style.display = 'none';
           85  +b.innerHTML='show';
           86  +}else{
           87  +x.style.display = '';
           88  +b.innerHTML='hide';
           89  +}
           90  +return false;
           91  +}
           92  +</script>
           93  +</div>
           94  +<div class=nosearch><h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>SQLite Keywords</h2></div></DIV>
           95  +
           96  +<p>The SQL standard specifies a large number of keywords which may not
           97  +be used as the names of tables, indices, columns, databases, user-defined
           98  +functions, collations, virtual table modules, or any other named object.
           99  +The list of keywords is so long that few people can remember them all.
          100  +For most SQL code, your safest bet is to never use any English language
          101  +word as the name of a user-defined object.</p>
          102  +
          103  +<p>If you want to use a keyword as a name, you need to quote it.  There
          104  +are four ways of quoting keywords in SQLite:</p>
          105  +
          106  +<p>
          107  +<blockquote>
          108  +<table>
          109  +<tr>	<td valign="top"><b>'keyword'</b></td><td width="20"></td>
          110  +	<td>A keyword in single quotes is a string literal.</td></tr>
          111  +
          112  +<tr>	<td valign="top"><b>"keyword"</b></td><td></td>
          113  +	<td>A keyword in double-quotes is an identifier.</td></tr>
          114  +
          115  +<tr>	<td valign="top"><b>&#91;keyword&#93;</b></td><td></td>
          116  +	<td>A keyword enclosed in square brackets is 
          117  +        an identifier.  This is not standard SQL.  This quoting mechanism
          118  +        is used by MS Access and SQL Server and is included in SQLite for
          119  +        compatibility.</td></tr>
          120  +
          121  +<tr>	<td valign="top"><b>&#96;keyword&#96;</b></td><td></td>
          122  +	<td>A keyword enclosed in grave accents (ASCII code 96) is 
          123  +        an identifier.  This is not standard SQL.  This quoting mechanism
          124  +        is used by MySQL and is included in SQLite for
          125  +        compatibility.</td></tr>
          126  +</table>
          127  +</blockquote>
          128  +</p>
          129  +
          130  +<p>For resilience when confronted with historical SQL statements, SQLite
          131  +will sometimes bend the quoting rules above:</p>
          132  +
          133  +<ul>
          134  +<li><p>If a keyword in single
          135  +quotes (ex: <b>'key'</b> or <b>'glob'</b>) is used in a context where
          136  +an identifier is allowed but where a string literal is not allowed, then
          137  +the token is understood to be an identifier instead of a string literal.
          138  +</p></li>
          139  +
          140  +<li><p>If a keyword in double
          141  +quotes (ex: <b>"key"</b> or <b>"glob"</b>) is used in a context where
          142  +it cannot be resolved to an identifier but where a string literal
          143  +is allowed, then the token is understood to be a string literal instead
          144  +of an identifier.</p></li>
          145  +</ul>
          146  +
          147  +<p>Programmers are cautioned not to use the two exceptions described in
          148  +the previous bullets.  We emphasize that they exist only so that old
          149  +and ill-formed SQL statements will run correctly.  Future versions of
          150  +SQLite might raise errors instead of accepting the malformed
          151  +statements covered by the exceptions above.</p>
          152  +
          153  +<p>
          154  +SQLite adds new keywords from time to time when it takes on new features.
          155  +So to prevent your code from being broken by future enhancements, you should
          156  +normally quote any identifier that is an English language word, even if
          157  +you do not have to.
          158  +</p>
          159  +
          160  +<p>
          161  +The list below shows all possible keywords used by any build of
          162  +SQLite regardless of <a href="compile.html">compile-time options</a>.  
          163  +Most reasonable configurations use most or all of these keywords,
          164  +but some keywords may be omitted when SQL language features are
          165  +disabled.
          166  +Applications can use the
          167  +<a href="c3ref/keyword_check.html">sqlite3_keyword_count()</a>, <a href="c3ref/keyword_check.html">sqlite3_keyword_name()</a>, and
          168  +<a href="c3ref/keyword_check.html">sqlite3_keyword_check()</a> interfaces to determine the keywords
          169  +recognized by SQLite at run-time.
          170  +Regardless of the compile-time configuration, any identifier that is not on
          171  +the following 143 element
          172  +list is not a keyword to the SQL parser in SQLite:
          173  +</p>
          174  +
          175  +<ol>
          176  +<li>ABORT</li>
          177  +<li>ACTION</li>
          178  +<li>ADD</li>
          179  +<li>AFTER</li>
          180  +<li>ALL</li>
          181  +<li>ALTER</li>
          182  +<li>ANALYZE</li>
          183  +<li>AND</li>
          184  +<li>AS</li>
          185  +<li>ASC</li>
          186  +<li>ATTACH</li>
          187  +<li>AUTOINCREMENT</li>
          188  +<li>BEFORE</li>
          189  +<li>BEGIN</li>
          190  +<li>BETWEEN</li>
          191  +<li>BY</li>
          192  +<li>CASCADE</li>
          193  +<li>CASE</li>
          194  +<li>CAST</li>
          195  +<li>CHECK</li>
          196  +<li>COLLATE</li>
          197  +<li>COLUMN</li>
          198  +<li>COMMIT</li>
          199  +<li>CONFLICT</li>
          200  +<li>CONSTRAINT</li>
          201  +<li>CREATE</li>
          202  +<li>CROSS</li>
          203  +<li>CURRENT</li>
          204  +<li>CURRENT_DATE</li>
          205  +<li>CURRENT_TIME</li>
          206  +<li>CURRENT_TIMESTAMP</li>
          207  +<li>DATABASE</li>
          208  +<li>DEFAULT</li>
          209  +<li>DEFERRABLE</li>
          210  +<li>DEFERRED</li>
          211  +<li>DELETE</li>
          212  +<li>DESC</li>
          213  +<li>DETACH</li>
          214  +<li>DISTINCT</li>
          215  +<li>DO</li>
          216  +<li>DROP</li>
          217  +<li>EACH</li>
          218  +<li>ELSE</li>
          219  +<li>END</li>
          220  +<li>ESCAPE</li>
          221  +<li>EXCEPT</li>
          222  +<li>EXCLUDE</li>
          223  +<li>EXCLUSIVE</li>
          224  +<li>EXISTS</li>
          225  +<li>EXPLAIN</li>
          226  +<li>FAIL</li>
          227  +<li>FILTER</li>
          228  +<li>FIRST</li>
          229  +<li>FOLLOWING</li>
          230  +<li>FOR</li>
          231  +<li>FOREIGN</li>
          232  +<li>FROM</li>
          233  +<li>FULL</li>
          234  +<li>GLOB</li>
          235  +<li>GROUP</li>
          236  +<li>GROUPS</li>
          237  +<li>HAVING</li>
          238  +<li>IF</li>
          239  +<li>IGNORE</li>
          240  +<li>IMMEDIATE</li>
          241  +<li>IN</li>
          242  +<li>INDEX</li>
          243  +<li>INDEXED</li>
          244  +<li>INITIALLY</li>
          245  +<li>INNER</li>
          246  +<li>INSERT</li>
          247  +<li>INSTEAD</li>
          248  +<li>INTERSECT</li>
          249  +<li>INTO</li>
          250  +<li>IS</li>
          251  +<li>ISNULL</li>
          252  +<li>JOIN</li>
          253  +<li>KEY</li>
          254  +<li>LAST</li>
          255  +<li>LEFT</li>
          256  +<li>LIKE</li>
          257  +<li>LIMIT</li>
          258  +<li>MATCH</li>
          259  +<li>NATURAL</li>
          260  +<li>NO</li>
          261  +<li>NOT</li>
          262  +<li>NOTHING</li>
          263  +<li>NOTNULL</li>
          264  +<li>NULL</li>
          265  +<li>NULLS</li>
          266  +<li>OF</li>
          267  +<li>OFFSET</li>
          268  +<li>ON</li>
          269  +<li>OR</li>
          270  +<li>ORDER</li>
          271  +<li>OTHERS</li>
          272  +<li>OUTER</li>
          273  +<li>OVER</li>
          274  +<li>PARTITION</li>
          275  +<li>PLAN</li>
          276  +<li>PRAGMA</li>
          277  +<li>PRECEDING</li>
          278  +<li>PRIMARY</li>
          279  +<li>QUERY</li>
          280  +<li>RAISE</li>
          281  +<li>RANGE</li>
          282  +<li>RECURSIVE</li>
          283  +<li>REFERENCES</li>
          284  +<li>REGEXP</li>
          285  +<li>REINDEX</li>
          286  +<li>RELEASE</li>
          287  +<li>RENAME</li>
          288  +<li>REPLACE</li>
          289  +<li>RESTRICT</li>
          290  +<li>RIGHT</li>
          291  +<li>ROLLBACK</li>
          292  +<li>ROW</li>
          293  +<li>ROWS</li>
          294  +<li>SAVEPOINT</li>
          295  +<li>SELECT</li>
          296  +<li>SET</li>