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 4c3bf14969

2020-08-14
13:32
Update SQLite core library to the 3.33.0 release. Leaf check-in: 9a82d5c9c7 user: mistachkin tags: core-3-33
2020-06-09
23:00
Preliminary support for an alternate DLL config file. Pursuant to [bd9c4375cc]. Leaf check-in: 4c3bf14969 user: mistachkin tags: trunk
2020-06-01
22:50
Enhancements to the NuGet packaging automation. check-in: f33042c238 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/aggregate-function-invocation.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/filter-clause.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/frame-spec.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/over-clause.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-function-invocation.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/window-defn.gif.

cannot compute difference between binary files

Added Doc/Extra/Core/images/syntax/window-function-invocation.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 || !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  +<div class='columns' style='columns: 17em auto;'>
          113  +<ul style='padding-top:0;'>
          114  +<li><a href='lang_aggfunc.html'>aggregate functions</a></li>
          115  +<li><a href='lang_altertable.html'>ALTER TABLE</a></li>
          116  +<li><a href='lang_analyze.html'>ANALYZE</a></li>
          117  +<li><a href='lang_attach.html'>ATTACH DATABASE</a></li>
          118  +<li><a href=''>BEGIN TRANSACTION</a></li>
          119  +<li><a href='lang_comment.html'>comment</a></li>
          120  +<li><a href='lang_transaction.html'>COMMIT TRANSACTION</a></li>
          121  +<li><a href='lang_corefunc.html'>core functions</a></li>
          122  +<li><a href='lang_createindex.html'>CREATE INDEX</a></li>
          123  +<li><a href='lang_createtable.html'>CREATE TABLE</a></li>
          124  +<li><a href='lang_createtrigger.html'>CREATE TRIGGER</a></li>
          125  +<li><a href='lang_createview.html'>CREATE VIEW</a></li>
          126  +<li><a href='lang_createvtab.html'>CREATE VIRTUAL TABLE</a></li>
          127  +<li><a href='lang_datefunc.html'>date and time functions</a></li>
          128  +<li><a href='lang_delete.html'>DELETE</a></li>
          129  +<li><a href='lang_detach.html'>DETACH DATABASE</a></li>
          130  +<li><a href='lang_dropindex.html'>DROP INDEX</a></li>
          131  +<li><a href='lang_droptable.html'>DROP TABLE</a></li>
          132  +<li><a href='lang_droptrigger.html'>DROP TRIGGER</a></li>
          133  +<li><a href='lang_dropview.html'>DROP VIEW</a></li>
          134  +<li><a href='lang_transaction.html'>END TRANSACTION</a></li>
          135  +<li><a href='lang_explain.html'>EXPLAIN</a></li>
          136  +<li><a href='lang_expr.html'>expression</a></li>
          137  +<li><a href='lang_indexedby.html'>INDEXED BY</a></li>
          138  +<li><a href='lang_insert.html'>INSERT</a></li>
          139  +<li><a href='lang_keywords.html'>keywords</a></li>
          140  +<li><a href='lang_conflict.html'>ON CONFLICT clause</a></li>
          141  +<li><a href='pragma.html#syntax'>PRAGMA</a></li>
          142  +<li><a href='lang_reindex.html'>REINDEX</a></li>
          143  +<li><a href='lang_savepoint.html'>RELEASE SAVEPOINT</a></li>
          144  +<li><a href='lang_replace.html'>REPLACE</a></li>
          145  +<li><a href='lang_transaction.html'>ROLLBACK TRANSACTION</a></li>
          146  +<li><a href='lang_savepoint.html'>SAVEPOINT</a></li>
          147  +<li><a href='lang_select.html'>SELECT</a></li>
          148  +<li><a href='lang_update.html'>UPDATE</a></li>
          149  +<li><a href='lang_upsert.html'>UPSERT</a></li>
          150  +<li><a href='lang_vacuum.html'>VACUUM</a></li>
          151  +<li><a href='lang_with.html'>WITH clause</a></li>
          152  +</ul>
          153  +</div>
          154  +
          155  +</ul></td></tr></table>
          156  +
          157  +<p>The routines <a href="c3ref/prepare.html">sqlite3_prepare_v2()</a>, <a href="c3ref/prepare.html">sqlite3_prepare()</a>,
          158  +<a href="c3ref/prepare.html">sqlite3_prepare16()</a>, <a href="c3ref/prepare.html">sqlite3_prepare16_v2()</a>, 
          159  +<a href="c3ref/exec.html">sqlite3_exec()</a>, and <a href="c3ref/free_table.html">sqlite3_get_table()</a> accept
          160  +an SQL statement list (sql-stmt-list) which is a semicolon-separated
          161  +list of statements.</p>
          162  +
          163  +<p><b><a href="syntax/sql-stmt-list.html">sql-stmt-list:</a></b></p><div class='imgcontainer'>
          164  + <img alt="syntax diagram sql-stmt-list" src="images/syntax/sql-stmt-list.gif"></img>
          165  + </div>
          166  +
          167  +
          168  +<p>Each SQL statement in the statement list is an instance of the
          169  +following:</p>
          170  +
          171  +<p><b><a href="syntax/sql-stmt.html">sql-stmt:</a></b></p><div class='imgcontainer'>
          172  + <img alt="syntax diagram sql-stmt" src="images/syntax/sql-stmt.gif"></img>
          173  + </div>
          174  +
          175  +

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+1".  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>Built-in 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 || !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=fancy>
           95  +<div class=nosearch>
           96  +<div class="fancy_title">
           97  +Built-in Aggregate Functions
           98  +</div>
           99  +</div>
          100  +
          101  +
          102  +
          103  +
          104  +
          105  +<h1 id="syntax"><span>1. </span>Syntax</h1>
          106  +<p><b><a href="syntax/aggregate-function-invocation.html">aggregate-function-invocation:</a></b>
          107  +<button id='x1191' onclick='hideorshow("x1191","x1192")'>hide</button></p>
          108  + <div id='x1192' class='imgcontainer'>
          109  + <img alt="syntax diagram aggregate-function-invocation" src="images/syntax/aggregate-function-invocation.gif" />
          110  +<p><b><a href="syntax/expr.html">expr:</a></b>
          111  +<button id='x1193' onclick='hideorshow("x1193","x1194")'>show</button></p>
          112  + <div id='x1194' style='display:none;' class='imgcontainer'>
          113  + <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
          114  +<p><b><a href="syntax/literal-value.html">literal-value:</a></b>
          115  +<button id='x1195' onclick='hideorshow("x1195","x1196")'>show</button></p>
          116  + <div id='x1196' style='display:none;' class='imgcontainer'>
          117  + <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
          118  +</div>
          119  +<p><b><a href="syntax/over-clause.html">over-clause:</a></b>
          120  +<button id='x1197' onclick='hideorshow("x1197","x1198")'>show</button></p>
          121  + <div id='x1198' style='display:none;' class='imgcontainer'>
          122  + <img alt="syntax diagram over-clause" src="images/syntax/over-clause.gif" />
          123  +<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
          124  +<button id='x1199' onclick='hideorshow("x1199","x1200")'>show</button></p>
          125  + <div id='x1200' style='display:none;' class='imgcontainer'>
          126  + <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
          127  +</div>
          128  +<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
          129  +<button id='x1201' onclick='hideorshow("x1201","x1202")'>show</button></p>
          130  + <div id='x1202' style='display:none;' class='imgcontainer'>
          131  + <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
          132  +</div>
          133  +</div>
          134  +<p><b><a href="syntax/raise-function.html">raise-function:</a></b>
          135  +<button id='x1203' onclick='hideorshow("x1203","x1204")'>show</button></p>
          136  + <div id='x1204' style='display:none;' class='imgcontainer'>
          137  + <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
          138  +</div>
          139  +<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
          140  +<button id='x1205' onclick='hideorshow("x1205","x1206")'>show</button></p>
          141  + <div id='x1206' style='display:none;' class='imgcontainer'>
          142  + <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
          143  +<p><b><a href="syntax/common-table-expression.html">common-table-expression:</a></b>
          144  +<button id='x1207' onclick='hideorshow("x1207","x1208")'>show</button></p>
          145  + <div id='x1208' style='display:none;' class='imgcontainer'>
          146  + <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
          147  +</div>
          148  +<p><b><a href="syntax/compound-operator.html">compound-operator:</a></b>
          149  +<button id='x1209' onclick='hideorshow("x1209","x1210")'>show</button></p>
          150  + <div id='x1210' style='display:none;' class='imgcontainer'>
          151  + <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
          152  +</div>
          153  +<p><b><a href="syntax/join-clause.html">join-clause:</a></b>
          154  +<button id='x1211' onclick='hideorshow("x1211","x1212")'>show</button></p>
          155  + <div id='x1212' style='display:none;' class='imgcontainer'>
          156  + <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
          157  +<p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
          158  +<button id='x1213' onclick='hideorshow("x1213","x1214")'>show</button></p>
          159  + <div id='x1214' style='display:none;' class='imgcontainer'>
          160  + <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
          161  +</div>
          162  +<p><b><a href="syntax/join-operator.html">join-operator:</a></b>
          163  +<button id='x1215' onclick='hideorshow("x1215","x1216")'>show</button></p>
          164  + <div id='x1216' style='display:none;' class='imgcontainer'>
          165  + <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
          166  +</div>
          167  +</div>
          168  +<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
          169  +<button id='x1217' onclick='hideorshow("x1217","x1218")'>show</button></p>
          170  + <div id='x1218' style='display:none;' class='imgcontainer'>
          171  + <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
          172  +</div>
          173  +<p><b><a href="syntax/result-column.html">result-column:</a></b>
          174  +<button id='x1219' onclick='hideorshow("x1219","x1220")'>show</button></p>
          175  + <div id='x1220' style='display:none;' class='imgcontainer'>
          176  + <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
          177  +</div>
          178  +<p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
          179  +<button id='x1221' onclick='hideorshow("x1221","x1222")'>show</button></p>
          180  + <div id='x1222' style='display:none;' class='imgcontainer'>
          181  + <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
          182  +</div>
          183  +<p><b><a href="syntax/window-defn.html">window-defn:</a></b>
          184  +<button id='x1223' onclick='hideorshow("x1223","x1224")'>show</button></p>
          185  + <div id='x1224' style='display:none;' class='imgcontainer'>
          186  + <img alt="syntax diagram window-defn" src="images/syntax/window-defn.gif" />
          187  +<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
          188  +<button id='x1225' onclick='hideorshow("x1225","x1226")'>show</button></p>
          189  + <div id='x1226' style='display:none;' class='imgcontainer'>
          190  + <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
          191  +</div>
          192  +</div>
          193  +</div>
          194  +<p><b><a href="syntax/type-name.html">type-name:</a></b>
          195  +<button id='x1227' onclick='hideorshow("x1227","x1228")'>show</button></p>
          196  + <div id='x1228' style='display:none;' class='imgcontainer'>
          197  + <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
          198  +<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
          199  +<button id='x1229' onclick='hideorshow("x1229","x1230")'>show</button></p>
          200  + <div id='x1230' style='display:none;' class='imgcontainer'>
          201  + <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
          202  +</div>
          203  +</div>
          204  +</div>
          205  +<p><b><a href="syntax/filter-clause.html">filter-clause:</a></b>
          206  +<button id='x1231' onclick='hideorshow("x1231","x1232")'>show</button></p>
          207  + <div id='x1232' style='display:none;' class='imgcontainer'>
          208  + <img alt="syntax diagram filter-clause" src="images/syntax/filter-clause.gif" />
          209  +</div>
          210  +</div>
          211  +
          212  +
          213  +<p>
          214  +The aggregate functions shown below are available by default.  Additional
          215  +aggregate functions written in C may be added using the 
          216  +<a href="c3ref/create_function.html">sqlite3_create_function()</a>
          217  +API.</p>
          218  +
          219  +<p>
          220  +In any aggregate function that takes a single argument, that argument
          221  +can be preceded by the keyword DISTINCT.  In such cases, duplicate
          222  +elements are filtered before being passed into the aggregate function.
          223  +For example, the function "count(distinct X)" will return the number
          224  +of distinct values of column X instead of the total number of non-null
          225  +values in column X.
          226  +</p>
          227  +
          228  +<a name="aggfilter"></a>
          229  +
          230  +<p>
          231  +If a FILTER clause is provided, then only rows for which the <i>expr</i> is
          232  +true are included in the aggregate.
          233  +</p>
          234  +
          235  +<a name="aggfunclist"></a>
          236  +
          237  +<h1 id="list_of_built_in_aggregate_functions"><span>2. </span>List of built-in aggregate functions</h1>
          238  +
          239  +<div class='columns' style='columns: 11em auto;'>
          240  +<ul style='padding-top:0;'>
          241  +<li><a href='lang_aggfunc.html#avg'>avg(X)</a></li>
          242  +<li><a href='lang_aggfunc.html#count'>count(*)</a></li>
          243  +<li><a href='lang_aggfunc.html#count'>count(X)</a></li>
          244  +<li><a href='lang_aggfunc.html#groupconcat'>group_concat(X)</a></li>
          245  +<li><a href='lang_aggfunc.html#groupconcat'>group_concat(X,Y)</a></li>
          246  +<li><a href='lang_corefunc.html#maxoreunc'>max(X)</a></li>
          247  +<li><a href='lang_corefunc.html#minoreunc'>min(X)</a></li>
          248  +<li><a href='lang_aggfunc.html#sumunc'>sum(X)</a></li>
          249  +<li><a href='lang_aggfunc.html#sumunc'>total(X)</a></li>
          250  +</ul>
          251  +</div>
          252  +
          253  +
          254  +<h1 id="descriptions_of_built_in_aggregate_functions"><span>3. </span>Descriptions of built-in aggregate functions</h1>
          255  +<dl>
          256  +
          257  +<a name="avg"></a>
          258  +<dt><p><b>avg(<i>X</i>)</b></dt><dd><p>
          259  +  The avg() function
          260  +  returns the average value of all non-NULL <i>X</i> within a
          261  +  group.  String and BLOB values that do not look like numbers are
          262  +  interpreted as 0.
          263  +  The result of avg() is always a floating point value as long as
          264  +  at there is at least one non-NULL input even if all
          265  +  inputs are integers.  The result of avg() is NULL if and only if
          266  +  there are no non-NULL inputs.  
          267  +</dd>
          268  +<a name="count"></a>
          269  +<dt><p><b>count(<i>X</i>)<br />count(*)</b></dt><dd><p>
          270  +  The count(X) function returns
          271  +  a count of the number of times
          272  +  that <i>X</i> is not NULL in a group.  The count(*) function
          273  +  (with no arguments) returns the total number of rows in the group.
          274  +</dd>
          275  +<a name="groupconcat"></a>
          276  +<dt><p><b>group_concat(<i>X</i>)<br />group_concat(<i>X</i>,<i>Y</i>)</b></dt><dd><p>
          277  +  The group_concat() function returns
          278  +  a string which is the concatenation of
          279  +  all non-NULL values of <i>X</i>.  If parameter <i>Y</i> is present then
          280  +  it is used as the separator
          281  +  between instances of <i>X</i>.  A comma (",") is used as the separator
          282  +  if <i>Y</i> is omitted.  The order of the concatenated elements is
          283  +  arbitrary.
          284  +</dd>
          285  +<a name="maxggunc"></a>
          286  +<dt><p><b>max(<i>X</i>)</b></dt><dd><p>
          287  +  The max() aggregate function
          288  +  returns the maximum value of all values in the group.
          289  +  The maximum value is the value that would be returned last in an
          290  +  ORDER BY on the same column.  Aggregate max() returns NULL 
          291  +  if and only if there are no non-NULL values in the group.
          292  +</dd>
          293  +<a name="minggunc"></a>
          294  +<dt><p><b>min(<i>X</i>)</b></dt><dd><p>
          295  +  The min() aggregate function
          296  +  returns the minimum non-NULL value of all values in the group.
          297  +  The minimum value is the first non-NULL value that would appear
          298  +  in an ORDER BY of the column.
          299  +  Aggregate min() returns NULL if and only if there are no non-NULL
          300  +  values in the group.
          301  +</dd>
          302  +<a name="sumunc"></a>
          303  +<dt><p><b>sum(<i>X</i>)<br />total(<i>X</i>)</b></dt><dd><p>
          304  +  The sum() and total() aggregate functions
          305  +  return sum of all non-NULL values in the group.
          306  +  If there are no non-NULL input rows then sum() returns
          307  +  NULL but total() returns 0.0.
          308  +  NULL is not normally a helpful result for the sum of no rows
          309  +  but the SQL standard requires it and most other
          310  +  SQL database engines implement sum() that way so SQLite does it in the
          311  +  same way in order to be compatible.   The non-standard total() function
          312  +  is provided as a convenient way to work around this design problem
          313  +  in the SQL language.</p>
          314  +
          315  +  <p>The result of total() is always a floating point value.
          316  +  The result of sum() is an integer value if all non-NULL inputs are integers.
          317  +  If any input to sum() is neither an integer or a NULL
          318  +  then sum() returns a floating point value
          319  +  which might be an approximation to the true sum.</p>
          320  +
          321  +  <p>Sum() will throw an "integer overflow" exception if all inputs
          322  +  are integers or NULL
          323  +  and an integer overflow occurs at any point during the computation.
          324  +  Total() never throws an integer overflow.
          325  +</dd>
          326  +
          327  +</dl>
          328  +

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>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 || !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=fancy>
           95  +<div class=nosearch>
           96  +<div class="fancy_title">
           97  +ALTER TABLE
           98  +</div>
           99  +</div>
          100  +
          101  +
          102  +
          103  +
          104  +
          105  +<h1 id="overview"><span>1. </span>Overview</h1>
          106  +
          107  +<p><b><a href="syntax/alter-table-stmt.html">alter-table-stmt:</a></b>
          108  +<button id='x1233' onclick='hideorshow("x1233","x1234")'>hide</button></p>
          109  + <div id='x1234' class='imgcontainer'>
          110  + <img alt="syntax diagram alter-table-stmt" src="images/syntax/alter-table-stmt.gif" />
          111  +<p><b><a href="syntax/column-def.html">column-def:</a></b>
          112  +<button id='x1235' onclick='hideorshow("x1235","x1236")'>show</button></p>
          113  + <div id='x1236' style='display:none;' class='imgcontainer'>
          114  + <img alt="syntax diagram column-def" src="images/syntax/column-def.gif" />
          115  +<p><b><a href="syntax/column-constraint.html">column-constraint:</a></b>
          116  +<button id='x1237' onclick='hideorshow("x1237","x1238")'>show</button></p>
          117  + <div id='x1238' style='display:none;' class='imgcontainer'>
          118  + <img alt="syntax diagram column-constraint" src="images/syntax/column-constraint.gif" />
          119  +<p><b><a href="syntax/conflict-clause.html">conflict-clause:</a></b>
          120  +<button id='x1239' onclick='hideorshow("x1239","x1240")'>show</button></p>
          121  + <div id='x1240' style='display:none;' class='imgcontainer'>
          122  + <img alt="syntax diagram conflict-clause" src="images/syntax/conflict-clause.gif" />
          123  +</div>
          124  +<p><b><a href="syntax/expr.html">expr:</a></b>
          125  +<button id='x1241' onclick='hideorshow("x1241","x1242")'>show</button></p>
          126  + <div id='x1242' style='display:none;' class='imgcontainer'>
          127  + <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
          128  +<p><b><a href="syntax/filter-clause.html">filter-clause:</a></b>
          129  +<button id='x1243' onclick='hideorshow("x1243","x1244")'>show</button></p>
          130  + <div id='x1244' style='display:none;' class='imgcontainer'>
          131  + <img alt="syntax diagram filter-clause" src="images/syntax/filter-clause.gif" />
          132  +</div>
          133  +<p><b><a href="syntax/over-clause.html">over-clause:</a></b>
          134  +<button id='x1245' onclick='hideorshow("x1245","x1246")'>show</button></p>
          135  + <div id='x1246' style='display:none;' class='imgcontainer'>
          136  + <img alt="syntax diagram over-clause" src="images/syntax/over-clause.gif" />
          137  +<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
          138  +<button id='x1247' onclick='hideorshow("x1247","x1248")'>show</button></p>
          139  + <div id='x1248' style='display:none;' class='imgcontainer'>
          140  + <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
          141  +</div>
          142  +<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
          143  +<button id='x1249' onclick='hideorshow("x1249","x1250")'>show</button></p>
          144  + <div id='x1250' style='display:none;' class='imgcontainer'>
          145  + <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
          146  +</div>
          147  +</div>
          148  +<p><b><a href="syntax/raise-function.html">raise-function:</a></b>
          149  +<button id='x1251' onclick='hideorshow("x1251","x1252")'>show</button></p>
          150  + <div id='x1252' style='display:none;' class='imgcontainer'>
          151  + <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
          152  +</div>
          153  +<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
          154  +<button id='x1253' onclick='hideorshow("x1253","x1254")'>show</button></p>
          155  + <div id='x1254' style='display:none;' class='imgcontainer'>
          156  + <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
          157  +<p><b><a href="syntax/common-table-expression.html">common-table-expression:</a></b>
          158  +<button id='x1255' onclick='hideorshow("x1255","x1256")'>show</button></p>
          159  + <div id='x1256' style='display:none;' class='imgcontainer'>
          160  + <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
          161  +</div>
          162  +<p><b><a href="syntax/compound-operator.html">compound-operator:</a></b>
          163  +<button id='x1257' onclick='hideorshow("x1257","x1258")'>show</button></p>
          164  + <div id='x1258' style='display:none;' class='imgcontainer'>
          165  + <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
          166  +</div>
          167  +<p><b><a href="syntax/join-clause.html">join-clause:</a></b>
          168  +<button id='x1259' onclick='hideorshow("x1259","x1260")'>show</button></p>
          169  + <div id='x1260' style='display:none;' class='imgcontainer'>
          170  + <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
          171  +<p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
          172  +<button id='x1261' onclick='hideorshow("x1261","x1262")'>show</button></p>
          173  + <div id='x1262' style='display:none;' class='imgcontainer'>
          174  + <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
          175  +</div>
          176  +<p><b><a href="syntax/join-operator.html">join-operator:</a></b>
          177  +<button id='x1263' onclick='hideorshow("x1263","x1264")'>show</button></p>
          178  + <div id='x1264' style='display:none;' class='imgcontainer'>
          179  + <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
          180  +</div>
          181  +</div>
          182  +<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
          183  +<button id='x1265' onclick='hideorshow("x1265","x1266")'>show</button></p>
          184  + <div id='x1266' style='display:none;' class='imgcontainer'>
          185  + <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
          186  +</div>
          187  +<p><b><a href="syntax/result-column.html">result-column:</a></b>
          188  +<button id='x1267' onclick='hideorshow("x1267","x1268")'>show</button></p>
          189  + <div id='x1268' style='display:none;' class='imgcontainer'>
          190  + <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
          191  +</div>
          192  +<p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
          193  +<button id='x1269' onclick='hideorshow("x1269","x1270")'>show</button></p>
          194  + <div id='x1270' style='display:none;' class='imgcontainer'>
          195  + <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
          196  +</div>
          197  +<p><b><a href="syntax/window-defn.html">window-defn:</a></b>
          198  +<button id='x1271' onclick='hideorshow("x1271","x1272")'>show</button></p>
          199  + <div id='x1272' style='display:none;' class='imgcontainer'>
          200  + <img alt="syntax diagram window-defn" src="images/syntax/window-defn.gif" />
          201  +<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
          202  +<button id='x1273' onclick='hideorshow("x1273","x1274")'>show</button></p>
          203  + <div id='x1274' style='display:none;' class='imgcontainer'>
          204  + <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
          205  +</div>
          206  +</div>
          207  +</div>
          208  +</div>
          209  +<p><b><a href="syntax/foreign-key-clause.html">foreign-key-clause:</a></b>
          210  +<button id='x1275' onclick='hideorshow("x1275","x1276")'>show</button></p>
          211  + <div id='x1276' style='display:none;' class='imgcontainer'>
          212  + <img alt="syntax diagram foreign-key-clause" src="images/syntax/foreign-key-clause.gif" />
          213  +</div>
          214  +<p><b><a href="syntax/literal-value.html">literal-value:</a></b>
          215  +<button id='x1277' onclick='hideorshow("x1277","x1278")'>show</button></p>
          216  + <div id='x1278' style='display:none;' class='imgcontainer'>
          217  + <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
          218  +</div>
          219  +<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
          220  +<button id='x1279' onclick='hideorshow("x1279","x1280")'>show</button></p>
          221  + <div id='x1280' style='display:none;' class='imgcontainer'>
          222  + <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
          223  +</div>
          224  +</div>
          225  +<p><b><a href="syntax/type-name.html">type-name:</a></b>
          226  +<button id='x1281' onclick='hideorshow("x1281","x1282")'>show</button></p>
          227  + <div id='x1282' style='display:none;' class='imgcontainer'>
          228  + <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
          229  +<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
          230  +<button id='x1283' onclick='hideorshow("x1283","x1284")'>show</button></p>
          231  + <div id='x1284' style='display:none;' class='imgcontainer'>
          232  + <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
          233  +</div>
          234  +</div>
          235  +</div>
          236  +</div>
          237  +
          238  +
          239  +<p>SQLite supports a limited subset of ALTER TABLE.
          240  +The ALTER TABLE command in SQLite allows the user to rename a table,
          241  +to rename a column within a table, or to add a new column to an existing table.
          242  +
          243  +<a name="altertabrename"></a>
          244  +
          245  +</p><h1 id="alter_table_rename"><span>2. </span>ALTER TABLE RENAME</h1>
          246  +
          247  +<p> The RENAME TO syntax changes the name of <span class='yyterm'>table-name</span>
          248  +to <span class='yyterm'>new-table-name</span>.
          249  +This command 
          250  +cannot be used to move a table between attached databases, only to rename 
          251  +a table within the same database.
          252  +If the table being renamed has triggers or indices, then these remain
          253  +attached to the table after it has been renamed.
          254  +
          255  +</p><blockquote style="'background-color:" #ffd0d0;'="1">
          256  +<b>Compatibility Note:</b>
          257  +The behavior of ALTER TABLE when renaming a table was enhanced
          258  +in versions 3.25.0 (2018-09-15) and 3.26.0 (2018-12-01)
          259  +in order to carry the rename operation forward into triggers and
          260  +views that reference the renamed table.  This is considered an
          261  +improvement. Applications that depend on the older (and
          262  +arguably buggy) behavior can use the
          263  +<a href="pragma.html#pragma_legacy_alter_table">PRAGMA legacy_alter_table=ON</a> statement or the
          264  +<a href="c3ref/c_dbconfig_defensive.html#sqlitedbconfiglegacyaltertable">SQLITE_DBCONFIG_LEGACY_ALTER_TABLE</a> configuration parameter
          265  +on <a href="c3ref/db_config.html">sqlite3_db_config()</a> interface to make ALTER TABLE RENAME
          266  +behave as it did prior to version 3.25.0.
          267  +</blockquote>
          268  +
          269  +<p>
          270  +Beginning with release 3.25.0 (2018-09-15), references to the table
          271  +within trigger bodies and view definitions are also renamed.
          272  +</p>
          273  +
          274  +<p> Prior to version 3.26.0 (2018-12-01), FOREIGN KEY references
          275  +to a table that is renamed were only edited if the
          276  +<a href="pragma.html#pragma_foreign_keys">PRAGMA foreign_keys=ON</a>, or in other words if
          277  +<a href="foreignkeys.html">foreign key constraints</a> were begin enforced.  With
          278  +<a href="pragma.html#pragma_foreign_keys">PRAGMA foreign_keys=OFF</a>, FOREIGN KEY constraints would not be changed
          279  +when the table that the foreign key referred to (the "<a href="foreignkeys.html#parentchild">parent table</a>")
          280  +was renamed.  Beginning with version 3.26.0, FOREIGN KEY constraints
          281  +are always converted when a table is renamed, unless the
          282  +<a href="pragma.html#pragma_legacy_alter_table">PRAGMA legacy_alter_table=ON</a> setting is engaged.  The following
          283  +table summaries the difference:</p>
          284  +
          285  +<blockquote>
          286  +<table border="1" cellpadding="2" cellspacing="0">
          287  +<tr>
          288  +<th>PRAGMA foreign_keys
          289  +</th><th>PRAGMA legacy_alter_table
          290  +</th><th><a href="foreignkeys.html#parentchild">Parent Table</a>
          291  +references are updated
          292  +</th><th>SQLite version
          293  +</th></tr><tr><td align="center">Off</td><td align="center">Off</td><td align="center">No</td><td align="center">&lt; 3.26.0
          294  +</td></tr><tr><td align="center">Off</td><td align="center">Off</td><td align="center">Yes</td><td align="center">&gt;= 3.26.0
          295  +</td></tr><tr><td align="center">On</td><td align="center">Off</td><td align="center">Yes</td><td align="center">all
          296  +</td></tr><tr><td align="center">Off</td><td align="center">On</td><td align="center">No</td><td align="center">all
          297  +</td></tr><tr><td align="center">On</td><td align="center">On</td><td align="center">Yes</td><td align="center">all
          298  +</td></tr></table>
          299  +</blockquote>
          300  +
          301  +<a name="altertabmvcol"></a>
          302  +
          303  +<h1 id="alter_table_rename_column"><span>3. </span>ALTER TABLE RENAME COLUMN</h1>
          304  +
          305  +<p> The RENAME COLUMN TO syntax changes the
          306  +<span class='yyterm'>column-name</span> of table <span class='yyterm'>table-name</span>
          307  +into <span class='yyterm'>new-column-name</span>.  The column name is changed both
          308  +within the table definition itself and also within all indexes, triggers,
          309  +and views that reference the column.  If the column name change would
          310  +result in a semantic ambiguity in a trigger or view, then the RENAME
          311  +COLUMN fails with an error and no changes are applied.
          312  +
          313  +<a name="altertabaddcol"></a>
          314  +
          315  +</p><h1 id="alter_table_add_column"><span>4. </span>ALTER TABLE ADD COLUMN</h1>
          316  +
          317  +<p> The ADD COLUMN syntax
          318  +is used to add a new column to an existing table.
          319  +The new column is always appended to the end of the list of existing columns.
          320  +The <a href="syntax/column-def.html">column-def</a> rule defines the characteristics of the new column.
          321  +The new column may take any of the forms permissible in a <a href="lang_createtable.html">CREATE TABLE</a>
          322  +statement, with the following restrictions:
          323  +</p><ul>
          324  +<li>The column may not have a PRIMARY KEY or UNIQUE constraint.</li>
          325  +<li>The column may not have a default value of CURRENT_TIME, CURRENT_DATE, 
          326  +    CURRENT_TIMESTAMP, or an expression in parentheses.</li>
          327  +<li>If a NOT NULL constraint is specified, then the column must have a
          328  +    default value other than NULL.
          329  +</li><li>If <a href="foreignkeys.html">foreign key constraints</a> are <a href="pragma.html#pragma_foreign_keys">enabled</a> and
          330  +    a column with a <a href="syntax/foreign-key-clause.html">REFERENCES clause</a>
          331  +    is added, the column must have a default value of NULL.
          332  +</li><li>The column may not be <a href="gencol.html">GENERATED ALWAYS ... STORED</a>,
          333  +though VIRTUAL columns are allowed.
          334  +</li></ul>
          335  +
          336  +<p>Note also that when adding a <a href="lang_createtable.html#ckconst">CHECK constraint</a>, the CHECK constraint
          337  +is not tested against preexisting rows of the table.
          338  +This can result in a table that contains data that
          339  +is in violation of the CHECK constraint.  Future versions of SQLite might
          340  +change to validate CHECK constraints as they are added.</p>
          341  +
          342  +<p>The ALTER TABLE command works by modifying the SQL text of the schema
          343  +stored in the <a href="fileformat2.html#sqlite_master">sqlite_master table</a>.
          344  +No changes are made to table content.
          345  +Because of this,
          346  +the execution time of the ALTER TABLE command is independent of
          347  +the amount of data in the table.  The ALTER TABLE command runs as quickly
          348  +on a table with 10 million rows as it does on a table with 1 row.
          349  +</p>
          350  +
          351  +<p>After ADD COLUMN has been run on a database, that database will not
          352  +be readable by SQLite version 3.1.3 (2005-02-20) and earlier.</p>
          353  +
          354  +<a name="otheralter"></a>
          355  +
          356  +<h1 id="making_other_kinds_of_table_schema_changes"><span>5. </span>Making Other Kinds Of Table Schema Changes</h1>
          357  +
          358  +<p> The only schema altering commands directly supported by SQLite are the
          359  +"<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.  
          360  +However, applications
          361  +can make other arbitrary changes to the format of a table using a simple
          362  +sequence of operations.
          363  +The steps to make arbitrary changes to the schema design of some table X
          364  +are as follows:
          365  +
          366  +</p><ol>
          367  +<li><p>
          368  +If foreign key constraints are enabled, disable them using <a href="pragma.html#pragma_foreign_keys">PRAGMA foreign_keys=OFF</a>.
          369  +
          370  +</p></li><li><p>
          371  +Start a transaction.
          372  +
          373  +</p></li><li><p>
          374  +Remember the format of all indexes, triggers, and views associated with table X.
          375  +This information will be needed in step 8 below.  One way to do this is
          376  +to run a query like the following:
          377  +SELECT type, sql FROM sqlite_master WHERE tbl_name='X'.
          378  +
          379  +</p></li><li><p>
          380  +Use <a href="lang_createtable.html">CREATE TABLE</a> to construct a new table "new_X" that is in the desired
          381  +revised format of table X.  Make sure that the name "new_X" does not collide
          382  +with any existing table name, of course.
          383  +
          384  +</p></li><li><p>
          385  +Transfer content from X into new_X using a statement
          386  +like: INSERT INTO new_X SELECT ... FROM X.
          387  +
          388  +</p></li><li><p>
          389  +Drop the old table X:  <a href="lang_droptable.html">DROP TABLE X</a>.
          390  +
          391  +</p></li><li><p>
          392  +Change the name of new_X to X using: ALTER TABLE new_X RENAME TO X.
          393  +
          394  +</p></li><li><p>
          395  +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>
          396  +to reconstruct indexes, triggers, and views
          397  +associated with table X.  Perhaps use the old format of the triggers,
          398  +indexes, and views saved from step 3 above as a guide, making changes
          399  +as appropriate for the alteration.
          400  +
          401  +</p></li><li><p>If any views refer to table X in a way that is affected by the
          402  +schema change, then drop those views using <a href="lang_dropview.html">DROP VIEW</a> and recreate them
          403  +with whatever changes are necessary to accommodate the schema change
          404  +using <a href="lang_createview.html">CREATE VIEW</a>.
          405  +
          406  +</p></li><li><p>
          407  +If foreign key constraints were originally enabled
          408  +then run <a href="pragma.html#pragma_foreign_key_check">PRAGMA foreign_key_check</a> to verify that the schema
          409  +change did not break any foreign key constraints.
          410  +
          411  +
          412  +</p></li><li><p>
          413  +Commit the transaction started in step 2.
          414  +
          415  +</p></li><li><p>
          416  +If foreign keys constraints were originally enabled, reenable them now.
          417  +</p></li></ol>
          418  +
          419  +<a name="caution"></a>
          420  +
          421  +<p>
          422  +<b>Caution:</b>
          423  +Take care to follow the procedure above precisely.  The boxes below
          424  +summarize two procedures for modifying a table definition.  At first
          425  +glance, they both appear to accomplish the same thing.  However, the
          426  +procedure on the right does not always work, especially with the
          427  +enhanced <a href="lang_altertable.html#altertabrename">rename table</a> capabilities added by versions 3.25.0 and
          428  +3.26.0.  In the procedure on the right, the initial rename of the
          429  +table to a temporary name might corrupt references to that table in
          430  +triggers, views, and foreign key constraints.  The safe procedure on
          431  +the left constructs the revised table definition using a new temporary
          432  +name, then renames the table into its final name, which does not break
          433  +links.
          434  +
          435  +</p><center>
          436  +<table border="1" cellpadding="10" cellspacing="0">
          437  +<tr>
          438  +<td valign="top">
          439  +<ol>
          440  +<li>Create new table
          441  +</li><li>Copy data
          442  +</li><li>Drop old table
          443  +</li><li>Rename new into old
          444  +</li></ol>
          445  +</td><td valign="top">
          446  +<ol>
          447  +<li>Rename old table
          448  +</li><li>Create new table
          449  +</li><li>Copy data
          450  +</li><li>Drop old table
          451  +</li></ol>
          452  +</td></tr><tr>
          453  +<th>&uarr;<br>Correct
          454  +</th><th>&uarr;<br>Incorrect
          455  +</th></tr></table>
          456  +</center>
          457  +
          458  +<p>The 12-step <a href="lang_altertable.html#otheralter">generalized ALTER TABLE procedure</a>
          459  +above will work even if the
          460  +schema change causes the information stored in the table to change.
          461  +So the full 12-step procedure above is appropriate for dropping a column,
          462  +changing the order of columns, adding or removing a UNIQUE constraint
          463  +or PRIMARY KEY, adding CHECK or FOREIGN KEY or NOT NULL constraints,
          464  +or changing the datatype for a column, for example.  However, a simpler
          465  +and faster procedure can optionally be used for
          466  +some changes that do no affect the on-disk content in any way.
          467  +The following simpler procedure is appropriate for removing
          468  +CHECK or FOREIGN KEY or NOT NULL constraints,
          469  +or adding, removing, or changing default values on
          470  +a column.
          471  +
          472  +</p><ol>
          473  +<li><p> Start a transaction.
          474  +
          475  +</p></li><li><p> Run <a href="pragma.html#pragma_schema_version">PRAGMA schema_version</a> to determine the current schema
          476  +version number.  This number will be needed for step 6 below.
          477  +
          478  +</p></li><li><p> Activate schema editing using 
          479  +<a href="pragma.html#pragma_writable_schema">PRAGMA writable_schema=ON</a>.
          480  +
          481  +</p></li><li><p> Run an <a href="lang_update.html">UPDATE</a> statement to change the definition of table X
          482  +in the <a href="fileformat2.html#sqlite_master">sqlite_master table</a>: 
          483  +UPDATE sqlite_master SET sql=... WHERE type='table' AND name='X';
          484  +</p><p><em>Caution:</em>  Making a change to the sqlite_master table like this will
          485  +render the database corrupt and unreadable if the change contains
          486  +a syntax error.  It is suggested that careful testing of the UPDATE
          487  +statement be done on a separate blank database prior to using it on
          488  +a database containing important data.
          489  +
          490  +</p></li><li><p> If the change to table X also affects other tables or indexes or
          491  +triggers are views within schema, then run <a href="lang_update.html">UPDATE</a> statements to modify
          492  +those other tables indexes and views too.  For example, if the name of
          493  +a column changes, all FOREIGN KEY constraints, triggers, indexes, and
          494  +views that refer to that column must be modified.
          495  +</p><p><em>Caution:</em>  Once again, making changes to the sqlite_master 
          496  +table like this will render the database corrupt and unreadable if the 
          497  +change contains an error.  Carefully test this entire procedure
          498  +on a separate test database prior to using it on
          499  +a database containing important data and/or make backup copies of
          500  +important databases prior to running this procedure.
          501  +
          502  +</p></li><li><p> Increment the schema version number using
          503  +<a href="pragma.html#pragma_schema_version">PRAGMA schema_version=X</a> where X is one
          504  +more than the old schema version number found in step 2 above.
          505  +
          506  +</p></li><li><p> Disable schema editing using 
          507  +<a href="pragma.html#pragma_writable_schema">PRAGMA writable_schema=OFF</a>.
          508  +
          509  +</p></li><li><p> (Optional) Run <a href="pragma.html#pragma_integrity_check">PRAGMA integrity_check</a> to verify that the
          510  +schema changes did not damage the database.
          511  +
          512  +</p></li><li><p> Commit the transaction started on step 1 above.
          513  +</p></li></ol>
          514  +
          515  +<p>If some future version of SQLite adds new ALTER TABLE capabilities, 
          516  +those capabilities will very likely use one of the two procedures
          517  +outlined above.
          518  +
          519  +<a name="altertableishard"></a>
          520  +
          521  +</p><h1 id="why_alter_table_is_such_a_problem_for_sqlite"><span>6. </span>Why ALTER TABLE is such a problem for SQLite</h1>
          522  +
          523  +<p>Most SQL database engines store the schema already parsed into
          524  +various system tables.  On those database engines, ALTER TABLE merely 
          525  +has to make modifications to the corresponding system tables.
          526  +
          527  +</p><p>SQLite is different in that it stores the schema
          528  +in the <a href="fileformat2.html#sqlite_master">sqlite_master</a> table as the original text of the CREATE
          529  +statements that define the schema.  Hence ALTER TABLE needs
          530  +to revise the text of the CREATE statement.  Doing
          531  +so can be tricky for certain "creative" schema designs.
          532  +
          533  +</p><p>The SQLite approach of storing the schema as text has advantages
          534  +for an embedded relational database.  For one, it means that the
          535  +schema takes up less space in the database file.  This is important
          536  +since a common SQLite usage pattern is to have many small,
          537  +separate database files instead of putting everything in one
          538  +big global database file, which is the usual approach for client/server
          539  +database engines.
          540  +Since the schema is duplicated in each separate database file, it is
          541  +important to keep the schema representation compact.
          542  +
          543  +</p><p>Storing the schema as text rather than as parsed tables also
          544  +give flexibility to the implementation.  Since the internal parse
          545  +of the schema is regenerated each time the database is opened, the
          546  +internal representation of the schema can change from one release
          547  +to the next.  This is important, as sometimes new features require
          548  +enhancements to the internal schema representation.  Changing the
          549  +internal schema representation would be much more difficult if the
          550  +schema representation was exposed in the database file.  So, in other
          551  +words, storing the schema as text helps maintain backwards 
          552  +compatibility, and helps ensure that older database files can be
          553  +read and written by newer versions of SQLite.
          554  +
          555  +</p><p>Storing the schema a text also makes the 
          556  +<a href="fileformat2.html">SQLite database file format</a> easier to define, document, and 
          557  +understand. This helps make SQLite database files a
          558  +<a href="locrsf.html">recommended storage format</a> for long-term archiving of data.
          559  +
          560  +</p><p>The downside of storing schema a text is that it can make
          561  +the schema tricky to modify.  And for that reason, the ALTER TABLE
          562  +support in SQLite has traditionally lagged behind other SQL
          563  +database engines that store their schemas as parsed system tables
          564  +that are easier to modify.
          565  +
          566  +
          567  +
          568  +
          569  +</p>

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>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 || !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=fancy>
           95  +<div class=nosearch>
           96  +<div class="fancy_title">
           97  +ANALYZE
           98  +</div>
           99  +</div>
          100  +
          101  +
          102  +
          103  +
          104  +<h1 id="overview"><span>1. </span>Overview</h1>
          105  +
          106  +<p><b><a href="syntax/analyze-stmt.html">analyze-stmt:</a></b>
          107  +<button id='x1285' onclick='hideorshow("x1285","x1286")'>hide</button></p>
          108  + <div id='x1286' class='imgcontainer'>
          109  + <img alt="syntax diagram analyze-stmt" src="images/syntax/analyze-stmt.gif" />
          110  +</div>
          111  +
          112  +
          113  +<p> The ANALYZE command gathers statistics about tables and
          114  +indices and stores the collected information
          115  +in <a href="fileformat2.html#intschema">internal tables</a> of the database where the query optimizer can
          116  +access the information and use it to help make better query planning choices.
          117  +If no arguments are given, all attached databases are
          118  +analyzed.  If a schema name is given as the argument, then all tables
          119  +and indices in that one database are analyzed.  
          120  +If the argument is a table name, then only that table and the
          121  +indices associated with that table are analyzed.  If the argument
          122  +is an index name, then only that one index is analyzed.</p>
          123  +
          124  +<a name="req"></a>
          125  +
          126  +<h2 id="recommended_usage_pattern"><span>1.1. </span>Recommended usage pattern</h2>
          127  +
          128  +<p>Applications with long-lived databases that use complex
          129  +queries should consider running the following commands just prior
          130  +to closing each database connection:
          131  +
          132  +</p><div class="codeblock"><pre>PRAGMA analysis_limit=400;
          133  +PRAGMA optimize;
          134  +</pre></div>
          135  +
          136  +<p>The <a href="pragma.html#pragma_optimize">optimize pragma</a> is usually a no-op but it will occasionally
          137  +run ANALYZE if it seems like doing so will be useful to the query planner.
          138  +The <a href="pragma.html#pragma_analysis_limit">analysis_limit pragma</a> limits the scope of any ANALYZE command that
          139  +the <a href="pragma.html#pragma_optimize">optimize pragma</a> runs so that it does not consume too many CPU cycles.
          140  +The constant "400" can be adjusted as needed.  Values between 100 and
          141  +1000 work well for most applications.
          142  +
          143  +</p><h1 id="details"><span>2. </span>Details</h1>
          144  +
          145  +<p> The default implementation stores all statistics in a single
          146  +table named "<a href="fileformat2.html#stat1tab">sqlite_stat1</a>".  
          147  + If SQLite is compiled with the
          148  +<a href="compile.html#enable_stat4">SQLITE_ENABLE_STAT4</a> option, then additional histogram data is
          149  +collected and stored in <a href="fileformat2.html#stat4tab">sqlite_stat4</a>.
          150  +Older versions of SQLite would make use of the <a href="fileformat2.html#stat2tab">sqlite_stat2</a> table
          151  +or <a href="fileformat2.html#stat3tab">sqlite_stat3</a> table
          152  +when compiled with <a href="compile.html#enable_stat2">SQLITE_ENABLE_STAT2</a> or <a href="compile.html#enable_stat3">SQLITE_ENABLE_STAT3</a>,
          153  +but all recent versions of
          154  +SQLite ignore the sqlite_stat2 and sqlite_stat3 tables.
          155  +Future enhancements may create
          156  +additional <a href="fileformat2.html#intschema">internal tables</a> with the same name pattern except with
          157  +final digit larger than "4".
          158  +All of these tables are collectively referred to as "statistics tables".
          159  +</p>
          160  +
          161  +<p> The content of the statistics tables can be queried using <a href="lang_select.html">SELECT</a>
          162  +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.
          163  +The <a href="lang_droptable.html">DROP TABLE</a> command works on statistics tables
          164  +as of SQLite version 3.7.9. (2011-11-01)
          165  +The <a href="lang_altertable.html">ALTER TABLE</a> command does not work on statistics tables.
          166  +Appropriate care should be used when changing the content of the statistics
          167  +tables as invalid content can cause SQLite to select inefficient
          168  +query plans.  Generally speaking, one should not modify the content of
          169  +the statistics tables by any mechanism other than invoking the
          170  +ANALYZE command.  
          171  +See "<a href="optoverview.html#manctrl">Manual Control Of Query Plans Using SQLITE_STAT Tables</a>" for
          172  +further information.</p>
          173  +
          174  +<p> Statistics gathered by ANALYZE are not automatically updated as
          175  +the content of the database changes.  If the content of the database
          176  +changes significantly, or if the database schema changes, then one should
          177  +consider rerunning the ANALYZE command in order to update the statistics.</p>
          178  +
          179  +<p> The query planner loads the content of the statistics tables
          180  +into memory when the schema is read.  Hence, when an application
          181  +changes the statistics tables directly, SQLite will not immediately
          182  +notice the changes. An application
          183  +can force the query planner to reread the statistics tables by running
          184  +<b>ANALYZE sqlite_master</b>. </p>
          185  +
          186  +<a name="autoanalyze"></a>
          187  +
          188  +<h1 id="automatically_running_analyze"><span>3. </span>Automatically Running ANALYZE</h1>
          189  +
          190  +<p>The <a href="pragma.html#pragma_optimize">PRAGMA optimize</a> command will automatically run ANALYZE on individual
          191  +tables on an as-needed basis.  The recommended practice is for applications
          192  +to invoke the <a href="pragma.html#pragma_optimize">PRAGMA optimize</a> statement just before closing each database
          193  +connection.</p>
          194  +
          195  +<p>Each SQLite <a href="c3ref/sqlite3.html">database connection</a> records cases when the query planner would
          196  +benefit from having accurate results of ANALYZE at hand.  These records
          197  +are held in memory and accumulate over the life of a database connection.
          198  +The <a href="pragma.html#pragma_optimize">PRAGMA optimize</a> command looks at those records and runs ANALYZE on only
          199  +those tables for which new or updated ANALYZE data seems likely to be useful.
          200  +In most cases <a href="pragma.html#pragma_optimize">PRAGMA optimize</a> will not run ANALYZE, but it will occasionally
          201  +do so either for tables that have never before been analyzed, or for tables
          202  +that have grown significantly since they were last analyzed.</p>
          203  +
          204  +<p>Since the actions of <a href="pragma.html#pragma_optimize">PRAGMA optimize</a> are determined to some extent by
          205  +prior queries that have been evaluated on the same database connection, it
          206  +is recommended that <a href="pragma.html#pragma_optimize">PRAGMA optimize</a> be deferred until the database connection
          207  +is closing and has thus had an opportunity to accumulate as much usage information
          208  +as possible.  It is also reasonable to set a timer to run <a href="pragma.html#pragma_optimize">PRAGMA optimize</a>
          209  +every few hours, or every few days, for database connections that stay open
          210  +for a long time.</p>
          211  +
          212  +<p>Applications that desire more control can run <a href="pragma.html#pragma_optimize">PRAGMA optimize(0x03)</a> to 
          213  +obtain a list of ANALYZE commands that SQLite thinks are appropriate to run,
          214  +but without actually running those commands.  If the returned set is 
          215  +non-empty, the application can then make a decision about whether or not
          216  +to run the suggested ANALYZE commands, perhaps after prompting the user
          217  +for guidance.</p>
          218  +
          219  +<p>The <a href="pragma.html#pragma_optimize">PRAGMA optimize</a> command was first introduced with 
          220  +SQLite 3.18.0 (2017-03-28) and is a no-op for all prior releases
          221  +of SQLite.</p>
          222  +
          223  +<a name="approx"></a>
          224  +
          225  +<h1 id="approximate_analyze_for_large_databases"><span>4. </span>Approximate ANALYZE For Large Databases</h1>
          226  +
          227  +<p>By default, ANALYZE does a full scan of every index.  This can be slow for
          228  +large databases.  So beginning with SQLite version 3.32.0 (2020-05-22), the
          229  +<a href="pragma.html#pragma_analysis_limit">PRAGMA analysis_limit</a> command can be used to limit the amount of
          230  +scanning performed by ANALYZE, and thus help ANALYZE to run faster,
          231  +even on very large database files.  We call this running an
          232  +"approximate ANALYZE".
          233  +
          234  +</p><p>The recommended usage pattern for the <a href="pragma.html#pragma_analysis_limit">analysis_limit</a> pragma is
          235  +like this:
          236  +
          237  +</p><div class="codeblock"><pre>PRAGMA analysis_limit=1000;
          238  +</pre></div>
          239  +
          240  +<p>This pragma tells the ANALYZE command to start a full scan
          241  +of the index as it normally would.  But when the number of rows visited
          242  +reaches 1000 (or whatever other limit is specified by the pragma), the
          243  +ANALYZE command will begin taking actions to stop the scan.  If
          244  +the left-most column of the index has changed at least once during the
          245  +previous 1000 steps, then the analysis stops immediately.  But if the
          246  +left-most column has always been the same, then ANALYZE skips ahead to
          247  +the first entry with a different left-most column and reads an additional
          248  +1000 rows before terminating.
          249  +
          250  +</p><p>The details of the effects of the analysis limit described in the previous
          251  +paragraph are subject to change in future versions of SQLite.  But the
          252  +core idea will remain the same.  An analysis limit of N will strive to
          253  +limit the number of rows visited in each index to approximately N.
          254  +
          255  +</p><p>Values of N between 100 and 1000 are recommended.
          256  +Or, to disable the analysis limit, causing ANALYZE to do a
          257  +complete scan of each index, set the analysis limit to 0.  The default
          258  +value for the analysis limit is 0 for backwards compatibility.
          259  +
          260  +</p><p>The values placed in the sqlite_stat1 table by an approximate ANALYZE
          261  +are not exactly the same as what would be computed by an unrestricted 
          262  +analysis.  But they are usually close enough.  The index statistics in
          263  +the sqlite_stat1 table are approximations in any case, so the fact that
          264  +the results of an approximate ANALYZE are slightly different from
          265  +a traditional full scan ANALYZE has little practical impact.  It is
          266  +possible to construct a pathological case where an approximate ANALYZE
          267  +is noticeably inferior to a full-scan ANALYZE, but such cases rare in
          268  +real-world problems.
          269  +
          270  +</p><p>A good rule of thumb seems to be to always set "PRAGMA analysis_limit=N"
          271  +for N between 100 and 1000 prior to running either "ANALYZE" or
          272  +"<a href="pragma.html#pragma_optimize">PRAGMA optimize</a>".  The results are not quite as precise, but they
          273  +are precise enough, and the fact that the results are computed so much
          274  +faster means that developers are more likely to compute them.  An
          275  +approximate ANALYZE is better than not running ANALYZE at all.
          276  +
          277  +</p><h2 id="limitations_of_approximate_analyze"><span>4.1. </span>Limitations of approximate ANALYZE</h2>
          278  +
          279  +<p>The content in the sqlite_stat4 table cannot be computed with
          280  +anything less than a full scan.  Hence, if a non-zero analysis limit
          281  +is specified, the sqlite_stat4 table is not computed.
          282  +</p>

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>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 || !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=fancy>
           95  +<div class=nosearch>
           96  +<div class="fancy_title">
           97  +ATTACH DATABASE
           98  +</div>
           99  +</div>
          100  +
          101  +
          102  +
          103  +
          104  +<h1 id="overview"><span>1. </span>Overview</h1>
          105  +<p><b><a href="syntax/attach-stmt.html">attach-stmt:</a></b>
          106  +<button id='x1287' onclick='hideorshow("x1287","x1288")'>hide</button></p>
          107  + <div id='x1288' class='imgcontainer'>
          108  + <img alt="syntax diagram attach-stmt" src="images/syntax/attach-stmt.gif" />
          109  +<p><b><a href="syntax/expr.html">expr:</a></b>
          110  +<button id='x1289' onclick='hideorshow("x1289","x1290")'>show</button></p>
          111  + <div id='x1290' style='display:none;' class='imgcontainer'>
          112  + <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
          113  +<p><b><a href="syntax/filter-clause.html">filter-clause:</a></b>
          114  +<button id='x1291' onclick='hideorshow("x1291","x1292")'>show</button></p>
          115  + <div id='x1292' style='display:none;' class='imgcontainer'>
          116  + <img alt="syntax diagram filter-clause" src="images/syntax/filter-clause.gif" />
          117  +</div>
          118  +<p><b><a href="syntax/literal-value.html">literal-value:</a></b>
          119  +<button id='x1293' onclick='hideorshow("x1293","x1294")'>show</button></p>
          120  + <div id='x1294' style='display:none;' class='imgcontainer'>
          121  + <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
          122  +</div>
          123  +<p><b><a href="syntax/over-clause.html">over-clause:</a></b>
          124  +<button id='x1295' onclick='hideorshow("x1295","x1296")'>show</button></p>
          125  + <div id='x1296' style='display:none;' class='imgcontainer'>
          126  + <img alt="syntax diagram over-clause" src="images/syntax/over-clause.gif" />
          127  +<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
          128  +<button id='x1297' onclick='hideorshow("x1297","x1298")'>show</button></p>
          129  + <div id='x1298' style='display:none;' class='imgcontainer'>
          130  + <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
          131  +</div>
          132  +<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
          133  +<button id='x1299' onclick='hideorshow("x1299","x1300")'>show</button></p>
          134  + <div id='x1300' style='display:none;' class='imgcontainer'>
          135  + <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
          136  +</div>
          137  +</div>
          138  +<p><b><a href="syntax/raise-function.html">raise-function:</a></b>
          139  +<button id='x1301' onclick='hideorshow("x1301","x1302")'>show</button></p>
          140  + <div id='x1302' style='display:none;' class='imgcontainer'>
          141  + <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
          142  +</div>
          143  +<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
          144  +<button id='x1303' onclick='hideorshow("x1303","x1304")'>show</button></p>
          145  + <div id='x1304' 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='x1305' onclick='hideorshow("x1305","x1306")'>show</button></p>
          149  + <div id='x1306' 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='x1307' onclick='hideorshow("x1307","x1308")'>show</button></p>
          154  + <div id='x1308' 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='x1309' onclick='hideorshow("x1309","x1310")'>show</button></p>
          159  + <div id='x1310' 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='x1311' onclick='hideorshow("x1311","x1312")'>show</button></p>
          163  + <div id='x1312' 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='x1313' onclick='hideorshow("x1313","x1314")'>show</button></p>
          168  + <div id='x1314' 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='x1315' onclick='hideorshow("x1315","x1316")'>show</button></p>
          174  + <div id='x1316' 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='x1317' onclick='hideorshow("x1317","x1318")'>show</button></p>
          179  + <div id='x1318' 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='x1319' onclick='hideorshow("x1319","x1320")'>show</button></p>
          184  + <div id='x1320' 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='x1321' onclick='hideorshow("x1321","x1322")'>show</button></p>
          189  + <div id='x1322' 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='x1323' onclick='hideorshow("x1323","x1324")'>show</button></p>
          193  + <div id='x1324' 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/type-name.html">type-name:</a></b>
          199  +<button id='x1325' onclick='hideorshow("x1325","x1326")'>show</button></p>
          200  + <div id='x1326' style='display:none;' class='imgcontainer'>
          201  + <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
          202  +<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
          203  +<button id='x1327' onclick='hideorshow("x1327","x1328")'>show</button></p>
          204  + <div id='x1328' style='display:none;' class='imgcontainer'>
          205  + <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
          206  +</div>
          207  +</div>
          208  +</div>
          209  +</div>
          210  +
          211  +
          212  +<p> The ATTACH DATABASE statement adds another database 
          213  +file to the current <a href="c3ref/sqlite3.html">database connection</a>. 
          214  +Database files that were previously attached can be removed using
          215  +the <a href="lang_detach.html">DETACH DATABASE</a> command.
          216  +
          217  +</p><h1 id="details"><span>2. </span>Details</h1>
          218  +
          219  +<p>The filename for the database to be attached is the value of
          220  +the expression that occurs before the AS keyword.
          221  +The filename of the database follows the same semantics as the
          222  +filename argument to <a href="c3ref/open.html">sqlite3_open()</a> and <a href="c3ref/open.html">sqlite3_open_v2()</a>; the
          223  +special name "<a href="inmemorydb.html">:memory:</a>" results in an <a href="inmemorydb.html">in-memory database</a> and an
          224  +empty string results in a new temporary database.
          225  +The filename argument can be a <a href="uri.html">URI filename</a> if URI filename processing
          226  +is enable on the database connection.  The default behavior is for
          227  +URI filenames to be disabled, however that might change in a future release
          228  +of SQLite, so application developers are advised to plan accordingly.
          229  +
          230  +</p><p>The name that occurs after the AS keyword is the name of the database
          231  +used internally by SQLite.
          232  +The schema-names 'main' and 
          233  +'temp' refer to the main database and the database used for 
          234  +temporary tables.  The main and temp databases cannot be attached or
          235  +detached.</p>
          236  +
          237  +<p> Tables in an attached database can be referred to using the syntax 
          238  +<i>schema-name.table-name</i>.  If the name of the table is unique
          239  +across all attached databases and the main and temp databases, then the
          240  +<i>schema-name</i> prefix is not required.  If two or more tables in
          241  +different databases have the same name and the 
          242  +<i>schema-name</i> prefix is not used on a table reference, then the
          243  +table chosen is the one in the database that was least recently attached.</p>
          244  +
          245  +<p>
          246  +Transactions involving multiple attached databases are atomic,
          247  +assuming that the main database is not "<a href="inmemorydb.html">:memory:</a>" and the 
          248  +<a href="pragma.html#pragma_journal_mode">journal_mode</a> is not <a href="wal.html">WAL</a>.  If the main
          249  +database is ":memory:" or if the journal_mode is WAL, then 
          250  +transactions continue to be atomic within each individual
          251  +database file. But if the host computer crashes in the middle
          252  +of a <a href="lang_transaction.html">COMMIT</a> where two or more database files are updated,
          253  +some of those files might get the changes where others
          254  +might not.
          255  +</p>
          256  +
          257  +<p> There is a limit, set using <a href="c3ref/limit.html">sqlite3_limit()</a> and 
          258  +<a href="c3ref/c_limit_attached.html#sqlitelimitattached">SQLITE_LIMIT_ATTACHED</a>, to the number of databases that can be
          259  +simultaneously attached to a single database connection.</p>
          260  +

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>SQL Comment Syntax</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 || !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=fancy>
           95  +<div class=nosearch>
           96  +<div class="fancy_title">
           97  +SQL Comment Syntax
           98  +</div>
           99  +</div>
          100  +
          101  +
          102  +
          103  +
          104  +
          105  +<p><b><a href="syntax/comment-syntax.html">comment-syntax:</a></b>
          106  +<button id='x1329' onclick='hideorshow("x1329","x1330")'>hide</button></p>
          107  + <div id='x1330' class='imgcontainer'>
          108  + <img alt="syntax diagram comment-syntax" src="images/syntax/comment-syntax.gif" />
          109  +</div>
          110  +
          111  +
          112  +<p>Comments are not SQL commands, but can occur within the text of
          113  +SQL queries passed to <a href="c3ref/prepare.html">sqlite3_prepare_v2()</a> and related interfaces.
          114  +Comments are treated as whitespace by the parser.
          115  +Comments can begin anywhere whitespace 
          116  +can be found, including inside expressions that span multiple lines.
          117  +</p>
          118  +
          119  +<p>SQL comments begin with two consecutive "-" characters (ASCII 0x2d)
          120  +and extend up to and including the next newline character (ASCII 0x0a)
          121  +or until the end of input, whichever comes first.</p>
          122  +
          123  +<p>C-style comments begin
          124  +with "/*" and extend up to and including the next "*/" character pair
          125  +or until the end of input, whichever comes first.  C-style comments
          126  +can span multiple lines. </p>
          127  +
          128  +<p>Comments can appear anywhere whitespace can occur,
          129  +including inside expressions and in the middle of other SQL statements.
          130  +Comments do not nest.
          131  +</p>
          132  +

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>The 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 || !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=fancy>
           95  +<div class=nosearch>
           96  +<div class="fancy_title">
           97  +The ON CONFLICT Clause
           98  +</div>
           99  +</div>
          100  +
          101  +
          102  +
          103  +
          104  +<p><b><a href="syntax/conflict-clause.html">conflict-clause:</a></b>
          105  +<button id='x1331' onclick='hideorshow("x1331","x1332")'>hide</button></p>
          106  + <div id='x1332' class='imgcontainer'>
          107  + <img alt="syntax diagram conflict-clause" src="images/syntax/conflict-clause.gif" />
          108  +</div>
          109  +
          110  +
          111  +<p>The ON CONFLICT clause is a
          112  +non-standard extension specific to SQLite 
          113  +that can appear in many other SQL commands.
          114  +It is given its own section in this document because it is not
          115  +part of standard SQL and therefore might not be familiar.</p>
          116  +
          117  +<p>The ON CONFLICT clause described here has been a part of
          118  +SQLite since before version 3.0.0 (2004-06-18).  The phrase
          119  +"ON&nbsp;CONFLICT" is also part of <a href="lang_upsert.html">UPSERT</a>, which is an extension
          120  +to <a href="lang_insert.html">INSERT</a> added in version 3.24.0 (2018-06-04).  Do not
          121  +confuse these two separate uses of the "ON&nbsp;CONFLICT" phrase.
          122  +
          123  +</p><p>The syntax for the ON CONFLICT clause is as shown above for
          124  +the CREATE TABLE command.  For the INSERT and
          125  +UPDATE commands, the keywords "ON CONFLICT" are replaced by "OR" so that
          126  +the syntax reads more naturally.  For example, instead of
          127  +"INSERT ON CONFLICT IGNORE" we have "INSERT OR IGNORE".
          128  +The keywords change but the meaning of the clause is the same
          129  +either way.</p>
          130  +
          131  +<p>The ON CONFLICT clause applies to <a href="lang_createtable.html#uniqueconst">UNIQUE</a>, <a href="lang_createtable.html#notnullconst">NOT NULL</a>,
          132  +<a href="lang_createtable.html#ckconst">CHECK</a>, and <a href="lang_createtable.html#primkeyconst">PRIMARY KEY</a> constraints.
          133  +The ON CONFLICT algorithm does not
          134  +apply to <a href="foreignkeys.html">FOREIGN KEY constraints</a>.
          135  +There are five conflict resolution algorithm choices:
          136  +ROLLBACK, ABORT, FAIL, IGNORE, and REPLACE.
          137  +The default conflict resolution algorithm is ABORT.  This
          138  +is what they mean:</p>
          139  +
          140  +<dl>
          141  +<dt><b>ROLLBACK</b></dt>
          142  +<dd><p> When an applicable constraint violation occurs, the ROLLBACK
          143  +resolution algorithm aborts the current SQL statement with
          144  +an SQLITE_CONSTRAINT error and rolls back the current transaction.
          145  +If no transaction is
          146  +active (other than the implied transaction that is created on every
          147  +command) then the ROLLBACK resolution algorithm works the same as the
          148  +ABORT algorithm.</p></dd>
          149  +
          150  +<dt><b>ABORT</b></dt>
          151  +<dd><p> When an applicable constraint violation occurs, the ABORT
          152  +resolution algorithm aborts the current SQL statement
          153  +with an SQLITE_CONSTRAINT error and backs out any changes
          154  +made by the current SQL statement; but changes caused
          155  +by prior SQL statements within the same transaction are preserved and the
          156  +transaction remains active.
          157  +This is the default behavior and the behavior specified by the SQL
          158  +standard.</p></dd>
          159  +
          160  +<dt><b>FAIL</b></dt>
          161  +<dd><p> When an applicable constraint violation occurs, the FAIL
          162  +resolution algorithm aborts the current SQL statement with an
          163  +SQLITE_CONSTRAINT error.  But the FAIL resolution does not
          164  +back out prior changes of the SQL statement that failed nor does
          165  +it end the transaction.
          166  +For example, if an UPDATE
          167  +statement encountered a constraint violation on the 100th row that
          168  +it attempts to update, then the first 99 row changes are preserved
          169  +but changes to rows 100 and beyond never occur.</p>
          170  +
          171  +<p>The FAIL behavior only works for uniqueness, NOT NULL, and CHECK 
          172  +constraints.  A <a href="foreignkeys.html">foreign key constraint</a> violation causes an ABORT.
          173  +</p></dd>
          174  +
          175  +<dt><b>IGNORE</b></dt>
          176  +<dd><p> When an applicable constraint violation occurs, 
          177  +the IGNORE resolution algorithm skips the one row that contains
          178  +the constraint violation and continues processing subsequent rows
          179  +of the SQL statement as if nothing went wrong.
          180  +Other rows before and after the row that
          181  +contained the constraint violation are inserted or updated
          182  +normally. No error is returned for uniqueness, NOT NULL, and
          183  +UNIQUE constraint errors when the IGNORE conflict resolution
          184  +algorithm is used.  However, the IGNORE conflict resolution
          185  +algorithm works like ABORT for <a href="foreignkeys.html">foreign key constraint</a> errors.
          186  +</p>
          187  +</dd>
          188  +
          189  +<dt><b>REPLACE</b></dt>
          190  +<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, 
          191  +the REPLACE algorithm
          192  +deletes pre-existing rows that are causing the constraint violation
          193  +prior to inserting or updating the current row and the command continues 
          194  +executing normally.
          195  +If a <a href="lang_createtable.html#notnullconst">NOT NULL</a> constraint violation occurs, the REPLACE conflict
          196  +resolution replaces the NULL value with
          197  +the default value for that column, or if the column has no default
          198  +value, then the ABORT algorithm is used.
          199  +If a <a href="lang_createtable.html#ckconst">CHECK constraint</a> or <a href="foreignkeys.html">foreign key constraint</a> violation occurs, 
          200  +the REPLACE conflict resolution algorithm works like ABORT.</p>
          201  +
          202  +<p>When the REPLACE conflict resolution strategy deletes rows in order to
          203  +satisfy a constraint, <a href="lang_createtrigger.html">delete triggers</a> fire if and only if
          204  +<a href="pragma.html#pragma_recursive_triggers">recursive triggers</a> are enabled.</p>
          205  +
          206  +<p>The <a href="c3ref/update_hook.html">update hook</a> is not invoked for rows that
          207  +are deleted by the REPLACE conflict resolution strategy.  Nor does
          208  +REPLACE increment the <a href="c3ref/changes.html">change counter</a>.
          209  +The exceptional behaviors defined in this paragraph might change 
          210  +in a future release.</p>
          211  +</dd></dl>
          212  +
          213  +<p>The algorithm specified in the OR clause of an INSERT or UPDATE
          214  +overrides any algorithm specified in a CREATE TABLE.
          215  +If no algorithm is specified anywhere, the ABORT algorithm is used.</p>
          216  +

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>Built-In Scalar SQL 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 || !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=fancy>
           95  +<div class=nosearch>
           96  +<div class="fancy_title">
           97  +Built-In Scalar SQL Functions
           98  +</div>
           99  +</div>
          100  +
          101  +
          102  +
          103  +
          104  +
          105  +<h1 id="overview"><span>1. </span>Overview</h1>
          106  +
          107  +<p>The core functions shown below are available by default. 
          108  +<a href="lang_datefunc.html">Date &amp; Time functions</a>,
          109  +<a href="lang_aggfunc.html">aggregate functions</a>,
          110  +<a href="windowfunctions.html#biwinfunc">window functions</a>, and
          111  +<a href="json1.html">JSON functions</a> are documented separately.  An
          112  +application may define additional
          113  +functions written in C and added to the database engine using
          114  +the <a href="c3ref/create_function.html">sqlite3_create_function()</a> API.</p>
          115  +
          116  +<p>
          117  +<div class='columns' style='columns: 15em auto;'>
          118  +<ul style='padding-top:0;'>
          119  +<li><a href='lang_corefunc.html#abs'>abs(X)</a></li>
          120  +<li><a href='lang_corefunc.html#changes'>changes()</a></li>
          121  +<li><a href='lang_corefunc.html#char'>char(X1,X2,...,XN)</a></li>
          122  +<li><a href='lang_corefunc.html#coalesce'>coalesce(X,Y,...)</a></li>
          123  +<li><a href='lang_corefunc.html#glob'>glob(X,Y)</a></li>
          124  +<li><a href='lang_corefunc.html#hex'>hex(X)</a></li>
          125  +<li><a href='lang_corefunc.html#ifnull'>ifnull(X,Y)</a></li>
          126  +<li><a href='lang_corefunc.html#iif'>iif(X,Y,Z)</a></li>
          127  +<li><a href='lang_corefunc.html#instr'>instr(X,Y)</a></li>
          128  +<li><a href='lang_corefunc.html#last_insert_rowid'>last_insert_rowid()</a></li>
          129  +<li><a href='lang_corefunc.html#length'>length(X)</a></li>
          130  +<li><a href='lang_corefunc.html#like'>like(X,Y)</a></li>
          131  +<li><a href='lang_corefunc.html#like'>like(X,Y,Z)</a></li>
          132  +<li><a href='lang_corefunc.html#likelihood'>likelihood(X,Y)</a></li>
          133  +<li><a href='lang_corefunc.html#likely'>likely(X)</a></li>
          134  +<li><a href='lang_corefunc.html#load_extension'>load_extension(X)</a></li>
          135  +<li><a href='lang_corefunc.html#load_extension'>load_extension(X,Y)</a></li>
          136  +<li><a href='lang_corefunc.html#lower'>lower(X)</a></li>
          137  +<li><a href='lang_corefunc.html#ltrim'>ltrim(X)</a></li>
          138  +<li><a href='lang_corefunc.html#ltrim'>ltrim(X,Y)</a></li>
          139  +<li><a href='lang_corefunc.html#maxoreunc'>max(X,Y,...)</a></li>
          140  +<li><a href='lang_corefunc.html#minoreunc'>min(X,Y,...)</a></li>
          141  +<li><a href='lang_corefunc.html#nullif'>nullif(X,Y)</a></li>
          142  +<li><a href='lang_corefunc.html#printf'>printf(FORMAT,...)</a></li>
          143  +<li><a href='lang_corefunc.html#quote'>quote(X)</a></li>
          144  +<li><a href='lang_corefunc.html#random'>random()</a></li>
          145  +<li><a href='lang_corefunc.html#randomblob'>randomblob(N)</a></li>
          146  +<li><a href='lang_corefunc.html#replace'>replace(X,Y,Z)</a></li>
          147  +<li><a href='lang_corefunc.html#round'>round(X)</a></li>
          148  +<li><a href='lang_corefunc.html#round'>round(X,Y)</a></li>
          149  +<li><a href='lang_corefunc.html#rtrim'>rtrim(X)</a></li>
          150  +<li><a href='lang_corefunc.html#rtrim'>rtrim(X,Y)</a></li>
          151  +<li><a href='lang_corefunc.html#soundex'>soundex(X)</a></li>
          152  +<li><a href='lang_corefunc.html#sqlite_compileoption_get'>sqlite_compileoption_get(N)</a></li>
          153  +<li><a href='lang_corefunc.html#sqlite_compileoption_used'>sqlite_compileoption_used(X)</a></li>
          154  +<li><a href='lang_corefunc.html#sqlite_offset'>sqlite_offset(X)</a></li>
          155  +<li><a href='lang_corefunc.html#sqlite_source_id'>sqlite_source_id()</a></li>
          156  +<li><a href='lang_corefunc.html#sqlite_version'>sqlite_version()</a></li>
          157  +<li><a href='lang_corefunc.html#substr'>substr(X,Y)</a></li>
          158  +<li><a href='lang_corefunc.html#substr'>substr(X,Y,Z)</a></li>
          159  +<li><a href='lang_corefunc.html#total_changes'>total_changes()</a></li>
          160  +<li><a href='lang_corefunc.html#trim'>trim(X)</a></li>
          161  +<li><a href='lang_corefunc.html#trim'>trim(X,Y)</a></li>
          162  +<li><a href='lang_corefunc.html#typeof'>typeof(X)</a></li>
          163  +<li><a href='lang_corefunc.html#unicode'>unicode(X)</a></li>
          164  +<li><a href='lang_corefunc.html#unlikely'>unlikely(X)</a></li>
          165  +<li><a href='lang_corefunc.html#upper'>upper(X)</a></li>
          166  +<li><a href='lang_corefunc.html#zeroblob'>zeroblob(N)</a></li>
          167  +</ul>
          168  +</div>
          169  +
          170  +
          171  +<h1 id="descriptions_of_built_in_scalar_sql_functions"><span>2. </span>Descriptions of built-in scalar SQL functions</h1>
          172  +<dl>
          173  +
          174  +<a name="abs"></a>
          175  +<dt><p><b>abs(<i>X</i>)</b></dt><dd><p>
          176  +  The abs(X) function returns the absolute value of the numeric
          177  +  argument X.  Abs(X) returns NULL if X is NULL. 
          178  +  Abs(X) returns 0.0 if X is a string or blob
          179  +  that cannot be converted to a numeric value.  If X is the 
          180  +  integer -9223372036854775808 then abs(X) throws an integer overflow
          181  +  error since there is no equivalent positive 64-bit two complement value.
          182  +</dd>
          183  +<a name="changes"></a>
          184  +<dt><p><b>changes()</b></dt><dd><p>
          185  +  The changes() function returns the number of database rows that were changed
          186  +  or inserted or deleted by the most recently completed INSERT, DELETE,
          187  +  or UPDATE statement, exclusive of statements in lower-level triggers.
          188  +  The changes() SQL function is a wrapper around the <a href="c3ref/changes.html">sqlite3_changes()</a>
          189  +  C/C++ function and hence follows the same rules for counting changes.
          190  +</dd>
          191  +<a name="char"></a>
          192  +<dt><p><b>char(<i>X1</i>,<i>X2</i>,...,<i>XN</i>)</b></dt><dd><p>
          193  +  The char(X1,X2,...,XN) function returns a string composed of characters having the
          194  +   unicode code point values of integers X1 through XN, respectively.
          195  +</dd>
          196  +<a name="coalesce"></a>
          197  +<dt><p><b>coalesce(<i>X</i>,<i>Y</i>,...)</b></dt><dd><p>
          198  +  The coalesce() function returns a copy of its first non-NULL argument, or
          199  +  NULL if all arguments are NULL.  Coalesce() must have at least 
          200  +  2 arguments.
          201  +</dd>
          202  +<a name="glob"></a>
          203  +<dt><p><b>glob(<i>X</i>,<i>Y</i>)</b></dt><dd><p>
          204  +  The glob(X,Y) function is equivalent to the
          205  +  expression "<b>Y GLOB X</b>".
          206  +  Note that the X and Y arguments are reversed in the glob() function
          207  +  relative to the infix <a href="lang_expr.html#glob">GLOB</a> operator.  Y is the string and X is the
          208  +  pattern.  So, for example, the following expressions are equivalent:
          209  +  <blockquote><pre>
          210  +     name GLOB '*helium*'
          211  +     glob('*helium*',name)
          212  +  </pre></blockquote>
          213  +  <p>If the <a href="c3ref/create_function.html">sqlite3_create_function()</a> interface is used to
          214  +  override the glob(X,Y) function with an alternative implementation then
          215  +  the <a href="lang_expr.html#glob">GLOB</a> operator will invoke the alternative implementation.
          216  +</dd>
          217  +<a name="hex"></a>
          218  +<dt><p><b>hex(<i>X</i>)</b></dt><dd><p>
          219  +  The hex() function interprets its argument as a BLOB and returns
          220  +  a string which is the upper-case hexadecimal rendering of the content of
          221  +  that blob.
          222  +</dd>
          223  +<a name="ifnull"></a>
          224  +<dt><p><b>ifnull(<i>X</i>,<i>Y</i>)</b></dt><dd><p>
          225  +  The ifnull() function returns a copy of its first non-NULL argument, or
          226  +  NULL if both arguments are NULL.  Ifnull() must have exactly 2 arguments.
          227  +  The ifnull() function is equivalent to <a href="lang_corefunc.html#coalesce">coalesce()</a> with two arguments.
          228  +</dd>
          229  +<a name="iif"></a>
          230  +<dt><p><b>iif(<i>X</i>,<i>Y</i>,<i>Z</i>)</b></dt><dd><p>
          231  +  The iif(X,Y,Z) function returns the value Y if X is true, and Z otherwise.
          232  +  The iif(X,Y,Z) function is logically equivalent to and generates the same
          233  +  <a href="opcode.html">bytecode</a> as the <a href="lang_expr.html#case">CASE expression</a> "CASE WHEN X THEN Y ELSE Z END".
          234  +</dd>
          235  +<a name="instr"></a>
          236  +<dt><p><b>instr(<i>X</i>,<i>Y</i>)</b></dt><dd><p>
          237  +  The instr(X,Y) function finds the first occurrence of string Y within 
          238  +  string X and returns the number of prior characters plus 1, or 0 if
          239  +  Y is nowhere found within X.
          240  +  Or, if X and Y are both BLOBs, then instr(X,Y) returns one
          241  +  more than the number bytes prior to the first occurrence of Y, or 0 if
          242  +  Y does not occur anywhere within X.
          243  +  If both arguments X and Y to instr(X,Y) are non-NULL and are not BLOBs
          244  +  then both are interpreted as strings.
          245  +  If either X or Y are NULL in instr(X,Y) then the result is NULL.
          246  +</dd>
          247  +<a name="last_insert_rowid"></a>
          248  +<dt><p><b>last_insert_rowid()</b></dt><dd><p>
          249  +  The last_insert_rowid() function returns the <a href="lang_createtable.html#rowid">ROWID</a>
          250  +  of the last row insert from the database connection which invoked the
          251  +  function.
          252  +  The last_insert_rowid() SQL function is a wrapper around the
          253  +  <a href="c3ref/last_insert_rowid.html">sqlite3_last_insert_rowid()</a> C/C++ interface function.
          254  +</dd>
          255  +<a name="length"></a>
          256  +<dt><p><b>length(<i>X</i>)</b></dt><dd><p>
          257  +  For a string value X, the length(X) function returns the number of 
          258  +  characters (not bytes) in X prior to the first NUL character.
          259  +  Since SQLite strings do not normally contain NUL characters, the length(X)
          260  +  function will usually return the total number of characters in the string X.
          261  +  For a blob value X, length(X) returns the number of bytes in the blob.
          262  +  If X is NULL then length(X) is NULL.
          263  +  If X is numeric then length(X) returns the length of a string
          264  +  representation of X.
          265  +</dd>
          266  +<a name="like"></a>
          267  +<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>
          268  +  The like() function is used to implement the
          269  +  "<b>Y LIKE X &#91;ESCAPE Z&#93;</b>" expression. 
          270  +  If the optional ESCAPE clause is present, then the
          271  +  like() function is invoked with three arguments.  Otherwise, it is
          272  +  invoked with two arguments only. Note that the X and Y parameters are
          273  +  reversed in the like() function relative to the infix <a href="lang_expr.html#like">LIKE</a> operator.
          274  +  X is the pattern and Y is the string to match against that pattern.
          275  +  Hence, the following expressions are equivalent:
          276  +  <blockquote><pre>
          277  +     name LIKE '%neon%'
          278  +     like('%neon%',name)
          279  +  </pre></blockquote>
          280  +  <p>The <a href="c3ref/create_function.html">sqlite3_create_function()</a> interface can be used to override the
          281  +  like() function and thereby change the operation of the
          282  +  <a href="lang_expr.html#like">LIKE</a> operator.  When overriding the like() function, it may be important
          283  +  to override both the two and three argument versions of the like() 
          284  +  function. Otherwise, different code may be called to implement the
          285  +  <a href="lang_expr.html#like">LIKE</a> operator depending on whether or not an ESCAPE clause was 
          286  +  specified.
          287  +</dd>
          288  +<a name="likelihood"></a>
          289  +<dt><p><b>likelihood(<i>X</i>,<i>Y</i>)</b></dt><dd><p>
          290  +  The likelihood(X,Y) function returns argument X unchanged.
          291  +  The value Y in likelihood(X,Y) must be a floating point constant
          292  +  between 0.0 and 1.0, inclusive.
          293  +  The likelihood(X) function is a no-op that the code generator
          294  +  optimizes away so that it consumes no CPU cycles during run-time
          295  +  (that is, during calls to <a href="c3ref/step.html">sqlite3_step()</a>).
          296  +  The purpose of the likelihood(X,Y) function is to provide a hint
          297  +  to the query planner that the argument X is a boolean that is
          298  +  true with a probability of approximately Y.
          299  +  The <a href="lang_corefunc.html#unlikely">unlikely(X)</a> function is short-hand for likelihood(X,0.0625).
          300  +  The <a href="lang_corefunc.html#likely">likely(X)</a> function is short-hand for likelihood(X,0.9375).
          301  +</dd>
          302  +<a name="likely"></a>
          303  +<dt><p><b>likely(<i>X</i>)</b></dt><dd><p>
          304  +  The likely(X) function returns the argument X unchanged.
          305  +  The likely(X) function is a no-op that the code generator
          306  +  optimizes away so that it consumes no CPU cycles at
          307  +  run-time (that is, during calls to <a href="c3ref/step.html">sqlite3_step()</a>).
          308  +  The purpose of the likely(X) function is to provide a hint
          309  +  to the query planner that the argument X is a boolean value
          310  +  that is usually true. The likely(X) function is equivalent
          311  +  to <a href="lang_corefunc.html#likelihood">likelihood</a>(X,0.9375). See also: <a href="lang_corefunc.html#unlikely">unlikely(X)</a>.
          312  +</dd>
          313  +<a name="load_extension"></a>
          314  +<dt><p><b>load_extension(<i>X</i>)<br />load_extension(<i>X</i>,<i>Y</i>)</b></dt><dd><p>
          315  +  The load_extension(X,Y) function loads <a href="loadext.html">SQLite extensions</a> out of the shared
          316  +  library file named X using the entry point Y.  The result of load_extension()
          317  +  is always a NULL.  If Y is omitted then the default entry point name is used.
          318  +  The load_extension() function raises an exception if the extension fails to
          319  +  load or initialize correctly.
          320  +
          321  +  <p>The load_extension() function will fail if the extension attempts to 
          322  +  modify or delete an SQL function or collating sequence.  The
          323  +  extension can add new functions or collating sequences, but cannot
          324  +  modify or delete existing functions or collating sequences because
          325  +  those functions and/or collating sequences might be used elsewhere
          326  +  in the currently running SQL statement.  To load an extension that
          327  +  changes or deletes functions or collating sequences, use the
          328  +  <a href="c3ref/load_extension.html">sqlite3_load_extension()</a> C-language API.</p>
          329  +
          330  +  <p>For security reasons, extension loaded is turned off by default and must
          331  +  be enabled by a prior call to <a href="c3ref/enable_load_extension.html">sqlite3_enable_load_extension()</a>.</p>
          332  +</dd>
          333  +<a name="lower"></a>
          334  +<dt><p><b>lower(<i>X</i>)</b></dt><dd><p>
          335  +  The lower(X) function returns a copy of string X with all ASCII characters
          336  +  converted to lower case.  The default built-in lower() function works
          337  +  for ASCII characters only.  To do case conversions on non-ASCII
          338  +  characters, load the ICU extension.
          339  +</dd>
          340  +<a name="ltrim"></a>
          341  +<dt><p><b>ltrim(<i>X</i>)<br />ltrim(<i>X</i>,<i>Y</i>)</b></dt><dd><p>
          342  +  The ltrim(X,Y) function returns a string formed by removing any and all
          343  +  characters that appear in Y from the left side of X.
          344  +  If the Y argument is omitted, ltrim(X) removes spaces from the left side
          345  +  of X.
          346  +</dd>
          347  +<a name="maxoreunc"></a>
          348  +<dt><p><b>max(<i>X</i>,<i>Y</i>,...)</b></dt><dd><p>
          349  +  The multi-argument max() function returns the argument with the 
          350  +  maximum value, or return NULL if any argument is NULL. 
          351  +  The multi-argument max() function searches its arguments from left to right
          352  +  for an argument that defines a collating function and uses that collating
          353  +  function for all string comparisons.  If none of the arguments to max()
          354  +  define a collating function, then the BINARY collating function is used.
          355  +  Note that <b>max()</b> is a simple function when
          356  +  it has 2 or more arguments but operates as an
          357  +  <a href="lang_aggfunc.html#maxggunc">aggregate function</a> if given only a single argument.
          358  +</dd>
          359  +<a name="minoreunc"></a>
          360  +<dt><p><b>min(<i>X</i>,<i>Y</i>,...)</b></dt><dd><p>
          361  +  The multi-argument min() function returns the argument with the
          362  +  minimum value.
          363  +  The multi-argument min() function searches its arguments from left to right
          364  +  for an argument that defines a collating function and uses that collating
          365  +  function for all string comparisons.  If none of the arguments to min()
          366  +  define a collating function, then the BINARY collating function is used.
          367  +  Note that <b>min()</b> is a simple function when
          368  +  it has 2 or more arguments but operates as an 
          369  +  <a href="lang_aggfunc.html#minggunc">aggregate function</a> if given
          370  +  only a single argument.
          371  +</dd>
          372  +<a name="nullif"></a>
          373  +<dt><p><b>nullif(<i>X</i>,<i>Y</i>)</b></dt><dd><p>
          374  +  The nullif(X,Y) function returns its first argument if the arguments are
          375  +  different and NULL if the arguments are the same.  The nullif(X,Y) function
          376  +  searches its arguments from left to right for an argument that defines a
          377  +  collating function and uses that collating function for all string
          378  +  comparisons.  If neither argument to nullif() defines a collating function
          379  +  then the BINARY is used.
          380  +</dd>
          381  +<a name="printf"></a>
          382  +<dt><p><b>printf(<i>FORMAT</i>,...)</b></dt><dd><p>
          383  +  The printf(FORMAT,...) SQL function works like the <a href="c3ref/mprintf.html">sqlite3_mprintf()</a> C-language
          384  +  function and the printf() function from the standard C library.
          385  +  The first argument is a format string that specifies how to construct the output
          386  +  string using values taken from subsequent arguments.  If the FORMAT argument is
          387  +  missing or NULL then the result is NULL.  The %n format is silently ignored and
          388  +  does not consume an argument.  The %p format is an alias for %X.  The %z format
          389  +  is interchangeable with %s.  If there are too few arguments in the argument list,
          390  +  missing arguments are assumed to have a NULL value, which is translated into
          391  +  0 or 0.0 for numeric formats or an empty string for %s.  See the
          392  +  <a href="printf.html">built-in printf()</a> documentation for additional information.
          393  +</dd>
          394  +<a name="quote"></a>
          395  +<dt><p><b>quote(<i>X</i>)</b></dt><dd><p>
          396  +  The quote(X) function returns the text of an SQL literal which
          397  +  is the value of its argument suitable for inclusion into an SQL statement.
          398  +  Strings are surrounded by single-quotes with escapes on interior quotes
          399  +  as needed.  BLOBs are encoded as hexadecimal literals.
          400  +  Strings with embedded NUL characters cannot be represented as string
          401  +  literals in SQL and hence the returned string literal is truncated prior
          402  +  to the first NUL.
          403  +</dd>
          404  +<a name="random"></a>
          405  +<dt><p><b>random()</b></dt><dd><p>
          406  +  The random() function returns a pseudo-random integer
          407  +  between -9223372036854775808 and +9223372036854775807.
          408  +</dd>
          409  +<a name="randomblob"></a>
          410  +<dt><p><b>randomblob(<i>N</i>)</b></dt><dd><p>
          411  +  The randomblob(N) function return an N-byte blob containing pseudo-random
          412  +  bytes. If N is less than 1 then a 1-byte random blob is returned.
          413  +
          414  +  <p>Hint:  applications can generate globally unique identifiers
          415  +  using this function together with <a href="lang_corefunc.html#hex">hex()</a> and/or
          416  +  <a href="lang_corefunc.html#lower">lower()</a> like this:</p>
          417  +
          418  +  <blockquote>
          419  +  hex(randomblob(16))<br></br>
          420  +  lower(hex(randomblob(16)))
          421  +  </blockquote>
          422  +</dd>
          423  +<a name="replace"></a>
          424  +<dt><p><b>replace(<i>X</i>,<i>Y</i>,<i>Z</i>)</b></dt><dd><p>
          425  +  The replace(X,Y,Z) function returns a string formed by substituting
          426  +  string Z for every occurrence of string Y in string X.  The <a href="datatype3.html#collation">BINARY</a>
          427  +  collating sequence is used for comparisons.  If Y is an empty
          428  +  string then return X unchanged.  If Z is not initially
          429  +  a string, it is cast to a UTF-8 string prior to processing.
          430  +</dd>
          431  +<a name="round"></a>
          432  +<dt><p><b>round(<i>X</i>)<br />round(<i>X</i>,<i>Y</i>)</b></dt><dd><p>
          433  +  The round(X,Y) function returns a floating-point
          434  +  value X rounded to Y digits to the right of the decimal point.
          435  +  If the Y argument is omitted, it is assumed to be 0.
          436  +</dd>
          437  +<a name="rtrim"></a>
          438  +<dt><p><b>rtrim(<i>X</i>)<br />rtrim(<i>X</i>,<i>Y</i>)</b></dt><dd><p>
          439  +  The rtrim(X,Y) function returns a string formed by removing any and all
          440  +  characters that appear in Y from the right side of X.
          441  +  If the Y argument is omitted, rtrim(X) removes spaces from the right
          442  +  side of X.
          443  +</dd>
          444  +<a name="soundex"></a>
          445  +<dt><p><b>soundex(<i>X</i>)</b></dt><dd><p>
          446  +  The soundex(X) function returns a string that is the soundex encoding 
          447  +  of the string X.
          448  +  The string "?000" is returned if the argument is NULL or contains
          449  +  no ASCII alphabetic characters.
          450  +  This function is omitted from SQLite by default.
          451  +  It is only available if the <a href="compile.html#soundex">SQLITE_SOUNDEX</a> compile-time option
          452  +  is used when SQLite is built.
          453  +</dd>
          454  +<a name="sqlite_compileoption_get"></a>
          455  +<dt><p><b>sqlite_compileoption_get(<i>N</i>)</b></dt><dd><p>
          456  +  The sqlite_compileoption_get() SQL function is a wrapper around the
          457  +  <a href="c3ref/compileoption_get.html">sqlite3_compileoption_get()</a> C/C++ function.
          458  +  This routine returns the N-th compile-time option used to build SQLite
          459  +  or NULL if N is out of range.  See also the <a href="pragma.html#pragma_compile_options">compile_options pragma</a>.
          460  +</dd>
          461  +<a name="sqlite_compileoption_used"></a>
          462  +<dt><p><b>sqlite_compileoption_used(<i>X</i>)</b></dt><dd><p>
          463  +  The sqlite_compileoption_used() SQL function is a wrapper around the
          464  +  <a href="c3ref/compileoption_get.html">sqlite3_compileoption_used()</a> C/C++ function.
          465  +  When the argument X to sqlite_compileoption_used(X) is a string which
          466  +  is the name of a compile-time option, this routine returns true (1) or
          467  +  false (0) depending on whether or not that option was used during the
          468  +  build.
          469  +</dd>
          470  +<a name="sqlite_offset"></a>
          471  +<dt><p><b>sqlite_offset(<i>X</i>)</b></dt><dd><p>
          472  +  The sqlite_offset(X) function returns the byte offset in the database
          473  +  file for the beginning of the record from which value would be read.
          474  +  If X is not a column in an ordinary table, then sqlite_offset(X) returns
          475  +  NULL.  The value returned by sqlite_offset(X) might reference either the
          476  +  original table or an index, depending on the query.  If the value X would
          477  +  normally be extracted from an index, the sqlite_offset(X) returns the
          478  +  offset to the corresponding index record.  If the value X would be
          479  +  extracted from the original table, then sqlite_offset(X) returns the offset
          480  +  to the table record.
          481  +
          482  +  <p>The sqlite_offset(X) SQL function is only available if SQLite is built
          483  +  using the <a href="compile.html#enable_offset_sql_func">-DSQLITE_ENABLE_OFFSET_SQL_FUNC</a> compile-time option.
          484  +</dd>
          485  +<a name="sqlite_source_id"></a>
          486  +<dt><p><b>sqlite_source_id()</b></dt><dd><p>
          487  +  The sqlite_source_id() function returns a string that identifies the
          488  +  specific version of the source code that was used to build the SQLite
          489  +  library.  The string returned by sqlite_source_id() is
          490  +  the date and time that the source code was checked in followed by
          491  +  the SHA1 hash for that check-in.  This function is
          492  +  an SQL wrapper around the <a href="c3ref/libversion.html">sqlite3_sourceid()</a> C interface.
          493  +</dd>
          494  +<a name="sqlite_version"></a>
          495  +<dt><p><b>sqlite_version()</b></dt><dd><p>
          496  +  The sqlite_version() function returns the version string for the SQLite
          497  +  library that is running.  This function is an SQL
          498  +  wrapper around the <a href="c3ref/libversion.html">sqlite3_libversion()</a> C-interface.
          499  +</dd>
          500  +<a name="substr"></a>
          501  +<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>
          502  +  The substr(X,Y,Z) function returns a substring of input string X that begins
          503  +  with the Y-th character and which is Z characters long.
          504  +  If Z is omitted then substr(X,Y) returns all characters through the end
          505  +  of the string X beginning with the Y-th.
          506  +  The left-most character of X is number 1.  If Y is negative
          507  +  then the first character of the substring is found by counting from the
          508  +  right rather than the left.  If Z is negative then
          509  +  the abs(Z) characters preceding the Y-th character are returned.
          510  +  If X is a string then characters indices refer to actual UTF-8 
          511  +  characters.  If X is a BLOB then the indices refer to bytes.
          512  +</dd>
          513  +<a name="total_changes"></a>
          514  +<dt><p><b>total_changes()</b></dt><dd><p>
          515  +  The total_changes() function returns the number of row changes
          516  +  caused by INSERT, UPDATE or DELETE
          517  +  statements since the current database connection was opened.
          518  +  This function is a wrapper around the <a href="c3ref/total_changes.html">sqlite3_total_changes()</a>
          519  +  C/C++ interface.
          520  +</dd>
          521  +<a name="trim"></a>
          522  +<dt><p><b>trim(<i>X</i>)<br />trim(<i>X</i>,<i>Y</i>)</b></dt><dd><p>
          523  +  The trim(X,Y) function returns a string formed by removing any and all
          524  +  characters that appear in Y from both ends of X.
          525  +  If the Y argument is omitted, trim(X) removes spaces from both ends of X.
          526  +</dd>
          527  +<a name="typeof"></a>
          528  +<dt><p><b>typeof(<i>X</i>)</b></dt><dd><p>
          529  +  The typeof(X) function returns a string that indicates the <a href="datatype3.html">datatype</a> of
          530  +  the expression X: "null", "integer", "real", "text", or "blob".
          531  +</dd>
          532  +<a name="unicode"></a>
          533  +<dt><p><b>unicode(<i>X</i>)</b></dt><dd><p>
          534  +  The unicode(X) function returns the numeric unicode code point corresponding to
          535  +  the first character of the string X.  If the argument to unicode(X) is not a string
          536  +  then the result is undefined.
          537  +</dd>
          538  +<a name="unlikely"></a>
          539  +<dt><p><b>unlikely(<i>X</i>)</b></dt><dd><p>
          540  +  The unlikely(X) function returns the argument X unchanged.
          541  +  The unlikely(X) function is a no-op that the code generator
          542  +  optimizes away so that it consumes no CPU cycles at
          543  +  run-time (that is, during calls to <a href="c3ref/step.html">sqlite3_step()</a>).
          544  +  The purpose of the unlikely(X) function is to provide a hint
          545  +  to the query planner that the argument X is a boolean value
          546  +  that is usually not true. The unlikely(X) function is equivalent
          547  +  to <a href="lang_corefunc.html#likelihood">likelihood</a>(X, 0.0625).
          548  +</dd>
          549  +<a name="upper"></a>
          550  +<dt><p><b>upper(<i>X</i>)</b></dt><dd><p>
          551  +  The upper(X) function returns a copy of input string X in which all 
          552  +  lower-case ASCII characters are converted to their upper-case equivalent.
          553  +</dd>
          554  +<a name="zeroblob"></a>
          555  +<dt><p><b>zeroblob(<i>N</i>)</b></dt><dd><p>
          556  +  The zeroblob(N) function returns a BLOB consisting of N bytes of 0x00.
          557  +  SQLite manages these zeroblobs very efficiently.  Zeroblobs can be used to
          558  +  reserve space for a BLOB that is later written using 
          559  +  <a href="c3ref/blob_open.html">incremental BLOB I/O</a>.
          560  +  This SQL function is implemented using the <a href="c3ref/result_blob.html">sqlite3_result_zeroblob()</a>
          561  +  routine from the C/C++ interface.
          562  +</dd>
          563  +
          564  +</dl>
          565  +

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>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 || !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=fancy>
           95  +<div class=nosearch>
           96  +<div class="fancy_title">
           97  +CREATE INDEX
           98  +</div>
           99  +</div>
          100  +
          101  +
          102  +
          103  +
          104  +<h1 id="syntax"><span>1. </span>Syntax</h1>
          105  +<p><b><a href="syntax/create-index-stmt.html">create-index-stmt:</a></b>
          106  +<button id='x1333' onclick='hideorshow("x1333","x1334")'>hide</button></p>
          107  + <div id='x1334' class='imgcontainer'>
          108  + <img alt="syntax diagram create-index-stmt" src="images/syntax/create-index-stmt.gif" />
          109  +<p><b><a href="syntax/expr.html">expr:</a></b>
          110  +<button id='x1335' onclick='hideorshow("x1335","x1336")'>show</button></p>
          111  + <div id='x1336' style='display:none;' class='imgcontainer'>
          112  + <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
          113  +<p><b><a href="syntax/filter-clause.html">filter-clause:</a></b>
          114  +<button id='x1337' onclick='hideorshow("x1337","x1338")'>show</button></p>
          115  + <div id='x1338' style='display:none;' class='imgcontainer'>
          116  + <img alt="syntax diagram filter-clause" src="images/syntax/filter-clause.gif" />
          117  +</div>
          118  +<p><b><a href="syntax/literal-value.html">literal-value:</a></b>
          119  +<button id='x1339' onclick='hideorshow("x1339","x1340")'>show</button></p>
          120  + <div id='x1340' style='display:none;' class='imgcontainer'>
          121  + <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
          122  +</div>
          123  +<p><b><a href="syntax/over-clause.html">over-clause:</a></b>
          124  +<button id='x1341' onclick='hideorshow("x1341","x1342")'>show</button></p>
          125  + <div id='x1342' style='display:none;' class='imgcontainer'>
          126  + <img alt="syntax diagram over-clause" src="images/syntax/over-clause.gif" />
          127  +<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
          128  +<button id='x1343' onclick='hideorshow("x1343","x1344")'>show</button></p>
          129  + <div id='x1344' style='display:none;' class='imgcontainer'>
          130  + <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
          131  +</div>
          132  +<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
          133  +<button id='x1345' onclick='hideorshow("x1345","x1346")'>show</button></p>
          134  + <div id='x1346' style='display:none;' class='imgcontainer'>
          135  + <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
          136  +</div>
          137  +</div>
          138  +<p><b><a href="syntax/raise-function.html">raise-function:</a></b>
          139  +<button id='x1347' onclick='hideorshow("x1347","x1348")'>show</button></p>
          140  + <div id='x1348' style='display:none;' class='imgcontainer'>
          141  + <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
          142  +</div>
          143  +<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
          144  +<button id='x1349' onclick='hideorshow("x1349","x1350")'>show</button></p>
          145  + <div id='x1350' 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='x1351' onclick='hideorshow("x1351","x1352")'>show</button></p>
          149  + <div id='x1352' 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='x1353' onclick='hideorshow("x1353","x1354")'>show</button></p>
          154  + <div id='x1354' 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='x1355' onclick='hideorshow("x1355","x1356")'>show</button></p>
          159  + <div id='x1356' 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='x1357' onclick='hideorshow("x1357","x1358")'>show</button></p>
          163  + <div id='x1358' 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='x1359' onclick='hideorshow("x1359","x1360")'>show</button></p>
          168  + <div id='x1360' 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='x1361' onclick='hideorshow("x1361","x1362")'>show</button></p>
          174  + <div id='x1362' 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='x1363' onclick='hideorshow("x1363","x1364")'>show</button></p>
          179  + <div id='x1364' 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='x1365' onclick='hideorshow("x1365","x1366")'>show</button></p>
          184  + <div id='x1366' 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='x1367' onclick='hideorshow("x1367","x1368")'>show</button></p>
          189  + <div id='x1368' 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='x1369' onclick='hideorshow("x1369","x1370")'>show</button></p>
          193  + <div id='x1370' 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/type-name.html">type-name:</a></b>
          199  +<button id='x1371' onclick='hideorshow("x1371","x1372")'>show</button></p>
          200  + <div id='x1372' style='display:none;' class='imgcontainer'>
          201  + <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
          202  +<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
          203  +<button id='x1373' onclick='hideorshow("x1373","x1374")'>show</button></p>
          204  + <div id='x1374' style='display:none;' class='imgcontainer'>
          205  + <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
          206  +</div>
          207  +</div>
          208  +</div>
          209  +<p><b><a href="syntax/indexed-column.html">indexed-column:</a></b>
          210  +<button id='x1375' onclick='hideorshow("x1375","x1376")'>show</button></p>
          211  + <div id='x1376' style='display:none;' class='imgcontainer'>
          212  + <img alt="syntax diagram indexed-column" src="images/syntax/indexed-column.gif" />
          213  +</div>
          214  +</div>
          215  +
          216  +
          217  +<p>The CREATE INDEX command consists of the keywords "CREATE INDEX" followed
          218  +by the name of the new index, the keyword "ON", the name of a previously
          219  +created table that is to be indexed, and a parenthesized list of table column
          220  +names and/or expressions that are used for the index key.
          221  +If the optional WHERE clause is included, then the index is a "<a href="partialindex.html">partial index</a>".
          222  +</p>
          223  +
          224  +<p>If the optional IF NOT EXISTS clause is present and another index
          225  +with the same name already exists, then this command becomes a no-op.</p>
          226  +
          227  +<p>There are no arbitrary limits on the number of indices that can be
          228  +attached to a single table.  The number of columns in an index is 
          229  +limited to the value set by
          230  +<a href="c3ref/limit.html">sqlite3_limit</a>(<a href="c3ref/c_limit_attached.html#sqlitelimitcolumn">SQLITE_LIMIT_COLUMN</a>,...).</p>
          231  +
          232  +<p>Indexes are removed with the <a href="lang_dropindex.html">DROP INDEX</a> command.</p>
          233  +
          234  +<a name="uniqueidx"></a>
          235  +
          236  +<h2 id="unique_indexes"><span>1.1. </span>Unique Indexes</h2>
          237  +
          238  +<p>If the UNIQUE keyword appears between CREATE and INDEX then duplicate
          239  +index entries are not allowed.  Any attempt to insert a duplicate entry
          240  +will result in an error.</p>
          241  +
          242  +<p>For the purposes of unique indices, all NULL values
          243  +are considered different from all other NULL values and are thus unique.
          244  +This is one of the two possible interpretations of the SQL-92 standard
          245  +(the language in the standard is ambiguous).  The interpretation used
          246  +by SQLite is the same and is the interpretation
          247  +followed by PostgreSQL, MySQL, Firebird, and Oracle.  Informix and
          248  +Microsoft SQL Server follow the other interpretation of the standard, which
          249  +is that all NULL values are equal to one another.</p>
          250  +
          251  +<a name="indexexpr"></a>
          252  +
          253  +<h2 id="indexes_on_expressions"><span>1.2. </span>Indexes on Expressions</h2>
          254  +
          255  +<p>Expressions in an index may not reference other tables
          256  +and may not use subqueries nor functions whose result might
          257  +change (ex: <a href="lang_corefunc.html#random">random()</a> or <a href="lang_corefunc.html#sqlite_version">sqlite_version()</a>).
          258  +Expressions in an index may only refer to columns in the table
          259  +that is being indexed.
          260  +Indexes on expression will not work with versions of SQLite prior
          261  +to <a href="releaselog/3_9_0.html">version 3.9.0</a> (2015-10-14).
          262  +See the <a href="expridx.html">Indexes On Expressions</a> document for additional information
          263  +about using general expressions in CREATE INDEX statements.
          264  +
          265  +<a name="descidx"></a>
          266  +
          267  +</p><h2 id="descending_indexes"><span>1.3. </span>Descending Indexes</h2>
          268  +
          269  +<p>Each column name or expression can be followed by one
          270  +of the "ASC" or "DESC" keywords to indicate sort order.
          271  +The sort order may or may not be ignored depending
          272  +on the database file format, and in particular the <a href="fileformat2.html#schemaformat">schema format number</a>.
          273  +The "legacy" schema format (1) ignores index
          274  +sort order.  The descending index schema format (4) takes index sort order
          275  +into account.  Only versions of SQLite 3.3.0 (2006-01-11)
          276  +and later are able to understand
          277  +the descending index format. For compatibility, version of SQLite between 3.3.0
          278  +and 3.7.9 use the legacy schema format by default.  The newer schema format is
          279  +used by default in version 3.7.10 (2012-01-16) and later.
          280  +The <a href="pragma.html#pragma_legacy_file_format">legacy_file_format pragma</a> can be used to change set the specific
          281  +behavior for any version of SQLite.</p>
          282  +
          283  +<h2 id="nulls_first_and_nulls_last"><span>1.4. </span>NULLS FIRST and NULLS LAST</h2>
          284  +
          285  +<p>The NULLS FIRST and NULLS LAST predicates are not supported
          286  +for indexes.  For <a href="datatype3.html#sortorder">sorting purposes</a>, SQLite considers NULL values 
          287  +to be smaller than all other values.  Hence NULL values always appear at
          288  +the beginning of an ASC index and at the end of a DESC index.</p>
          289  +
          290  +<a name="collidx"></a>
          291  +
          292  +<h2 id="collations"><span>1.5. </span>Collations</h2>
          293  +
          294  +<p>The COLLATE clause optionally following each column name
          295  +or expression defines a
          296  +collating sequence used for text entries in that column.
          297  +The default collating
          298  +sequence is the collating sequence defined for that column in the
          299  +<a href="lang_createtable.html">CREATE TABLE</a> statement.  Or if no collating sequence is otherwise defined,
          300  +the built-in BINARY collating sequence is used.</p>
          301  +

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>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 || !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=fancy>
           95  +<div class=nosearch>
           96  +<div class="fancy_title">
           97  +CREATE TABLE
           98  +</div>
           99  +<div class="fancy_toc">
          100  +<a onclick="toggle_toc()">
          101  +<span class="fancy_toc_mark" id="toc_mk">&#x25ba;</span>
          102  +Table Of Contents
          103  +</a>
          104  +<div id="toc_sub"><div class="fancy-toc1"><a href="#syntax">1. Syntax</a></div>
          105  +<div class="fancy-toc1"><a href="#the_create_table_command">2. The CREATE TABLE command</a></div>
          106  +<div class="fancy-toc2"><a href="#create_table_as_select_statements">2.1. CREATE TABLE ... AS SELECT Statements</a></div>
          107  +<div class="fancy-toc1"><a href="#column_definitions">3. Column Definitions</a></div>
          108  +<div class="fancy-toc2"><a href="#column_data_types">3.1. Column Data Types</a></div>
          109  +<div class="fancy-toc2"><a href="#the_default_clause">3.2. The DEFAULT clause</a></div>
          110  +<div class="fancy-toc2"><a href="#the_collate_clause">3.3. The COLLATE clause</a></div>
          111  +<div class="fancy-toc2"><a href="#the_generated_always_as_clause">3.4. The GENERATED ALWAYS AS clause</a></div>
          112  +<div class="fancy-toc2"><a href="#the_primary_key">3.5. The PRIMARY KEY</a></div>
          113  +<div class="fancy-toc2"><a href="#unique_constraints">3.6. UNIQUE constraints</a></div>
          114  +<div class="fancy-toc2"><a href="#check_constraints">3.7. CHECK constraints</a></div>
          115  +<div class="fancy-toc2"><a href="#not_null_constraints">3.8. NOT NULL constraints</a></div>
          116  +<div class="fancy-toc1"><a href="#constraint_violations">4. Constraint violations</a></div>
          117  +<div class="fancy-toc1"><a href="#rowids_and_the_integer_primary_key">5. ROWIDs and the INTEGER PRIMARY KEY</a></div>
          118  +</div>
          119  +</div>
          120  +<script>
          121  +function toggle_toc(){
          122  +var sub = document.getElementById("toc_sub")
          123  +var mk = document.getElementById("toc_mk")
          124  +if( sub.style.display!="block" ){
          125  +sub.style.display = "block";
          126  +mk.innerHTML = "&#x25bc;";
          127  +} else {
          128  +sub.style.display = "none";
          129  +mk.innerHTML = "&#x25ba;";
          130  +}
          131  +}
          132  +</script>
          133  +</div>
          134  +
          135  +
          136  +
          137  +
          138  +<h1 id="syntax"><span>1. </span>Syntax</h1>
          139  +
          140  +<p><b><a href="syntax/create-table-stmt.html">create-table-stmt:</a></b>
          141  +<button id='x1377' onclick='hideorshow("x1377","x1378")'>hide</button></p>
          142  + <div id='x1378' class='imgcontainer'>
          143  + <img alt="syntax diagram create-table-stmt" src="images/syntax/create-table-stmt.gif" />
          144  +<p><b><a href="syntax/column-def.html">column-def:</a></b>
          145  +<button id='x1379' onclick='hideorshow("x1379","x1380")'>show</button></p>
          146  + <div id='x1380' style='display:none;' class='imgcontainer'>
          147  + <img alt="syntax diagram column-def" src="images/syntax/column-def.gif" />
          148  +<p><b><a href="syntax/column-constraint.html">column-constraint:</a></b>
          149  +<button id='x1381' onclick='hideorshow("x1381","x1382")'>show</button></p>
          150  + <div id='x1382' style='display:none;' class='imgcontainer'>
          151  + <img alt="syntax diagram column-constraint" src="images/syntax/column-constraint.gif" />
          152  +<p><b><a href="syntax/conflict-clause.html">conflict-clause:</a></b>
          153  +<button id='x1383' onclick='hideorshow("x1383","x1384")'>show</button></p>
          154  + <div id='x1384' style='display:none;' class='imgcontainer'>
          155  + <img alt="syntax diagram conflict-clause" src="images/syntax/conflict-clause.gif" />
          156  +</div>
          157  +<p><b><a href="syntax/expr.html">expr:</a></b>
          158  +<button id='x1385' onclick='hideorshow("x1385","x1386")'>show</button></p>
          159  + <div id='x1386' style='display:none;' class='imgcontainer'>
          160  + <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
          161  +<p><b><a href="syntax/filter-clause.html">filter-clause:</a></b>
          162  +<button id='x1387' onclick='hideorshow("x1387","x1388")'>show</button></p>
          163  + <div id='x1388' style='display:none;' class='imgcontainer'>
          164  + <img alt="syntax diagram filter-clause" src="images/syntax/filter-clause.gif" />
          165  +</div>
          166  +<p><b><a href="syntax/over-clause.html">over-clause:</a></b>
          167  +<button id='x1389' onclick='hideorshow("x1389","x1390")'>show</button></p>
          168  + <div id='x1390' style='display:none;' class='imgcontainer'>
          169  + <img alt="syntax diagram over-clause" src="images/syntax/over-clause.gif" />
          170  +<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
          171  +<button id='x1391' onclick='hideorshow("x1391","x1392")'>show</button></p>
          172  + <div id='x1392' style='display:none;' class='imgcontainer'>
          173  + <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
          174  +</div>
          175  +<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
          176  +<button id='x1393' onclick='hideorshow("x1393","x1394")'>show</button></p>
          177  + <div id='x1394' style='display:none;' class='imgcontainer'>
          178  + <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
          179  +</div>
          180  +</div>
          181  +<p><b><a href="syntax/raise-function.html">raise-function:</a></b>
          182  +<button id='x1395' onclick='hideorshow("x1395","x1396")'>show</button></p>
          183  + <div id='x1396' style='display:none;' class='imgcontainer'>
          184  + <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
          185  +</div>
          186  +</div>
          187  +<p><b><a href="syntax/foreign-key-clause.html">foreign-key-clause:</a></b>
          188  +<button id='x1397' onclick='hideorshow("x1397","x1398")'>show</button></p>
          189  + <div id='x1398' style='display:none;' class='imgcontainer'>
          190  + <img alt="syntax diagram foreign-key-clause" src="images/syntax/foreign-key-clause.gif" />
          191  +</div>
          192  +<p><b><a href="syntax/literal-value.html">literal-value:</a></b>
          193  +<button id='x1399' onclick='hideorshow("x1399","x1400")'>show</button></p>
          194  + <div id='x1400' style='display:none;' class='imgcontainer'>
          195  + <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
          196  +</div>
          197  +<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
          198  +<button id='x1401' onclick='hideorshow("x1401","x1402")'>show</button></p>
          199  + <div id='x1402' style='display:none;' class='imgcontainer'>
          200  + <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
          201  +</div>
          202  +</div>
          203  +<p><b><a href="syntax/type-name.html">type-name:</a></b>
          204  +<button id='x1403' onclick='hideorshow("x1403","x1404")'>show</button></p>
          205  + <div id='x1404' style='display:none;' class='imgcontainer'>
          206  + <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
          207  +<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
          208  +<button id='x1405' onclick='hideorshow("x1405","x1406")'>show</button></p>
          209  + <div id='x1406' style='display:none;' class='imgcontainer'>
          210  + <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
          211  +</div>
          212  +</div>
          213  +</div>
          214  +<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
          215  +<button id='x1407' onclick='hideorshow("x1407","x1408")'>show</button></p>
          216  + <div id='x1408' style='display:none;' class='imgcontainer'>
          217  + <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
          218  +<p><b><a href="syntax/common-table-expression.html">common-table-expression:</a></b>
          219  +<button id='x1409' onclick='hideorshow("x1409","x1410")'>show</button></p>
          220  + <div id='x1410' style='display:none;' class='imgcontainer'>
          221  + <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
          222  +</div>
          223  +<p><b><a href="syntax/compound-operator.html">compound-operator:</a></b>
          224  +<button id='x1411' onclick='hideorshow("x1411","x1412")'>show</button></p>
          225  + <div id='x1412' style='display:none;' class='imgcontainer'>
          226  + <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
          227  +</div>
          228  +<p><b><a href="syntax/expr.html">expr:</a></b>
          229  +<button id='x1413' onclick='hideorshow("x1413","x1414")'>show</button></p>
          230  + <div id='x1414' style='display:none;' class='imgcontainer'>
          231  + <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
          232  +<p><b><a href="syntax/filter-clause.html">filter-clause:</a></b>
          233  +<button id='x1415' onclick='hideorshow("x1415","x1416")'>show</button></p>
          234  + <div id='x1416' style='display:none;' class='imgcontainer'>
          235  + <img alt="syntax diagram filter-clause" src="images/syntax/filter-clause.gif" />
          236  +</div>
          237  +<p><b><a href="syntax/literal-value.html">literal-value:</a></b>
          238  +<button id='x1417' onclick='hideorshow("x1417","x1418")'>show</button></p>
          239  + <div id='x1418' style='display:none;' class='imgcontainer'>
          240  + <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
          241  +</div>
          242  +<p><b><a href="syntax/over-clause.html">over-clause:</a></b>
          243  +<button id='x1419' onclick='hideorshow("x1419","x1420")'>show</button></p>
          244  + <div id='x1420' style='display:none;' class='imgcontainer'>
          245  + <img alt="syntax diagram over-clause" src="images/syntax/over-clause.gif" />
          246  +<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
          247  +<button id='x1421' onclick='hideorshow("x1421","x1422")'>show</button></p>
          248  + <div id='x1422' style='display:none;' class='imgcontainer'>
          249  + <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
          250  +</div>
          251  +</div>
          252  +<p><b><a href="syntax/raise-function.html">raise-function:</a></b>
          253  +<button id='x1423' onclick='hideorshow("x1423","x1424")'>show</button></p>
          254  + <div id='x1424' style='display:none;' class='imgcontainer'>
          255  + <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
          256  +</div>
          257  +<p><b><a href="syntax/type-name.html">type-name:</a></b>
          258  +<button id='x1425' onclick='hideorshow("x1425","x1426")'>show</button></p>
          259  + <div id='x1426' style='display:none;' class='imgcontainer'>
          260  + <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
          261  +<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
          262  +<button id='x1427' onclick='hideorshow("x1427","x1428")'>show</button></p>
          263  + <div id='x1428' style='display:none;' class='imgcontainer'>
          264  + <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
          265  +</div>
          266  +</div>
          267  +</div>
          268  +<p><b><a href="syntax/join-clause.html">join-clause:</a></b>
          269  +<button id='x1429' onclick='hideorshow("x1429","x1430")'>show</button></p>
          270  + <div id='x1430' style='display:none;' class='imgcontainer'>
          271  + <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
          272  +<p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
          273  +<button id='x1431' onclick='hideorshow("x1431","x1432")'>show</button></p>
          274  + <div id='x1432' style='display:none;' class='imgcontainer'>
          275  + <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
          276  +</div>
          277  +<p><b><a href="syntax/join-operator.html">join-operator:</a></b>
          278  +<button id='x1433' onclick='hideorshow("x1433","x1434")'>show</button></p>
          279  + <div id='x1434' style='display:none;' class='imgcontainer'>
          280  + <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
          281  +</div>
          282  +</div>
          283  +<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
          284  +<button id='x1435' onclick='hideorshow("x1435","x1436")'>show</button></p>
          285  + <div id='x1436' style='display:none;' class='imgcontainer'>
          286  + <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
          287  +</div>
          288  +<p><b><a href="syntax/result-column.html">result-column:</a></b>
          289  +<button id='x1437' onclick='hideorshow("x1437","x1438")'>show</button></p>
          290  + <div id='x1438' style='display:none;' class='imgcontainer'>
          291  + <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
          292  +</div>
          293  +<p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
          294  +<button id='x1439' onclick='hideorshow("x1439","x1440")'>show</button></p>
          295  + <div id='x1440' style='display:none;' class='imgcontainer'>
          296  + <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
          297  +</div>
          298  +<p><b><a href="syntax/window-defn.html">window-defn:</a></b>
          299  +<button id='x1441' onclick='hideorshow("x1441","x1442")'>show</button></p>
          300  + <div id='x1442' style='display:none;' class='imgcontainer'>
          301  + <img alt="syntax diagram window-defn" src="images/syntax/window-defn.gif" />
          302  +<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
          303  +<button id='x1443' onclick='hideorshow("x1443","x1444")'>show</button></p>
          304  + <div id='x1444' style='display:none;' class='imgcontainer'>
          305  + <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
          306  +</div>
          307  +</div>
          308  +</div>
          309  +<p><b><a href="syntax/table-constraint.html">table-constraint:</a></b>
          310  +<button id='x1445' onclick='hideorshow("x1445","x1446")'>show</button></p>
          311  + <div id='x1446' style='display:none;' class='imgcontainer'>
          312  + <img alt="syntax diagram table-constraint" src="images/syntax/table-constraint.gif" />
          313  +<p><b><a href="syntax/conflict-clause.html">conflict-clause:</a></b>
          314  +<button id='x1447' onclick='hideorshow("x1447","x1448")'>show</button></p>
          315  + <div id='x1448' style='display:none;' class='imgcontainer'>
          316  + <img alt="syntax diagram conflict-clause" src="images/syntax/conflict-clause.gif" />
          317  +</div>
          318  +<p><b><a href="syntax/expr.html">expr:</a></b>
          319  +<button id='x1449' onclick='hideorshow("x1449","x1450")'>show</button></p>
          320  + <div id='x1450' style='display:none;' class='imgcontainer'>
          321  + <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
          322  +<p><b><a href="syntax/filter-clause.html">filter-clause:</a></b>
          323  +<button id='x1451' onclick='hideorshow("x1451","x1452")'>show</button></p>
          324  + <div id='x1452' style='display:none;' class='imgcontainer'>
          325  + <img alt="syntax diagram filter-clause" src="images/syntax/filter-clause.gif" />
          326  +</div>
          327  +<p><b><a href="syntax/literal-value.html">literal-value:</a></b>
          328  +<button id='x1453' onclick='hideorshow("x1453","x1454")'>show</button></p>
          329  + <div id='x1454' style='display:none;' class='imgcontainer'>
          330  + <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
          331  +</div>
          332  +<p><b><a href="syntax/over-clause.html">over-clause:</a></b>
          333  +<button id='x1455' onclick='hideorshow("x1455","x1456")'>show</button></p>
          334  + <div id='x1456' style='display:none;' class='imgcontainer'>
          335  + <img alt="syntax diagram over-clause" src="images/syntax/over-clause.gif" />
          336  +<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
          337  +<button id='x1457' onclick='hideorshow("x1457","x1458")'>show</button></p>
          338  + <div id='x1458' style='display:none;' class='imgcontainer'>
          339  + <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
          340  +</div>
          341  +<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
          342  +<button id='x1459' onclick='hideorshow("x1459","x1460")'>show</button></p>
          343  + <div id='x1460' style='display:none;' class='imgcontainer'>
          344  + <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
          345  +</div>
          346  +</div>
          347  +<p><b><a href="syntax/raise-function.html">raise-function:</a></b>
          348  +<button id='x1461' onclick='hideorshow("x1461","x1462")'>show</button></p>
          349  + <div id='x1462' style='display:none;' class='imgcontainer'>
          350  + <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
          351  +</div>
          352  +<p><b><a href="syntax/type-name.html">type-name:</a></b>
          353  +<button id='x1463' onclick='hideorshow("x1463","x1464")'>show</button></p>
          354  + <div id='x1464' style='display:none;' class='imgcontainer'>
          355  + <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
          356  +<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
          357  +<button id='x1465' onclick='hideorshow("x1465","x1466")'>show</button></p>
          358  + <div id='x1466' style='display:none;' class='imgcontainer'>
          359  + <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
          360  +</div>
          361  +</div>
          362  +</div>
          363  +<p><b><a href="syntax/foreign-key-clause.html">foreign-key-clause:</a></b>
          364  +<button id='x1467' onclick='hideorshow("x1467","x1468")'>show</button></p>
          365  + <div id='x1468' style='display:none;' class='imgcontainer'>
          366  + <img alt="syntax diagram foreign-key-clause" src="images/syntax/foreign-key-clause.gif" />
          367  +</div>
          368  +<p><b><a href="syntax/indexed-column.html">indexed-column:</a></b>
          369  +<button id='x1469' onclick='hideorshow("x1469","x1470")'>show</button></p>
          370  + <div id='x1470' style='display:none;' class='imgcontainer'>
          371  + <img alt="syntax diagram indexed-column" src="images/syntax/indexed-column.gif" />
          372  +</div>
          373  +</div>
          374  +</div>
          375  +
          376  +
          377  +<h1 id="the_create_table_command"><span>2. </span>The CREATE TABLE command</h1>
          378  +
          379  +<p>The "CREATE TABLE" command is used to create a new table in an SQLite 
          380  +database. A CREATE TABLE command specifies the following attributes of the
          381  +new table:
          382  +
          383  +</p><ul>
          384  +  <li><p>The name of the new table.
          385  +
          386  +  </p></li><li><p> The database in which the new table is created. Tables may be 
          387  +      created in the main database, the temp database, or in any attached
          388  +      database.
          389  +
          390  +  </p></li><li><p> The name of each column in the table.
          391  +
          392  +  </p></li><li><p> The declared type of each column in the table.
          393  +
          394  +  </p></li><li><p> A default value or expression for each column in the table.
          395  +
          396  +  </p></li><li><p> A default collation sequence to use with each column.
          397  +
          398  +  </p></li><li><p> Optionally, a PRIMARY KEY for the table. Both single column and
          399  +       composite (multiple column) primary keys are supported.
          400  +
          401  +  </p></li><li><p> A set of SQL constraints for each table. SQLite supports UNIQUE, NOT
          402  +       NULL, CHECK and FOREIGN KEY constraints.
          403  +
          404  +  </p></li><li><p> Optionally, a <a href="gencol.html">generated column</a> constraint.
          405  +
          406  +  </p></li><li><p> Whether the table is a <a href="withoutrowid.html">WITHOUT ROWID</a> table.
          407  +</p></li></ul>
          408  +
          409  +<p>Every CREATE TABLE statement must specify a name for the new table.
          410  +  Table names that begin with "sqlite_" are reserved for internal use. It
          411  +  is an error to attempt to create a table with a name that starts with
          412  +  "sqlite_".
          413  +
          414  +</p><p> If a <span class='yyterm'>schema-name</span> is specified, it must be either "main", 
          415  +  "temp", or the name of an <a href="lang_attach.html">attached database</a>. In this case
          416  +  the new table is created in the named database. If the "TEMP" or "TEMPORARY"
          417  +  keyword occurs between the "CREATE" and "TABLE" then the new table is
          418  +  created in the temp database. It is an error to specify both a 
          419  +  <span class='yyterm'>schema-name</span> and the TEMP or TEMPORARY keyword, unless the
          420  +  <span class='yyterm'>schema-name</span> is "temp". 
          421  +  If no schema name is specified and the
          422  +  TEMP keyword is not present then the table is created in the main
          423  +  database.
          424  +
          425  +</p><p>
          426  +  It is usually an error to attempt to create a new table in a database that
          427  +  already contains a table, index or view of the same name. However, if the
          428  +  "IF NOT EXISTS" clause is specified as part of the CREATE TABLE statement and
          429  +  a table or view of the same name already exists, the CREATE TABLE command
          430  +  simply has no effect (and no error message is returned). An error is still
          431  +  returned if the table cannot be created because of an existing index, even 
          432  +  if the "IF NOT EXISTS" clause is specified.
          433  +
          434  +</p><p>It is not an error to create a table that has the same name as an 
          435  +  existing <a href="lang_createtrigger.html">trigger</a>.
          436  +
          437  +</p><p>Tables are removed using the <a href="lang_droptable.html">DROP TABLE</a> statement.  </p>
          438  +
          439  +<a name="createtabas"></a>
          440  +
          441  +<h2 id="create_table_as_select_statements"><span>2.1. </span>CREATE TABLE ... AS SELECT Statements</h2>
          442  +
          443  +<p>A "CREATE TABLE ... AS SELECT" statement creates and populates a database
          444  +table based on the results of a SELECT statement. The table has the same
          445  +number of columns as the rows returned by the SELECT statement. The name of
          446  +each column is the same as the name of the corresponding column in the result
          447  +set of the SELECT statement. The declared type of each column is determined
          448  +by the <a href="datatype3.html#expraff">expression affinity</a> of the corresponding expression in the result set
          449  +of the SELECT statement, as follows:
          450  +</p>
          451  +
          452  +<center><table border="1">
          453  +  <tr><th>Expression Affinity   </th><th>Column Declared Type
          454  +  </th></tr><tr><td>TEXT                  </td><td>"TEXT"
          455  +  </td></tr><tr><td>NUMERIC               </td><td>"NUM"
          456  +  </td></tr><tr><td>INTEGER               </td><td>"INT"
          457  +  </td></tr><tr><td>REAL                  </td><td>"REAL"
          458  +  </td></tr><tr><td>BLOB (a.k.a "NONE")   </td><td>"" (empty string)
          459  +</td></tr></table></center>
          460  +
          461  +<p>A table created using CREATE TABLE AS has no PRIMARY KEY and no
          462  +constraints of any kind. The default value of each column is NULL. The default
          463  +collation sequence for each column of the new table is BINARY.
          464  +
          465  +</p><p>Tables created using CREATE TABLE AS are initially populated with the
          466  +rows of data returned by the SELECT statement. Rows are assigned contiguously
          467  +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
          468  +are returned by the SELECT statement.
          469  +
          470  +<a name="tablecoldef"></a>
          471  +
          472  +</p><h1 id="column_definitions"><span>3. </span>Column Definitions</h1>
          473  +
          474  +<p>Unless it is a CREATE TABLE ... AS SELECT statement, a CREATE TABLE includes
          475  +one or more <a href="syntax/column-def.html">column definitions</a>, optionally followed by a list of
          476  +<a href="syntax/table-constraint.html">table constraints</a>.  Each column definition consists of the
          477  +name of the column, optionally followed by the declared type of the column,
          478  +then one or more optional <a href="syntax/column-constraint.html">column constraints</a>. Included in
          479  +the definition of "column constraints" for the purposes of the previous
          480  +statement are the COLLATE and DEFAULT clauses, even though these are not really
          481  +constraints in the sense that they do not restrict the data that the table may
          482  +contain. The other constraints - NOT NULL, CHECK, UNIQUE, PRIMARY KEY and
          483  +FOREIGN KEY constraints - impose restrictions on the table data.
          484  +
          485  +</p><p>The number of columns in a table is limited by the <a href="limits.html#max_column">SQLITE_MAX_COLUMN</a>
          486  +compile-time parameter. A single row of a table cannot store more than
          487  +<a href="limits.html#max_length">SQLITE_MAX_LENGTH</a> bytes of data. Both of these limits can be lowered at
          488  +runtime using the <a href="c3ref/limit.html">sqlite3_limit()</a> C/C++ interface.</p>
          489  +
          490  +<h2 id="column_data_types"><span>3.1. </span>Column Data Types</h2>
          491  +
          492  +<p>Unlike most SQL databases, SQLite does not restrict the type of data that
          493  +may be inserted into a column based on the columns declared type. Instead,
          494  +SQLite uses <a href="datatype3.html">dynamic typing</a>. The declared type of a column is used to
          495  +determine the <a href="datatype3.html#affinity">affinity</a> of the column only.
          496  +
          497  +<a name="dfltval"></a>
          498  +
          499  +</p><h2 id="the_default_clause"><span>3.2. </span>The DEFAULT clause</h2>
          500  +<p>The DEFAULT clause specifies a default value to use for the column if no
          501  +value is explicitly provided by the user when doing an <a href="lang_insert.html">INSERT</a>. If there
          502  +is no explicit DEFAULT clause attached to a column definition, then the 
          503  +default value of the column is NULL. An explicit DEFAULT clause may specify
          504  +that the default value is NULL, a string constant, a blob constant, a
          505  +signed-number, or any constant expression enclosed in parentheses. A
          506  +default value may also be one of the special case-independent keywords
          507  +CURRENT_TIME, CURRENT_DATE or CURRENT_TIMESTAMP. For the purposes of the
          508  +DEFAULT clause, an expression is considered constant if it
          509  +contains no sub-queries, column or table references, <a href="lang_expr.html#varparam">bound parameters</a>,
          510  +or string literals enclosed in double-quotes instead of single-quotes.
          511  +
          512  +</p><p>Each time a row is inserted into the table by an INSERT statement that 
          513  +does not provide explicit values for all table columns the values stored in
          514  +the new row are determined by their default values, as follows:
          515  +
          516  +</p><ul>
          517  +  <li><p>If the default value of the column is a constant NULL, text, blob or
          518  +    signed-number value, then that value is used directly in the new row.
          519  +
          520  +  </p></li><li><p>If the default value of a column is an expression in parentheses, then
          521  +    the expression is evaluated once for each row inserted and the results
          522  +    used in the new row.
          523  +
          524  +  </p></li><li><p>If the default value of a column is CURRENT_TIME, CURRENT_DATE or
          525  +    CURRENT_TIMESTAMP, then the value used in the new row is a text
          526  +    representation of the current UTC date and/or time. For CURRENT_TIME, the
          527  +    format of the value is "HH:MM:SS". For CURRENT_DATE, "YYYY-MM-DD". The
          528  +    format for CURRENT_TIMESTAMP is "YYYY-MM-DD HH:MM:SS".
          529  +</p></li></ul>
          530  +
          531  +<a name="collateclause"></a>
          532  +
          533  +<h2 id="the_collate_clause"><span>3.3. </span>The COLLATE clause</h2>
          534  +<p>The COLLATE clause specifies the name of a <a href="datatype3.html#collation">collating sequence</a> to use as
          535  +the default collation sequence for the column. If no COLLATE clause is
          536  +specified, the default collation sequence is <a href="datatype3.html#collation">BINARY</a>.
          537  +
          538  +</p><h2 id="the_generated_always_as_clause"><span>3.4. </span>The GENERATED ALWAYS AS clause</h2>
          539  +<p>A column that includes a GENERATED ALWAY AS clause is a <a href="gencol.html">generated column</a>.
          540  +Generated columns are supported beginning with SQLite verison 3.31.0 (2020-01-22).
          541  +See the <a href="gencol.html">separate documentation</a> for details on the capabilities and
          542  +limitations of generated columns.
          543  +
          544  +<a name="primkeyconst"></a>
          545  +
          546  +</p><h2 id="the_primary_key"><span>3.5. </span>The PRIMARY KEY</h2>
          547  +<p>Each table in SQLite may have at most one PRIMARY KEY. If the
          548  +  keywords PRIMARY KEY are added to a column definition, then the primary key
          549  +  for the table consists of that single column. Or, if a PRIMARY KEY clause 
          550  +  is specified as a <a href="syntax/table-constraint.html">table-constraint</a>, then the primary key of the table
          551  +  consists of the list of columns specified as part of the PRIMARY KEY clause.
          552  +  The PRIMARY KEY clause must contain only column names &mdash; the use of 
          553  +  expressions in an <a href="syntax/indexed-column.html">indexed-column</a> of a PRIMARY KEY is not supported.
          554  +  An error is raised if more than one PRIMARY KEY clause appears in a
          555  +  CREATE TABLE statement.  The PRIMARY KEY is optional for ordinary tables
          556  +  but is required for <a href="withoutrowid.html">WITHOUT ROWID</a> tables.
          557  +
          558  +</p><p>If a table has a single column primary key and the declared type of that
          559  +  column is "INTEGER" and the table is not a <a href="withoutrowid.html">WITHOUT ROWID</a> table,
          560  +  then the column is known as an <a href="lang_createtable.html#rowid">INTEGER PRIMARY KEY</a>.
          561  +  See <a href="lang_createtable.html#rowid">below</a> for a description of the special properties and behaviors
          562  +  associated with an <a href="lang_createtable.html#rowid">INTEGER PRIMARY KEY</a>.
          563  +
          564  +</p><p>Each row in a table with a primary key must have a unique combination
          565  +  of values in its primary key columns. For the purposes of determining
          566  +  the uniqueness of primary key values, NULL values are considered distinct from
          567  +  all other values, including other NULLs. If an <a href="lang_insert.html">INSERT</a> or <a href="lang_update.html">UPDATE</a>
          568  +  statement attempts to modify the table content so that two or more rows
          569  +  have identical primary key values, that is a constraint violation.
          570  +
          571  +</p><p> According to the SQL standard, PRIMARY KEY should always imply NOT NULL.
          572  +  Unfortunately, due to a bug in some early versions, this is not the
          573  +  case in SQLite. Unless the column is an <a href="lang_createtable.html#rowid">INTEGER PRIMARY KEY</a> or
          574  +  the table is a <a href="withoutrowid.html">WITHOUT ROWID</a> table or the column is declared NOT NULL,
          575  +  SQLite allows NULL values in a PRIMARY KEY column.  SQLite could be fixed to
          576  +  conform to the standard, but doing so might break legacy applications.
          577  +  Hence, it has been decided to merely document the fact that SQLite
          578  +  allowing NULLs in most PRIMARY KEY columns.
          579  +
          580  +<a name="uniqueconst"></a>
          581  +
          582  +</p><h2 id="unique_constraints"><span>3.6. </span>UNIQUE constraints</h2>
          583  +<p>A UNIQUE constraint is similar to a PRIMARY KEY constraint, except
          584  +  that a single table may have any number of UNIQUE constraints. For each
          585  +  UNIQUE constraint on the table, each row must contain a unique combination
          586  +  of values in the columns identified by the UNIQUE constraint. 
          587  +  For the purposes of UNIQUE constraints, NULL values
          588  +  are considered distinct from all other values, including other NULLs.
          589  +  As with PRIMARY KEYs, a UNIQUE <a href="syntax/table-constraint.html">table-constraint</a> clause must contain
          590  +  only column names &mdash; the use of 
          591  +  expressions in an <a href="syntax/indexed-column.html">indexed-column</a> of a UNIQUE <a href="syntax/table-constraint.html">table-constraint</a>
          592  +  is not supported.
          593  +  
          594  +
          595  +</p><p>In most cases, UNIQUE and PRIMARY KEY
          596  +  constraints are implemented by creating a unique index in the database.
          597  +  (The exceptions are <a href="lang_createtable.html#rowid">INTEGER PRIMARY KEY</a> and PRIMARY KEYs on 
          598  +  <a href="withoutrowid.html">WITHOUT ROWID</a> tables.)
          599  +  Hence, the following schemas are logically equivalent:
          600  +
          601  +  </p><ol>
          602  +  <li><p>CREATE TABLE t1(a, b UNIQUE);
          603  +  </p></li><li><p>CREATE TABLE t1(a, b PRIMARY KEY);
          604  +  </p></li><li><p>CREATE TABLE t1(a, b);<br>
          605  +         CREATE UNIQUE INDEX t1b ON t1(b);
          606  +  </p></li></ol>
          607  +
          608  +<a name="ckconst"></a>
          609  +
          610  +<h2 id="check_constraints"><span>3.7. </span>CHECK constraints</h2>
          611  +<p>A CHECK constraint may be attached to a column definition or
          612  +  specified as a table constraint. In practice it makes no difference. Each
          613  +  time a new row is inserted into the table or an existing row is updated,
          614  +  the expression associated with each CHECK constraint is evaluated and
          615  +  cast to a NUMERIC value in the same way as a <a href="lang_expr.html#castexpr">CAST expression</a>. If the 
          616  +  result is zero (integer value 0 or real value 0.0), then a constraint
          617  +  violation has occurred. If the CHECK expression evaluates to NULL, or
          618  +  any other non-zero value, it is not a constraint violation.
          619  +  The expression of a CHECK constraint may not contain a subquery.
          620  +
          621  +<a name="notnullconst"></a>
          622  +
          623  +</p><h2 id="not_null_constraints"><span>3.8. </span>NOT NULL constraints</h2>
          624  +<p>A NOT NULL constraint may only be attached to a column definition,
          625  +  not specified as a table constraint.  Not surprisingly, a NOT NULL
          626  +  constraint dictates that the associated column may not contain a NULL value.
          627  +  Attempting to set the column value to NULL when inserting a new row or
          628  +  updating an existing one causes a constraint violation.
          629  +
          630  +
          631  +</p><h1 id="constraint_violations"><span>4. </span>Constraint violations</h1>
          632  +<p>Exactly how a constraint violation is dealt with is determined by the
          633  +  <a href="lang_conflict.html">constraint conflict resolution algorithm</a>. Each 
          634  +  PRIMARY KEY, UNIQUE, NOT NULL and CHECK constraint has a default conflict
          635  +  resolution algorithm. PRIMARY KEY, UNIQUE and NOT NULL constraints may be
          636  +  explicitly assigned a default conflict resolution algorithm by including
          637  +  a <a href="syntax/conflict-clause.html">conflict-clause</a> in their definitions. Or, if a constraint definition
          638  +  does not include a <a href="syntax/conflict-clause.html">conflict-clause</a> or it is a CHECK constraint, the default
          639  +  conflict resolution algorithm is ABORT. Different constraints within the
          640  +  same table may have different default conflict resolution algorithms. See
          641  +  the section titled <a href="lang_conflict.html">ON CONFLICT</a> for additional information.
          642  +
          643  +<a name="rowid"></a>
          644  +
          645  +</p><h1 id="rowids_and_the_integer_primary_key"><span>5. </span>ROWIDs and the INTEGER PRIMARY KEY</h1>
          646  +
          647  +<p>Except for <a href="withoutrowid.html">WITHOUT ROWID</a> tables, all rows within SQLite tables
          648  +have a 64-bit signed integer key that uniquely identifies the row within its table.
          649  +This integer is usually
          650  +called the "rowid". The rowid value can be accessed using one of the special
          651  +case-independent names "rowid", "oid", or "_rowid_" in place of a column name.
          652  +If a table contains a user defined column named "rowid", "oid" or "_rowid_",
          653  +then that name always refers the explicitly declared column and cannot be used
          654  +to retrieve the integer rowid value.
          655  +
          656  +</p><p>The rowid (and "oid" and "_rowid_") is omitted in <a href="withoutrowid.html">WITHOUT ROWID</a> tables.
          657  +WITHOUT ROWID tables are only available in SQLite <a href="releaselog/3_8_2.html">version 3.8.2</a>
          658  +(2013-12-06) and later.
          659  +A table that lacks the WITHOUT ROWID clause is called a "rowid table".
          660  +
          661  +</p><p>The data for rowid tables is stored as a B-Tree structure containing
          662  +one entry for each table row, using the rowid value as the key. This means that
          663  +retrieving or sorting records by rowid is fast. Searching for a record with a
          664  +specific rowid, or for all records with rowids within a specified range is
          665  +around twice as fast as a similar search made by specifying any other PRIMARY
          666  +KEY or indexed value.
          667  +
          668  +</p><p> With one exception noted below, if a rowid table has a primary key that consists
          669  +of a single column and the declared type of that column is "INTEGER" in any mixture of
          670  +upper and lower case, then the column becomes an alias for the rowid. Such a
          671  +column is usually referred to as an "integer primary key". A PRIMARY KEY column
          672  +only becomes an integer primary key if the declared type name is exactly
          673  +"INTEGER".  Other integer type names like "INT" or "BIGINT" or "SHORT INTEGER"
          674  +or "UNSIGNED INTEGER" causes the primary key column to behave as an ordinary
          675  +table column with integer <a href="datatype3.html#affinity">affinity</a> and a unique index, not as an alias for
          676  +the rowid.
          677  +
          678  +</p><p> The exception mentioned above is that if the declaration of a column with
          679  +declared type "INTEGER" includes an "PRIMARY KEY DESC" clause, it does not
          680  +become an alias for the rowid and is not classified as an integer primary key.
          681  +This quirk is not by design. It is due to a bug in early versions of SQLite.
          682  +But fixing the bug could result in backwards incompatibilities.
          683  +Hence, the original behavior has been retained (and documented) because odd
          684  +behavior in a corner case is far better than a compatibility break.  This means
          685  +that the following three table declarations all cause the column "x" to be an
          686  +alias for the rowid (an integer primary key):
          687  +
          688  +</p><ul>
          689  +<li><tt>CREATE TABLE t(x INTEGER PRIMARY KEY ASC, y, z);</tt>
          690  +</li><li><tt>CREATE TABLE t(x INTEGER, y, z, PRIMARY KEY(x ASC));</tt>
          691  +</li><li><tt>CREATE TABLE t(x INTEGER, y, z, PRIMARY KEY(x DESC));</tt>
          692  +</li></ul>
          693  +
          694  +<p>But the following declaration does not result in "x" being an alias for
          695  +the rowid:
          696  +</p><ul>
          697  +<li><tt>CREATE TABLE t(x INTEGER PRIMARY KEY DESC, y, z);</tt>
          698  +</li></ul>
          699  +
          700  +<p>Rowid values may be modified using an UPDATE statement in the same
          701  +way as any other column value can, either using one of the built-in aliases
          702  +("rowid", "oid" or "_rowid_") or by using an alias created by an integer
          703  +primary key. Similarly, an INSERT statement may provide a value to use as the
          704  +rowid for each row inserted. Unlike normal SQLite columns, an integer primary
          705  +key or rowid column must contain integer values. Integer primary key or rowid
          706  +columns are not able to hold floating point values, strings, BLOBs, or NULLs.
          707  +
          708  +</p><p>If an UPDATE statement attempts to set an integer primary key or rowid column
          709  +to a NULL or blob value, or to a string or real value that cannot be losslessly
          710  +converted to an integer, a "datatype mismatch" error occurs and the statement
          711  +is aborted. If an INSERT statement attempts to insert a blob value, or a string
          712  +or real value that cannot be losslessly converted to an integer into an
          713  +integer primary key or rowid column, a "datatype mismatch" error occurs and the
          714  +statement is aborted.
          715  +
          716  +</p><p>If an INSERT statement attempts to insert a NULL value into a rowid or
          717  +integer primary key column, the system chooses an integer value to use as the
          718  +rowid automatically. A detailed description of how this is done is provided
          719  +<a href="autoinc.html">separately</a>.</p>
          720  +
          721  +<p>The <a href="foreignkeys.html#parentchild">parent key</a> of a <a href="foreignkeys.html">foreign key constraint</a> is not allowed to
          722  +use the rowid.  The parent key must used named columns only.</p>
          723  +

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>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 || !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=fancy>
           95  +<div class=nosearch>
           96  +<div class="fancy_title">
           97  +CREATE TRIGGER
           98  +</div>
           99  +<div class="fancy_toc">
          100  +<a onclick="toggle_toc()">
          101  +<span class="fancy_toc_mark" id="toc_mk">&#x25ba;</span>
          102  +Table Of Contents
          103  +</a>
          104  +<div id="toc_sub"><div class="fancy-toc1"><a href="#syntax">1. Syntax</a></div>
          105  +<div class="fancy-toc1"><a href="#description">2. Description</a></div>
          106  +<div class="fancy-toc2"><a href="#syntax_restrictions_on_update_delete_and_insert_statements_within_triggers">2.1. Syntax Restrictions On UPDATE, DELETE, and INSERT Statements Within
          107  +Triggers</a></div>
          108  +<div class="fancy-toc1"><a href="#instead_of_triggers">3. INSTEAD OF triggers</a></div>
          109  +<div class="fancy-toc1"><a href="#some_example_triggers">4. Some Example Triggers</a></div>
          110  +<div class="fancy-toc1"><a href="#cautions_on_the_use_of_before_triggers">5. Cautions On The Use Of BEFORE triggers</a></div>
          111  +<div class="fancy-toc1"><a href="#the_raise_function">6. The RAISE() function</a></div>
          112  +<div class="fancy-toc1"><a href="#temp_triggers_on_non_temp_tables">7. TEMP Triggers on Non-TEMP Tables</a></div>
          113  +</div>
          114  +</div>
          115  +<script>
          116  +function toggle_toc(){
          117  +var sub = document.getElementById("toc_sub")
          118  +var mk = document.getElementById("toc_mk")
          119  +if( sub.style.display!="block" ){
          120  +sub.style.display = "block";
          121  +mk.innerHTML = "&#x25bc;";
          122  +} else {
          123  +sub.style.display = "none";
          124  +mk.innerHTML = "&#x25ba;";
          125  +}
          126  +}
          127  +</script>
          128  +</div>
          129  +
          130  +
          131  +
          132  +
          133  +<h1 id="syntax"><span>1. </span>Syntax</h1>
          134  +
          135  +<p><b><a href="syntax/create-trigger-stmt.html">create-trigger-stmt:</a></b>
          136  +<button id='x1471' onclick='hideorshow("x1471","x1472")'>hide</button></p>
          137  + <div id='x1472' class='imgcontainer'>
          138  + <img alt="syntax diagram create-trigger-stmt" src="images/syntax/create-trigger-stmt.gif" />
          139  +<p><b><a href="syntax/delete-stmt.html">delete-stmt:</a></b>
          140  +<button id='x1473' onclick='hideorshow("x1473","x1474")'>show</button></p>
          141  + <div id='x1474' style='display:none;' class='imgcontainer'>
          142  + <img alt="syntax diagram delete-stmt" src="images/syntax/delete-stmt.gif" />
          143  +<p><b><a href="syntax/qualified-table-name.html">qualified-table-name:</a></b>
          144  +<button id='x1475' onclick='hideorshow("x1475","x1476")'>show</button></p>
          145  + <div id='x1476' style='display:none;' class='imgcontainer'>
          146  + <img alt="syntax diagram qualified-table-name" src="images/syntax/qualified-table-name.gif" />
          147  +</div>
          148  +<p><b><a href="syntax/with-clause.html">with-clause:</a></b>
          149  +<button id='x1477' onclick='hideorshow("x1477","x1478")'>show</button></p>
          150  + <div id='x1478' style='display:none;' class='imgcontainer'>
          151  + <img alt="syntax diagram with-clause" src="images/syntax/with-clause.gif" />
          152  +<p><b><a href="syntax/cte-table-name.html">cte-table-name:</a></b>
          153  +<button id='x1479' onclick='hideorshow("x1479","x1480")'>show</button></p>
          154  + <div id='x1480' style='display:none;' class='imgcontainer'>
          155  + <img alt="syntax diagram cte-table-name" src="images/syntax/cte-table-name.gif" />
          156  +</div>
          157  +</div>
          158  +</div>
          159  +<p><b><a href="syntax/expr.html">expr:</a></b>
          160  +<button id='x1481' onclick='hideorshow("x1481","x1482")'>show</button></p>
          161  + <div id='x1482' style='display:none;' class='imgcontainer'>
          162  + <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
          163  +<p><b><a href="syntax/filter-clause.html">filter-clause:</a></b>
          164  +<button id='x1483' onclick='hideorshow("x1483","x1484")'>show</button></p>
          165  + <div id='x1484' style='display:none;' class='imgcontainer'>
          166  + <img alt="syntax diagram filter-clause" src="images/syntax/filter-clause.gif" />
          167  +</div>
          168  +<p><b><a href="syntax/literal-value.html">literal-value:</a></b>
          169  +<button id='x1485' onclick='hideorshow("x1485","x1486")'>show</button></p>
          170  + <div id='x1486' style='display:none;' class='imgcontainer'>
          171  + <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
          172  +</div>
          173  +<p><b><a href="syntax/over-clause.html">over-clause:</a></b>
          174  +<button id='x1487' onclick='hideorshow("x1487","x1488")'>show</button></p>
          175  + <div id='x1488' style='display:none;' class='imgcontainer'>
          176  + <img alt="syntax diagram over-clause" src="images/syntax/over-clause.gif" />
          177  +<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
          178  +<button id='x1489' onclick='hideorshow("x1489","x1490")'>show</button></p>
          179  + <div id='x1490' style='display:none;' class='imgcontainer'>
          180  + <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
          181  +</div>
          182  +<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
          183  +<button id='x1491' onclick='hideorshow("x1491","x1492")'>show</button></p>
          184  + <div id='x1492' style='display:none;' class='imgcontainer'>
          185  + <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
          186  +</div>
          187  +</div>
          188  +<p><b><a href="syntax/raise-function.html">raise-function:</a></b>
          189  +<button id='x1493' onclick='hideorshow("x1493","x1494")'>show</button></p>
          190  + <div id='x1494' style='display:none;' class='imgcontainer'>
          191  + <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
          192  +</div>
          193  +<p><b><a href="syntax/type-name.html">type-name:</a></b>
          194  +<button id='x1495' onclick='hideorshow("x1495","x1496")'>show</button></p>
          195  + <div id='x1496' style='display:none;' class='imgcontainer'>
          196  + <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
          197  +<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
          198  +<button id='x1497' onclick='hideorshow("x1497","x1498")'>show</button></p>
          199  + <div id='x1498' style='display:none;' class='imgcontainer'>
          200  + <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
          201  +</div>
          202  +</div>
          203  +</div>
          204  +<p><b><a href="syntax/insert-stmt.html">insert-stmt:</a></b>
          205  +<button id='x1499' onclick='hideorshow("x1499","x1500")'>show</button></p>
          206  + <div id='x1500' style='display:none;' class='imgcontainer'>
          207  + <img alt="syntax diagram insert-stmt" src="images/syntax/insert-stmt.gif" />
          208  +<p><b><a href="syntax/upsert-clause.html">upsert-clause:</a></b>
          209  +<button id='x1501' onclick='hideorshow("x1501","x1502")'>show</button></p>
          210  + <div id='x1502' style='display:none;' class='imgcontainer'>
          211  + <img alt="syntax diagram upsert-clause" src="images/syntax/upsert-clause.gif" />
          212  +<p><b><a href="syntax/column-name-list.html">column-name-list:</a></b>
          213  +<button id='x1503' onclick='hideorshow("x1503","x1504")'>show</button></p>
          214  + <div id='x1504' style='display:none;' class='imgcontainer'>
          215  + <img alt="syntax diagram column-name-list" src="images/syntax/column-name-list.gif" />
          216  +</div>
          217  +<p><b><a href="syntax/indexed-column.html">indexed-column:</a></b>
          218  +<button id='x1505' onclick='hideorshow("x1505","x1506")'>show</button></p>
          219  + <div id='x1506' style='display:none;' class='imgcontainer'>
          220  + <img alt="syntax diagram indexed-column" src="images/syntax/indexed-column.gif" />
          221  +</div>
          222  +</div>
          223  +<p><b><a href="syntax/with-clause.html">with-clause:</a></b>
          224  +<button id='x1507' onclick='hideorshow("x1507","x1508")'>show</button></p>
          225  + <div id='x1508' style='display:none;' class='imgcontainer'>
          226  + <img alt="syntax diagram with-clause" src="images/syntax/with-clause.gif" />
          227  +<p><b><a href="syntax/cte-table-name.html">cte-table-name:</a></b>
          228  +<button id='x1509' onclick='hideorshow("x1509","x1510")'>show</button></p>
          229  + <div id='x1510' style='display:none;' class='imgcontainer'>
          230  + <img alt="syntax diagram cte-table-name" src="images/syntax/cte-table-name.gif" />
          231  +</div>
          232  +</div>
          233  +</div>
          234  +<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
          235  +<button id='x1511' onclick='hideorshow("x1511","x1512")'>show</button></p>
          236  + <div id='x1512' style='display:none;' class='imgcontainer'>
          237  + <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
          238  +<p><b><a href="syntax/common-table-expression.html">common-table-expression:</a></b>
          239  +<button id='x1513' onclick='hideorshow("x1513","x1514")'>show</button></p>
          240  + <div id='x1514' style='display:none;' class='imgcontainer'>
          241  + <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
          242  +</div>
          243  +<p><b><a href="syntax/compound-operator.html">compound-operator:</a></b>
          244  +<button id='x1515' onclick='hideorshow("x1515","x1516")'>show</button></p>
          245  + <div id='x1516' style='display:none;' class='imgcontainer'>
          246  + <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
          247  +</div>
          248  +<p><b><a href="syntax/join-clause.html">join-clause:</a></b>
          249  +<button id='x1517' onclick='hideorshow("x1517","x1518")'>show</button></p>
          250  + <div id='x1518' style='display:none;' class='imgcontainer'>
          251  + <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
          252  +<p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
          253  +<button id='x1519' onclick='hideorshow("x1519","x1520")'>show</button></p>
          254  + <div id='x1520' style='display:none;' class='imgcontainer'>
          255  + <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
          256  +</div>
          257  +<p><b><a href="syntax/join-operator.html">join-operator:</a></b>
          258  +<button id='x1521' onclick='hideorshow("x1521","x1522")'>show</button></p>
          259  + <div id='x1522' style='display:none;' class='imgcontainer'>
          260  + <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
          261  +</div>
          262  +</div>
          263  +<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
          264  +<button id='x1523' onclick='hideorshow("x1523","x1524")'>show</button></p>
          265  + <div id='x1524' style='display:none;' class='imgcontainer'>
          266  + <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
          267  +</div>
          268  +<p><b><a href="syntax/result-column.html">result-column:</a></b>
          269  +<button id='x1525' onclick='hideorshow("x1525","x1526")'>show</button></p>
          270  + <div id='x1526' style='display:none;' class='imgcontainer'>
          271  + <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
          272  +</div>
          273  +<p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
          274  +<button id='x1527' onclick='hideorshow("x1527","x1528")'>show</button></p>
          275  + <div id='x1528' style='display:none;' class='imgcontainer'>
          276  + <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
          277  +</div>
          278  +<p><b><a href="syntax/window-defn.html">window-defn:</a></b>
          279  +<button id='x1529' onclick='hideorshow("x1529","x1530")'>show</button></p>
          280  + <div id='x1530' style='display:none;' class='imgcontainer'>
          281  + <img alt="syntax diagram window-defn" src="images/syntax/window-defn.gif" />
          282  +<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
          283  +<button id='x1531' onclick='hideorshow("x1531","x1532")'>show</button></p>
          284  + <div id='x1532' style='display:none;' class='imgcontainer'>
          285  + <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
          286  +</div>
          287  +</div>
          288  +</div>
          289  +<p><b><a href="syntax/update-stmt.html">update-stmt:</a></b>
          290  +<button id='x1533' onclick='hideorshow("x1533","x1534")'>show</button></p>
          291  + <div id='x1534' style='display:none;' class='imgcontainer'>
          292  + <img alt="syntax diagram update-stmt" src="images/syntax/update-stmt.gif" />
          293  +<p><b><a href="syntax/column-name-list.html">column-name-list:</a></b>
          294  +<button id='x1535' onclick='hideorshow("x1535","x1536")'>show</button></p>
          295  + <div id='x1536' style='display:none;' class='imgcontainer'>
          296  + <img alt="syntax diagram column-name-list" src="images/syntax/column-name-list.gif" />
          297  +</div>
          298  +<p><b><a href="syntax/qualified-table-name.html">qualified-table-name:</a></b>
          299  +<button id='x1537' onclick='hideorshow("x1537","x1538")'>show</button></p>
          300  + <div id='x1538' style='display:none;' class='imgcontainer'>
          301  + <img alt="syntax diagram qualified-table-name" src="images/syntax/qualified-table-name.gif" />
          302  +</div>
          303  +<p><b><a href="syntax/with-clause.html">with-clause:</a></b>
          304  +<button id='x1539' onclick='hideorshow("x1539","x1540")'>show</button></p>
          305  + <div id='x1540' style='display:none;' class='imgcontainer'>
          306  + <img alt="syntax diagram with-clause" src="images/syntax/with-clause.gif" />
          307  +<p><b><a href="syntax/cte-table-name.html">cte-table-name:</a></b>
          308  +<button id='x1541' onclick='hideorshow("x1541","x1542")'>show</button></p>
          309  + <div id='x1542' style='display:none;' class='imgcontainer'>
          310  + <img alt="syntax diagram cte-table-name" src="images/syntax/cte-table-name.gif" />
          311  +</div>
          312  +</div>
          313  +</div>
          314  +</div>
          315  +
          316  +
          317  +<h1 id="description"><span>2. </span>Description</h1>
          318  +<p>The CREATE TRIGGER statement is used to add triggers to the 
          319  +database schema. Triggers are database operations 
          320  +that are automatically performed when a specified database event
          321  +occurs.  </p>
          322  +
          323  +<p>Each trigger must specify that it will fire for one of
          324  +the following operations: <a href="lang_delete.html">DELETE</a>, <a href="lang_insert.html">INSERT</a>, <a href="lang_update.html">UPDATE</a>.
          325  +The trigger fires once for each row that is deleted, inserted,
          326  +or updated.  If the "UPDATE OF <span class='yyterm'>column-name</span>"
          327  +syntax is used, then the trigger will only fire if
          328  +<span class='yyterm'>column-name</span> appears on the left-hand side of
          329  +one of the terms in the SET clause of the <a href="lang_update.html">UPDATE</a> statement.</p>
          330  +
          331  +<p>Due to an historical oversight, columns named in the "UPDATE OF"
          332  +clause do not actually have to exist in the table being updated.
          333  +Unrecognized column names are silently ignored.
          334  +It would be more helpful if SQLite would fail the CREATE TRIGGER
          335  +statement if any of the names in the "UPDATE OF" clause are not
          336  +columns in the table.  However, as this problem was discovered
          337  +many years after SQLite was widely deployed, we have resisted
          338  +fixing the problem for fear of breaking legacy applications.</p>
          339  +
          340  +<p>At this time SQLite supports only FOR EACH ROW triggers, not FOR EACH
          341  +STATEMENT triggers. Hence explicitly specifying FOR EACH ROW is optional.
          342  +FOR EACH ROW implies that the SQL statements specified in the trigger
          343  +may be executed (depending on the WHEN clause) for each database row being
          344  +inserted, updated or deleted by the statement causing the trigger to fire.</p>
          345  +
          346  +<p>Both the WHEN clause and the trigger actions may access elements of 
          347  +the row being inserted, deleted or updated using references of the form 
          348  +"NEW.<i>column-name</i>" and "OLD.<i>column-name</i>", where
          349  +<i>column-name</i> is the name of a column from the table that the trigger
          350  +is associated with. OLD and NEW references may only be used in triggers on
          351  +events for which they are relevant, as follows:</p>
          352  +
          353  +<table border="0" cellpadding="10">
          354  +<tr>
          355  +<td valign="top" align="right" width="120"><i>INSERT</i></td>
          356  +<td valign="top">NEW references are valid</td>
          357  +</tr>
          358  +<tr>
          359  +<td valign="top" align="right" width="120"><i>UPDATE</i></td>
          360  +<td valign="top">NEW and OLD references are valid</td>
          361  +</tr>
          362  +<tr>
          363  +<td valign="top" align="right" width="120"><i>DELETE</i></td>
          364  +<td valign="top">OLD references are valid</td>
          365  +</tr>
          366  +</table>
          367  +
          368  +
          369  +<p>If a WHEN clause is supplied, the SQL statements specified
          370  +are only executed if the WHEN clause is true.
          371  +If no WHEN clause is supplied, the SQL statements
          372  +are executed every time the trigger fires.</p>
          373  +
          374  +<p>The BEFORE or AFTER keyword determines when the trigger actions
          375  +will be executed relative to the insertion, modification or removal of the
          376  +associated row.  BEFORE is the default when neither keyword is present.</p>
          377  +
          378  +<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>
          379  +action within the body of the trigger.
          380  +However if an <a href="lang_conflict.html">ON CONFLICT</a> clause is specified as part of 
          381  +the statement causing the trigger to fire, then conflict handling
          382  +policy of the outer statement is used instead.</p>
          383  +
          384  +<p>Triggers are automatically <a href="lang_droptrigger.html">dropped</a>
          385  +when the table that they are 
          386  +associated with (the <i>table-name</i> table) is 
          387  +<a href="lang_droptable.html">dropped</a>.  However if the trigger actions reference
          388  +other tables, the trigger is not dropped or modified if those other
          389  +tables are <a href="lang_droptable.html">dropped</a> or <a href="lang_altertable.html">modified</a>.</p>
          390  +
          391  +<p>Triggers are removed using the <a href="lang_droptrigger.html">DROP TRIGGER</a> statement.</p>
          392  +
          393  +<h2 id="syntax_restrictions_on_update_delete_and_insert_statements_within_triggers"><span>2.1. </span>Syntax Restrictions On UPDATE, DELETE, and INSERT Statements Within
          394  +    Triggers</h2>
          395  +
          396  +<p>The <a href="lang_update.html">UPDATE</a>, <a href="lang_delete.html">DELETE</a>, and <a href="lang_insert.html">INSERT</a>
          397  +statements within triggers do not support
          398  +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
          399  +restrictions apply:</p>
          400  +
          401  +<ul>
          402  +<li><p>
          403  +  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>
          404  +  statement must be an unqualified table name.  In other words, one must
          405  +  use just "<i>tablename</i>" not "<i>database</i><b>.</b><i>tablename</i>"
          406  +  when specifying the table. </p></li>
          407  +
          408  +<li><p>
          409  + For non-TEMP triggers,
          410  +  the table to be modified or queried must exist in the
          411  +  same database as the table or view to which the trigger is attached.
          412  +  TEMP triggers are not subject to the same-database rule.  A TEMP
          413  +  trigger is allowed to query or modify any table in any <a href="lang_attach.html">ATTACH</a>-ed database.
          414  +  </p></li>
          415  +
          416  +<li><p>
          417  +  The "INSERT INTO <i>table</i> DEFAULT VALUES" form of the <a href="lang_insert.html">INSERT</a> statement
          418  +  is not supported.
          419  +  </p></li>
          420  +
          421  +<li><p>
          422  +  The INDEXED BY and NOT INDEXED clauses are not supported for <a href="lang_update.html">UPDATE</a> and
          423  +  <a href="lang_delete.html">DELETE</a> statements.
          424  +  </p></li>
          425  +
          426  +<li><p>
          427  +  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
          428  +  supported.  ORDER BY and LIMIT are not normally supported for <a href="lang_update.html">UPDATE</a> or
          429  +  <a href="lang_delete.html">DELETE</a> in any context but can be enabled for top-level statements
          430  +  using the <a href="compile.html#enable_update_delete_limit">SQLITE_ENABLE_UPDATE_DELETE_LIMIT</a> compile-time option.  However,
          431  +  that compile-time option only applies to top-level <a href="lang_update.html">UPDATE</a> and <a href="lang_delete.html">DELETE</a>
          432  +  statements, not <a href="lang_update.html">UPDATE</a> and <a href="lang_delete.html">DELETE</a> statements within triggers.
          433  +  </p></li>
          434  +
          435  +<li><p>
          436  +  <a href="syntax/common-table-expression.html">Common table expression</a> are not supported for
          437  +  statements inside of triggers.
          438  +  </p></li>
          439  +</ul>
          440  +
          441  +<a name="instead_of_trigger"></a>
          442  +
          443  +<h1 id="instead_of_triggers"><span>3. </span>INSTEAD OF triggers</h1>
          444  +
          445  +<p>Triggers may be created on <a href="lang_createview.html">views</a>, as well as ordinary tables, by
          446  +specifying INSTEAD OF in the CREATE TRIGGER statement. 
          447  +If one or more ON INSERT, ON DELETE
          448  +or ON UPDATE triggers are defined on a view, then it is not an
          449  +error to execute an INSERT, DELETE or UPDATE statement on the view, 
          450  +respectively.  Instead,
          451  +executing an INSERT, DELETE or UPDATE on the view causes the associated
          452  +triggers to fire. The real tables underlying the view are not modified
          453  +(except possibly explicitly, by a trigger program).</p>
          454  +
          455  +<p>Note that the <a href="c3ref/changes.html">sqlite3_changes()</a> and <a href="c3ref/total_changes.html">sqlite3_total_changes()</a> interfaces
          456  +do not count INSTEAD OF trigger firings, but the
          457  +<a href="pragma.html#pragma_count_changes">count_changes pragma</a> does count INSTEAD OF trigger firing.</p>
          458  +
          459  +<h1 id="some_example_triggers"><span>4. </span>Some Example Triggers</h1>
          460  +
          461  +<p>Assuming that customer records are stored in the "customers" table, and
          462  +that order records are stored in the "orders" table, the following
          463  +UPDATE trigger
          464  +ensures that all associated orders are redirected when a customer changes
          465  +his or her address:</p>
          466  +
          467  +<blockquote><pre>
          468  +CREATE TRIGGER update_customer_address UPDATE OF address ON customers 
          469  +  BEGIN
          470  +    UPDATE orders SET address = new.address WHERE customer_name = old.name;
          471  +  END;
          472  +</pre></blockquote>
          473  +
          474  +<p>With this trigger installed, executing the statement:</p>
          475  +
          476  +<blockquote><pre>
          477  +UPDATE customers SET address = '1 Main St.' WHERE name = 'Jack Jones';
          478  +</pre></blockquote>
          479  +
          480  +<p>causes the following to be automatically executed:</p>
          481  +
          482  +<blockquote><pre>
          483  +UPDATE orders SET address = '1 Main St.' WHERE customer_name = 'Jack Jones';
          484  +</pre></blockquote>
          485  +
          486  +<p>For an example of an INSTEAD OF trigger, consider the following schema:
          487  +
          488  +<blockquote><pre>
          489  +CREATE TABLE customer(
          490  +  cust_id INTEGER PRIMARY KEY,
          491  +  cust_name TEXT,
          492  +  cust_addr TEXT
          493  +);
          494  +CREATE VIEW customer_address AS
          495  +   SELECT cust_id, cust_addr FROM customer;
          496  +CREATE TRIGGER cust_addr_chng
          497  +INSTEAD OF UPDATE OF cust_addr ON customer_address
          498  +BEGIN
          499  +  UPDATE customer SET cust_addr=NEW.cust_addr
          500  +   WHERE cust_id=NEW.cust_id;
          501  +END;
          502  +</pre></blockquote>
          503  +
          504  +</p><p>With the schema above, a statement of the form:</p>
          505  +
          506  +<blockquote><pre>
          507  +UPDATE customer_address SET cust_addr=$new_address WHERE cust_id=$cust_id;
          508  +</pre></blockquote>
          509  +
          510  +<p>Causes the customer.cust_addr field to be updated for a specific
          511  +customer entry that has customer.cust_id equal to the $cust_id parameter.
          512  +Note how the values assigned to the view are made available as field
          513  +in the special "NEW" table within the trigger body.</p>
          514  +
          515  +<a name="undef_before"></a>
          516  +
          517  +<h1 id="cautions_on_the_use_of_before_triggers"><span>5. </span>Cautions On The Use Of BEFORE triggers</h1>
          518  +
          519  +<p>If a BEFORE UPDATE or BEFORE DELETE trigger modifies or deletes a row
          520  +that was to have been updated or deleted, then the result of the subsequent
          521  +update or delete operation is undefined.  Furthermore, if a BEFORE trigger
          522  +modifies or deletes a row, then it is undefined whether or not AFTER triggers
          523  +that would have otherwise run on those rows will in fact run.
          524  +</p>
          525  +
          526  +<p>The value of NEW.rowid is undefined in a BEFORE INSERT trigger in which
          527  +the rowid is not explicitly set to an integer.</p>
          528  +
          529  +<p>Because of the behaviors described above, programmers are encouraged to
          530  +prefer AFTER triggers over BEFORE triggers.</p>
          531  +
          532  +<a name="raise"></a>
          533  +
          534  +<h1 id="the_raise_function"><span>6. </span>The RAISE() function</h1>
          535  +
          536  +<p>A special SQL function RAISE() may be used within a trigger-program,
          537  +with the following syntax</p> 
          538  +
          539  +<p><b><a href="syntax/raise-function.html">raise-function:</a></b></p><div class='imgcontainer'>
          540  + <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif"></img>
          541  + </div>
          542  +
          543  +
          544  +<p>When one of RAISE(ROLLBACK,...), RAISE(ABORT,...) or RAISE(FAIL,...)
          545  +is called during trigger-program
          546  +execution, the specified <a href="lang_conflict.html">ON CONFLICT</a> processing is performed and
          547  +the current query terminates.
          548  +An error code of <a href="rescode.html#constraint">SQLITE_CONSTRAINT</a> is returned to the application,
          549  +along with the specified error message.</p>
          550  +
          551  +<p>When RAISE(IGNORE) is called, the remainder of the current trigger program,
          552  +the statement that caused the trigger program to execute and any subsequent
          553  +trigger programs that would have been executed are abandoned. No database
          554  +changes are rolled back.  If the statement that caused the trigger program
          555  +to execute is itself part of a trigger program, then that trigger program
          556  +resumes execution at the beginning of the next step.
          557  +</p>
          558  +
          559  +<a name="temptrig"></a>
          560  +
          561  +<h1 id="temp_triggers_on_non_temp_tables"><span>7. </span>TEMP Triggers on Non-TEMP Tables</h1>
          562  +
          563  +<p>A trigger normally exists in the same database as the table named
          564  +after the "ON" keyword in the CREATE TRIGGER statement.  Except, it is
          565  +possible to create a TEMP TRIGGER on a table in another database.  
          566  +Such a trigger will only fire when changes
          567  +are made to the target table by the application that defined the trigger.
          568  +Other applications that modify the database will not be able to see the
          569  +TEMP trigger and hence cannot run the trigger.</p>
          570  +
          571  +<p>When defining a TEMP trigger on a non-TEMP table, it is important to
          572  +specify the database holding the non-TEMP table.  For example,
          573  +in the following statement, it is important to say "main.tab1" instead
          574  +of just "tab1":</p>
          575  +
          576  +<blockquote><pre>
          577  +CREATE TEMP TRIGGER ex1 AFTER INSERT ON <b>main.</b>tab1 BEGIN ...
          578  +</pre></blockquote>
          579  +
          580  +<p>Failure to specify the schema name on the target table could result
          581  +in the TEMP trigger being reattached to a table with the same name in
          582  +another database whenever any schema change occurs.</p>
          583  +

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>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 || !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=fancy>
           95  +<div class=nosearch>
           96  +<div class="fancy_title">
           97  +CREATE VIEW
           98  +</div>
           99  +</div>
          100  +
          101  +
          102  +
          103  +
          104  +<h1 id="syntax"><span>1. </span>Syntax</h1>
          105  +
          106  +<p><b><a href="syntax/create-view-stmt.html">create-view-stmt:</a></b>
          107  +<button id='x1543' onclick='hideorshow("x1543","x1544")'>hide</button></p>
          108  + <div id='x1544' class='imgcontainer'>
          109  + <img alt="syntax diagram create-view-stmt" src="images/syntax/create-view-stmt.gif" />
          110  +<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
          111  +<button id='x1545' onclick='hideorshow("x1545","x1546")'>show</button></p>
          112  + <div id='x1546' style='display:none;' class='imgcontainer'>
          113  + <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
          114  +<p><b><a href="syntax/common-table-expression.html">common-table-expression:</a></b>
          115  +<button id='x1547' onclick='hideorshow("x1547","x1548")'>show</button></p>
          116  + <div id='x1548' style='display:none;' class='imgcontainer'>
          117  + <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
          118  +</div>
          119  +<p><b><a href="syntax/compound-operator.html">compound-operator:</a></b>
          120  +<button id='x1549' onclick='hideorshow("x1549","x1550")'>show</button></p>
          121  + <div id='x1550' style='display:none;' class='imgcontainer'>
          122  + <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
          123  +</div>
          124  +<p><b><a href="syntax/expr.html">expr:</a></b>
          125  +<button id='x1551' onclick='hideorshow("x1551","x1552")'>show</button></p>
          126  + <div id='x1552' style='display:none;' class='imgcontainer'>
          127  + <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
          128  +<p><b><a href="syntax/filter-clause.html">filter-clause:</a></b>
          129  +<button id='x1553' onclick='hideorshow("x1553","x1554")'>show</button></p>
          130  + <div id='x1554' style='display:none;' class='imgcontainer'>
          131  + <img alt="syntax diagram filter-clause" src="images/syntax/filter-clause.gif" />
          132  +</div>
          133  +<p><b><a href="syntax/literal-value.html">literal-value:</a></b>
          134  +<button id='x1555' onclick='hideorshow("x1555","x1556")'>show</button></p>
          135  + <div id='x1556' style='display:none;' class='imgcontainer'>
          136  + <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
          137  +</div>
          138  +<p><b><a href="syntax/over-clause.html">over-clause:</a></b>
          139  +<button id='x1557' onclick='hideorshow("x1557","x1558")'>show</button></p>
          140  + <div id='x1558' style='display:none;' class='imgcontainer'>
          141  + <img alt="syntax diagram over-clause" src="images/syntax/over-clause.gif" />
          142  +<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
          143  +<button id='x1559' onclick='hideorshow("x1559","x1560")'>show</button></p>
          144  + <div id='x1560' style='display:none;' class='imgcontainer'>
          145  + <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
          146  +</div>
          147  +</div>
          148  +<p><b><a href="syntax/raise-function.html">raise-function:</a></b>
          149  +<button id='x1561' onclick='hideorshow("x1561","x1562")'>show</button></p>
          150  + <div id='x1562' style='display:none;' class='imgcontainer'>
          151  + <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
          152  +</div>
          153  +<p><b><a href="syntax/type-name.html">type-name:</a></b>
          154  +<button id='x1563' onclick='hideorshow("x1563","x1564")'>show</button></p>
          155  + <div id='x1564' style='display:none;' class='imgcontainer'>
          156  + <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
          157  +<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
          158  +<button id='x1565' onclick='hideorshow("x1565","x1566")'>show</button></p>
          159  + <div id='x1566' style='display:none;' class='imgcontainer'>
          160  + <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
          161  +</div>
          162  +</div>
          163  +</div>
          164  +<p><b><a href="syntax/join-clause.html">join-clause:</a></b>
          165  +<button id='x1567' onclick='hideorshow("x1567","x1568")'>show</button></p>
          166  + <div id='x1568' style='display:none;' class='imgcontainer'>
          167  + <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
          168  +<p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
          169  +<button id='x1569' onclick='hideorshow("x1569","x1570")'>show</button></p>
          170  + <div id='x1570' style='display:none;' class='imgcontainer'>
          171  + <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
          172  +</div>
          173  +<p><b><a href="syntax/join-operator.html">join-operator:</a></b>
          174  +<button id='x1571' onclick='hideorshow("x1571","x1572")'>show</button></p>
          175  + <div id='x1572' style='display:none;' class='imgcontainer'>
          176  + <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
          177  +</div>
          178  +</div>
          179  +<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
          180  +<button id='x1573' onclick='hideorshow("x1573","x1574")'>show</button></p>
          181  + <div id='x1574' style='display:none;' class='imgcontainer'>
          182  + <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
          183  +</div>
          184  +<p><b><a href="syntax/result-column.html">result-column:</a></b>
          185  +<button id='x1575' onclick='hideorshow("x1575","x1576")'>show</button></p>
          186  + <div id='x1576' style='display:none;' class='imgcontainer'>
          187  + <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
          188  +</div>
          189  +<p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
          190  +<button id='x1577' onclick='hideorshow("x1577","x1578")'>show</button></p>
          191  + <div id='x1578' style='display:none;' class='imgcontainer'>
          192  + <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
          193  +</div>
          194  +<p><b><a href="syntax/window-defn.html">window-defn:</a></b>
          195  +<button id='x1579' onclick='hideorshow("x1579","x1580")'>show</button></p>
          196  + <div id='x1580' style='display:none;' class='imgcontainer'>
          197  + <img alt="syntax diagram window-defn" src="images/syntax/window-defn.gif" />
          198  +<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
          199  +<button id='x1581' onclick='hideorshow("x1581","x1582")'>show</button></p>
          200  + <div id='x1582' style='display:none;' class='imgcontainer'>
          201  + <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
          202  +</div>
          203  +</div>
          204  +</div>
          205  +</div>
          206  +
          207  +
          208  +<h1 id="description"><span>2. </span>Description</h1>
          209  +
          210  +<p>The CREATE VIEW command assigns a name to a pre-packaged 
          211  +<a href="lang_select.html">SELECT</a> statement. 
          212  +Once the view is created, it can be used in the FROM clause
          213  +of another <a href="lang_select.html">SELECT</a> in place of a table name.
          214  +</p>
          215  +
          216  +<p>If the "TEMP" or "TEMPORARY" keyword occurs in between "CREATE"
          217  +and "VIEW" then the view that is created is only visible to the
          218  +<a href="c3ref/sqlite3.html">database connection</a> that created it and is automatically deleted when
          219  +the database connection is closed.</p>
          220  +
          221  +<p> If a <span class='yyterm'>schema-name</span> is specified, then the view 
          222  +is created in the specified database.
          223  +It is an error to specify both a <span class='yyterm'>schema-name</span>
          224  +and the TEMP keyword on a VIEW, unless the <span class='yyterm'>schema-name</span> 
          225  +is "temp".
          226  +If no schema name is specified, and the TEMP keyword is not present,
          227  +the VIEW is created in the main database.</p>
          228  +
          229  +<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 
          230  +in SQLite.  However, in many cases you can use an
          231  +<a href="lang_createtrigger.html#instead_of_trigger">INSTEAD OF trigger</a> on the view to accomplish 
          232  +the same thing.  Views are removed 
          233  +with the <a href="lang_dropview.html">DROP VIEW</a> command.</p>
          234  +
          235  +<p>If a <span class='yyterm'>column-name</span> list follows 
          236  +the <span class='yyterm'>view-name</span>, then that list determines
          237  +the names of the columns for the view.  If the <span class='yyterm'>column-name</span>
          238  +list is omitted, then the names of the columns in the view are derived
          239  +from the names of the result-set columns in the <a href="syntax/select-stmt.html">select-stmt</a>.
          240  +The use of <span class='yyterm'>column-name</span> list is recommended.  Or, if
          241  +<span class='yyterm'>column-name</span> list is omitted, then the result
          242  +columns in the <a href="lang_select.html">SELECT</a> statement that defines the view should have
          243  +well-defined names using the 
          244  +"<a href="syntax/result-column.html">AS column-alias</a>" syntax.
          245  +SQLite allows you to create views that depend on automatically 
          246  +generated column names, but you should avoid using them since the 
          247  +rules used to generate column names are not a defined part of the
          248  +interface and might change in future releases of SQLite.
          249  +
          250  +</p><p>The <span class='yyterm'>column-name</span> list syntax was added in
          251  +SQLite versions 3.9.0 (2015-10-14).
          252  +
          253  +</p>

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>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 || !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=fancy>
           95  +<div class=nosearch>
           96  +<div class="fancy_title">
           97  +CREATE VIRTUAL TABLE
           98  +</div>
           99  +</div>
          100  +
          101  +
          102  +
          103  +
          104  +
          105  +<p><b><a href="syntax/create-virtual-table-stmt.html">create-virtual-table-stmt:</a></b>
          106  +<button id='x1583' onclick='hideorshow("x1583","x1584")'>hide</button></p>
          107  + <div id='x1584' class='imgcontainer'>
          108  + <img alt="syntax diagram create-virtual-table-stmt" src="images/syntax/create-virtual-table-stmt.gif" />
          109  +</div>
          110  +
          111  +
          112  +<p>A <a href="vtab.html">virtual table</a> is an interface to an external storage or computation
          113  +engine that appears to be a table but does not actually store information
          114  +in the database file.</p>
          115  +
          116  +<p>In general, you can do anything with a <a href="vtab.html">virtual table</a> that can be done
          117  +with an ordinary table, except that you cannot create indices or triggers on a
          118  +virtual table.  Some virtual table implementations might impose additional
          119  +restrictions.  For example, many virtual tables are read-only.</p>
          120  +
          121  +<p>The <span class='yyterm'>module-name</span> is the name of an object that implements
          122  +the virtual table.  The <span class='yyterm'>module-name</span> must be registered with
          123  +the SQLite database connection using
          124  +<a href="c3ref/create_module.html">sqlite3_create_module()</a> or <a href="c3ref/create_module.html">sqlite3_create_module_v2()</a>
          125  +prior to issuing the CREATE VIRTUAL TABLE statement.
          126  +The module takes zero or more comma-separated arguments.
          127  +The arguments can be just about any text as long as it has balanced
          128  +parentheses.  The argument syntax is sufficiently general that the
          129  +arguments can be made to appear as <a href="lang_createtable.html#tablecoldef">column definitions</a> in a traditional
          130  +<a href="lang_createtable.html">CREATE TABLE</a> statement.  
          131  +SQLite passes the module arguments directly
          132  +to the <a href="vtab.html#xcreate">xCreate</a> and <a href="vtab.html#xconnect">xConnect</a> methods of the module implementation
          133  +without any interpretation.  It is the responsibility
          134  +of the module implementation to parse and interpret its own arguments.</p>
          135  +
          136  +<p>A virtual table is destroyed using the ordinary
          137  +<a href="lang_droptable.html">DROP TABLE</a> statement.  There is no
          138  +DROP VIRTUAL TABLE statement.</p>
          139  +

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>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 || !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=fancy>
           95  +<div class=nosearch>
           96  +<div class="fancy_title">
           97  +Date And Time Functions
           98  +</div>
           99  +<div class="fancy_toc">
          100  +<a onclick="toggle_toc()">
          101  +<span class="fancy_toc_mark" id="toc_mk">&#x25ba;</span>
          102  +Table Of Contents
          103  +</a>
          104  +<div id="toc_sub"><div class="fancy-toc1"><a href="#overview">1. Overview</a></div>
          105  +<div class="fancy-toc1"><a href="#time_strings">2. Time Strings</a></div>
          106  +<div class="fancy-toc1"><a href="#modifiers">3. Modifiers</a></div>
          107  +<div class="fancy-toc1"><a href="#examples">4. Examples</a></div>
          108  +<div class="fancy-toc1"><a href="#caveats_and_bugs">5. Caveats And Bugs</a></div>
          109  +</div>
          110  +</div>
          111  +<script>
          112  +function toggle_toc(){
          113  +var sub = document.getElementById("toc_sub")
          114  +var mk = document.getElementById("toc_mk")
          115  +if( sub.style.display!="block" ){
          116  +sub.style.display = "block";
          117  +mk.innerHTML = "&#x25bc;";
          118  +} else {
          119  +sub.style.display = "none";
          120  +mk.innerHTML = "&#x25ba;";
          121  +}
          122  +}
          123  +</script>
          124  +</div>
          125  +
          126  +
          127  +
          128  +
          129  +<h1 id="overview"><span>1. </span>Overview</h1>
          130  +
          131  +<p>
          132  +SQLite supports five date and time functions as follows:
          133  +</p>
          134  +
          135  +<p>
          136  +</p><ol>
          137  +<li> <b>date(</b><i>timestring, modifier, modifier, ...</i><b>)</b> </li>
          138  +<li> <b>time(</b><i>timestring, modifier, modifier, ...</i><b>)</b> </li>
          139  +<li> <b>datetime(</b><i>timestring, modifier, modifier, ...</i><b>)</b> </li>
          140  +<li> <b>julianday(</b><i>timestring, modifier, modifier, ...</i><b>)</b> </li>
          141  +<li> <b>strftime(</b><i>format, timestring, modifier, modifier, ...</i><b>)</b> </li>
          142  +</ol>
          143  +
          144  +<p>
          145  +All five date and time functions take a time string as an argument. 
          146  +The time string is followed by zero or more modifiers. 
          147  +The strftime() function also takes a format string as its first argument.
          148  +</p>
          149  +
          150  +<p>
          151  +The date and time functions use a subset of
          152  +<a href="http://en.wikipedia.org/wiki/ISO_8601">IS0-8601</a> date and time
          153  +formats.
          154  +The date() function returns the date in this format: YYYY-MM-DD. 
          155  +The time() function returns the time as HH:MM:SS. 
          156  +The datetime() function returns "YYYY-MM-DD HH:MM:SS". 
          157  +The julianday() function returns the 
          158  +<a href="http://en.wikipedia.org/wiki/Julian_day">Julian day</a> - the
          159  +number of days since noon in Greenwich on November 24, 4714 B.C. 
          160  +(<a href="http://en.wikipedia.org/wiki/Proleptic_Gregorian_calendar">Proleptic Gregorian calendar</a>).
          161  +The strftime() routine returns the date formatted according to 
          162  +the format string specified as the first argument.
          163  +The format string supports the most common substitutions found in the 
          164  +<a href="http://opengroup.org/onlinepubs/007908799/xsh/strftime.html">strftime() function</a>
          165  +from the standard C library plus two new substitutions, %f and %J.
          166  +The following is a complete list of valid strftime() substitutions:
          167  +</p>
          168  +
          169  +<blockquote>
          170  +<table border="0" cellpadding="0" cellspacing="0">
          171  +<tr><td></td><td width="10"></td><td></td></tr>
          172  +
          173  +<tr><td> %d </td><td></td><td> day of month: 00
          174  +</td></tr><tr><td> %f </td><td></td><td> fractional seconds: SS.SSS
          175  +</td></tr><tr><td> %H </td><td></td><td> hour: 00-24 
          176  +</td></tr><tr><td> %j </td><td></td><td> day of year: 001-366
          177  +</td></tr><tr><td> %J </td><td></td><td> Julian day number
          178  +</td></tr><tr><td> %m </td><td></td><td> month: 01-12
          179  +</td></tr><tr><td> %M </td><td></td><td> minute: 00-59
          180  +</td></tr><tr><td> %s </td><td></td><td> seconds since 1970-01-01
          181  +</td></tr><tr><td> %S </td><td></td><td> seconds: 00-59
          182  +</td></tr><tr><td> %w </td><td></td><td> day of week 0-6 with Sunday==0
          183  +</td></tr><tr><td> %W </td><td></td><td> week of year: 00-53
          184  +</td></tr><tr><td> %Y </td><td></td><td> year: 0000-9999
          185  +</td></tr><tr><td> %% </td><td></td><td> %
          186  +</td></tr></table>
          187  +</blockquote>
          188  +
          189  +<p>
          190  +Notice that all other date and time functions can be expressed
          191  +in terms of strftime():
          192  +</p>
          193  +
          194  +<blockquote>
          195  +<table border="0" cellpadding="0" cellspacing="0">
          196  +<tr><td><b>Function</b></td><td width="30"></td><td><b>Equivalent strftime()</b>
          197  +</td></tr><tr><td>   date(...)      </td><td></td><td>  strftime('%Y-%m-%d', ...)
          198  +</td></tr><tr><td>   time(...)      </td><td></td><td>  strftime('%H:%M:%S', ...)
          199  +</td></tr><tr><td>   datetime(...)  </td><td></td><td>  strftime('%Y-%m-%d %H:%M:%S', ...)
          200  +</td></tr><tr><td>   julianday(...) </td><td></td><td>  strftime('%J', ...)
          201  +</td></tr></table>
          202  +</blockquote>
          203  +
          204  +<p>
          205  +The only reasons for providing functions other than strftime() is
          206  +for convenience and for efficiency.
          207  +</p>
          208  +
          209  +<h1 id="time_strings"><span>2. </span>Time Strings</h1>
          210  +
          211  +<p>A time string can be in any of the following formats:</p>
          212  +
          213  +<ol>
          214  +<li> <i>YYYY-MM-DD</i>
          215  +</li><li> <i>YYYY-MM-DD HH:MM</i>
          216  +</li><li> <i>YYYY-MM-DD HH:MM:SS</i>
          217  +</li><li> <i>YYYY-MM-DD HH:MM:SS.SSS</i>
          218  +</li><li> <i>YYYY-MM-DD</i><b>T</b><i>HH:MM</i>
          219  +</li><li> <i>YYYY-MM-DD</i><b>T</b><i>HH:MM:SS</i>
          220  +</li><li> <i>YYYY-MM-DD</i><b>T</b><i>HH:MM:SS.SSS</i>
          221  +</li><li> <i>HH:MM</i>
          222  +</li><li> <i>HH:MM:SS</i>
          223  +</li><li> <i>HH:MM:SS.SSS</i>
          224  +</li><li> <b>now</b>
          225  +</li><li> <i>DDDDDDDDDD</i>
          226  +</li></ol>
          227  +
          228  +<p>
          229  +In formats 5 through 7, the "T" is a literal character separating 
          230  +the date and the time, as required by 
          231  +<a href="http://www.w3c.org/TR/NOTE-datetime">ISO-8601</a>. 
          232  +Formats 8 through 10 that specify only a time assume a date of 
          233  +2000-01-01. Format 11, the string 'now', is converted into the 
          234  +current date and time as obtained from the xCurrentTime method
          235  +of the <a href="c3ref/vfs.html">sqlite3_vfs</a> object in use.
          236  +The 'now' argument to date and time functions always returns exactly the
          237  +same value for multiple invocations within the same <a href="c3ref/step.html">sqlite3_step()</a> call.
          238  +<a href="http://en.wikipedia.org/wiki/Coordinated_Universal_Time">Universal Coordinated Time (UTC)</a> is used. 
          239  +Format 12 is the 
          240  +<a href="http://en.wikipedia.org/wiki/Julian_day">Julian day number</a>
          241  +expressed as a floating point value.
          242  +</p>
          243  +
          244  +<p>
          245  +Formats 2 through 10 may be optionally followed by a timezone indicator of the form
          246  +"<i>&#91;+-&#93;HH:MM</i>" or just "<i>Z</i>".  The date and time functions use UTC or "zulu"
          247  +time internally, and so the "Z" suffix is a no-op.  Any non-zero "HH:MM" suffix is
          248  +subtracted from the indicated date and time in order to compute zulu time.
          249  +For example, all of the following time strings are equivalent:
          250  +</p>
          251  +
          252  +<blockquote>
          253  +2013-10-07 08:23:19.120<br>
          254  +2013-10-07T08:23:19.120Z<br>
          255  +2013-10-07 04:23:19.120-04:00<br>
          256  +2456572.84952685
          257  +</blockquote>
          258  +
          259  +<p>
          260  +In formats 4, 7, and 10, the fractional seconds value SS.SSS can have
          261  +one or more digits following the decimal point.  Exactly three digits are
          262  +shown in the examples because only the first three digits are significant
          263  +to the result, but the input string can have fewer or more than three digits
          264  +and the date/time functions will still operate correctly.
          265  +Similarly, format 12 is shown with 10 significant digits, but the date/time
          266  +functions will really accept as many or as few digits as are necessary to
          267  +represent the Julian day number.
          268  +</p>
          269  +
          270  +<h1 id="modifiers"><span>3. </span>Modifiers</h1>
          271  +
          272  +<p>The time string can be followed by zero or more modifiers that 
          273  +alter date and/or time. Each modifier
          274  +is a transformation that is applied to the time value to its left.
          275  +Modifiers are applied from left to right; order is important.
          276  +The available modifiers are as follows.</p>
          277  +
          278  +<ol>
          279  +<li> NNN days
          280  +</li><li> NNN hours
          281  +</li><li> NNN minutes
          282  +</li><li> NNN.NNNN seconds
          283  +</li><li> NNN months
          284  +</li><li> NNN years
          285  +</li><li> start of month
          286  +</li><li> start of year
          287  +</li><li> start of day
          288  +</li><li> weekday N
          289  +</li><li> unixepoch
          290  +</li><li> localtime
          291  +</li><li> utc 
          292  +</li></ol>
          293  +
          294  +<p>The first six modifiers (1 through 6) 
          295  +simply add the specified amount of time to the date and time 
          296  +specified by the preceding timestring and modifiers.
          297  +The 's' character at the end of the modifier names is optional.
          298  +Note that "&plusmn;NNN months" works by rendering the original date into
          299  +the YYYY-MM-DD format, adding the &plusmn;NNN to the MM month value, then
          300  +normalizing the result.  Thus, for example, the data 2001-03-31 modified
          301  +by '+1 month' initially yields 2001-04-31, but April only has 30 days
          302  +so the date is normalized to 2001-05-01.  A similar effect occurs when
          303  +the original date is February 29 of a leapyear and the modifier is
          304  +&plusmn;N years where N is not a multiple of four.</p>
          305  +
          306  +<p>The "start of" modifiers (7 through 9) shift the date backwards 
          307  +to the beginning of the current month, year or day.</p>
          308  +
          309  +<p>The "weekday" modifier advances the date forward, if necessary,
          310  +to the next date where the weekday number is N. Sunday is 0, Monday is 1,
          311  +and so forth.
          312  +If the date is already on the desired weekday, the "weekday" modifier
          313  +leaves the date unchanged.  </p>
          314  +
          315  +<p>The "unixepoch" modifier (11) only works if it immediately follows 
          316  +a timestring in the DDDDDDDDDD format. 
          317  +This modifier causes the DDDDDDDDDD to be interpreted not 
          318  +as a Julian day number as it normally would be, but as
          319  +<a href="http://en.wikipedia.org/wiki/Unix_time">Unix Time</a> - the 
          320  +number of seconds since 1970.  If the "unixepoch" modifier does not
          321  +follow a timestring of the form DDDDDDDDDD which expresses the number
          322  +of seconds since 1970 or if other modifiers
          323  +separate the "unixepoch" modifier from prior DDDDDDDDDD then the
          324  +behavior is undefined.
          325  +For SQLite versions before 3.16.0 (2017-01-02), 
          326  +the "unixepoch" modifier only works for
          327  +dates between 0000-01-01 00:00:00 and 5352-11-01 10:52:47 (unix times
          328  +of -62167219200 through 106751991167).</p>
          329  +
          330  +<a name="localtime"></a>
          331  +
          332  +<p>The "localtime" modifier (12) assumes the time string to its left is in
          333  +Universal Coordinated Time (UTC) and adjusts the time
          334  +string so that it displays localtime.  If "localtime"
          335  +follows a time that is not UTC, then the behavior is undefined.
          336  +The "utc" modifier is the opposite of "localtime".  
          337  +"utc" assumes that the string
          338  +to its left is in the local timezone and adjusts that string to be in UTC.
          339  +If the prior string is not in localtime, then the result of "utc" is
          340  +undefined.</p>
          341  +
          342  +<h1 id="examples"><span>4. </span>Examples</h1>
          343  +
          344  +<p>Compute the current date.</p><p>
          345  +
          346  +</p><blockquote>SELECT date('now');</blockquote>
          347  +
          348  +<p>Compute the last day of the current month.</p>
          349  +
          350  +<blockquote>SELECT date('now','start of month','+1 month','-1 day');
          351  +</blockquote>
          352  +
          353  +<p>Compute the date and time given a unix timestamp 1092941466.</p>
          354  +
          355  +<blockquote>
          356  +    SELECT datetime(1092941466, 'unixepoch');
          357  +</blockquote>
          358  +
          359  +<p>Compute the date and time given a unix timestamp 1092941466, and 
          360  +compensate for your local timezone.</p>
          361  +
          362  +<blockquote>
          363  +  SELECT datetime(1092941466, 'unixepoch', 'localtime');
          364  +</blockquote>
          365  +
          366  +<p>Compute the current unix timestamp.</p>
          367  +
          368  +<blockquote>
          369  +  SELECT strftime('%s','now');
          370  +</blockquote>
          371  +
          372  +<p>Compute the number of days since the signing of the US Declaration
          373  +of Independence.</p>
          374  +
          375  +<blockquote>
          376  +  SELECT julianday('now') - julianday('1776-07-04');
          377  +</blockquote>
          378  +
          379  +<p>Compute the number of seconds since a particular moment in 2004:</p>
          380  +
          381  +<blockquote>
          382  +  SELECT strftime('%s','now') - strftime('%s','2004-01-01 02:34:56');
          383  +</blockquote>
          384  +
          385  +<p>
          386  +Compute the date of the first Tuesday in October
          387  +for the current year.
          388  +</p>
          389  +
          390  +<blockquote>
          391  +  SELECT date('now','start of year','+9 months','weekday 2');
          392  +</blockquote>
          393  +
          394  +<p>Compute the time since the unix epoch in seconds 
          395  +(like strftime('%s','now') except includes fractional part):</p>
          396  +
          397  +<blockquote>
          398  +  SELECT (julianday('now') - 2440587.5)*86400.0;
          399  +</blockquote>
          400  +
          401  +<h1 id="caveats_and_bugs"><span>5. </span>Caveats And Bugs</h1>
          402  +
          403  +<p>The computation of local time depends heavily on the whim 
          404  +of politicians and is thus difficult to get correct for 
          405  +all locales. In this implementation, the standard C library 
          406  +function localtime_r() is used to assist in the calculation of 
          407  +local time.  The 
          408  +localtime_r() C function normally only works for years
          409  +between 1970 and 2037. For dates outside this range, SQLite 
          410  +attempts to map the year into an equivalent year within 
          411  +this range, do the calculation, then map the year back.</p>
          412  +
          413  +
          414  +<p>These functions only work for dates between 0000-01-01 00:00:00
          415  +and 9999-12-31 23:59:59 (julian day numbers 1721059.5 through 5373484.5).
          416  +For dates outside that range, the results of these
          417  +functions are undefined.</p>
          418  +
          419  +<p>Non-Vista Windows platforms only support one set of DST rules. 
          420  +Vista only supports two. Therefore, on these platforms, 
          421  +historical DST calculations will be incorrect. 
          422  +For example, in the US, in 2007 the DST rules changed. 
          423  +Non-Vista Windows platforms apply the new 2007 DST rules 
          424  +to all previous years as well. Vista does somewhat better
          425  +getting results correct back to 1986, when the rules were also changed.</p>
          426  +
          427  +<p>All internal computations assume the 
          428  +<a href="http://en.wikipedia.org/wiki/Gregorian_calendar">Gregorian calendar</a>
          429  +system.  It is also assumed that every
          430  +day is exactly 86400 seconds in duration.</p>
          431  +

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>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 || !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=fancy>
           95  +<div class=nosearch>
           96  +<div class="fancy_title">
           97  +DELETE
           98  +</div>
           99  +<div class="fancy_toc">
          100  +<a onclick="toggle_toc()">
          101  +<span class="fancy_toc_mark" id="toc_mk">&#x25ba;</span>
          102  +Table Of Contents
          103  +</a>
          104  +<div id="toc_sub"><div class="fancy-toc1"><a href="#overview">1. Overview</a></div>
          105  +<div class="fancy-toc1"><a href="#restrictions_on_delete_statements_within_create_trigger">2. Restrictions on DELETE Statements Within CREATE TRIGGER</a></div>
          106  +<div class="fancy-toc1"><a href="#optional_limit_and_order_by_clauses">3. Optional LIMIT and ORDER BY clauses</a></div>
          107  +<div class="fancy-toc1"><a href="#the_truncate_optimization">4. The Truncate Optimization</a></div>
          108  +</div>
          109  +</div>
          110  +<script>
          111  +function toggle_toc(){
          112  +var sub = document.getElementById("toc_sub")
          113  +var mk = document.getElementById("toc_mk")
          114  +if( sub.style.display!="block" ){
          115  +sub.style.display = "block";
          116  +mk.innerHTML = "&#x25bc;";
          117  +} else {
          118  +sub.style.display = "none";
          119  +mk.innerHTML = "&#x25ba;";
          120  +}
          121  +}
          122  +</script>
          123  +</div>
          124  +
          125  +
          126  +
          127  +
          128  +<h1 id="overview"><span>1. </span>Overview</h1>
          129  +
          130  +<p><b><a href="syntax/delete-stmt.html">delete-stmt:</a></b>
          131  +<button id='x1585' onclick='hideorshow("x1585","x1586")'>hide</button></p>
          132  + <div id='x1586' class='imgcontainer'>
          133  + <img alt="syntax diagram delete-stmt" src="images/syntax/delete-stmt.gif" />
          134  +<p><b><a href="syntax/expr.html">expr:</a></b>
          135  +<button id='x1587' onclick='hideorshow("x1587","x1588")'>show</button></p>
          136  + <div id='x1588' style='display:none;' class='imgcontainer'>
          137  + <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
          138  +<p><b><a href="syntax/filter-clause.html">filter-clause:</a></b>
          139  +<button id='x1589' onclick='hideorshow("x1589","x1590")'>show</button></p>
          140  + <div id='x1590' style='display:none;' class='imgcontainer'>
          141  + <img alt="syntax diagram filter-clause" src="images/syntax/filter-clause.gif" />
          142  +</div>
          143  +<p><b><a href="syntax/literal-value.html">literal-value:</a></b>
          144  +<button id='x1591' onclick='hideorshow("x1591","x1592")'>show</button></p>
          145  + <div id='x1592' style='display:none;' class='imgcontainer'>
          146  + <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
          147  +</div>
          148  +<p><b><a href="syntax/over-clause.html">over-clause:</a></b>
          149  +<button id='x1593' onclick='hideorshow("x1593","x1594")'>show</button></p>
          150  + <div id='x1594' style='display:none;' class='imgcontainer'>
          151  + <img alt="syntax diagram over-clause" src="images/syntax/over-clause.gif" />
          152  +<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
          153  +<button id='x1595' onclick='hideorshow("x1595","x1596")'>show</button></p>
          154  + <div id='x1596' style='display:none;' class='imgcontainer'>
          155  + <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
          156  +</div>
          157  +<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
          158  +<button id='x1597' onclick='hideorshow("x1597","x1598")'>show</button></p>
          159  + <div id='x1598' style='display:none;' class='imgcontainer'>
          160  + <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
          161  +</div>
          162  +</div>
          163  +<p><b><a href="syntax/raise-function.html">raise-function:</a></b>
          164  +<button id='x1599' onclick='hideorshow("x1599","x1600")'>show</button></p>
          165  + <div id='x1600' style='display:none;' class='imgcontainer'>
          166  + <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
          167  +</div>
          168  +<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
          169  +<button id='x1601' onclick='hideorshow("x1601","x1602")'>show</button></p>
          170  + <div id='x1602' 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='x1603' onclick='hideorshow("x1603","x1604")'>show</button></p>
          174  + <div id='x1604' 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='x1605' onclick='hideorshow("x1605","x1606")'>show</button></p>
          179  + <div id='x1606' 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/join-clause.html">join-clause:</a></b>
          183  +<button id='x1607' onclick='hideorshow("x1607","x1608")'>show</button></p>
          184  + <div id='x1608' style='display:none;' class='imgcontainer'>
          185  + <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
          186  +<p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
          187  +<button id='x1609' onclick='hideorshow("x1609","x1610")'>show</button></p>
          188  + <div id='x1610' style='display:none;' class='imgcontainer'>
          189  + <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
          190  +</div>
          191  +<p><b><a href="syntax/join-operator.html">join-operator:</a></b>
          192  +<button id='x1611' onclick='hideorshow("x1611","x1612")'>show</button></p>
          193  + <div id='x1612' style='display:none;' class='imgcontainer'>
          194  + <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
          195  +</div>
          196  +</div>
          197  +<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
          198  +<button id='x1613' onclick='hideorshow("x1613","x1614")'>show</button></p>
          199  + <div id='x1614' style='display:none;' class='imgcontainer'>
          200  + <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
          201  +</div>
          202  +<p><b><a href="syntax/result-column.html">result-column:</a></b>
          203  +<button id='x1615' onclick='hideorshow("x1615","x1616")'>show</button></p>
          204  + <div id='x1616' style='display:none;' class='imgcontainer'>
          205  + <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
          206  +</div>
          207  +<p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
          208  +<button id='x1617' onclick='hideorshow("x1617","x1618")'>show</button></p>
          209  + <div id='x1618' style='display:none;' class='imgcontainer'>
          210  + <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
          211  +</div>
          212  +<p><b><a href="syntax/window-defn.html">window-defn:</a></b>
          213  +<button id='x1619' onclick='hideorshow("x1619","x1620")'>show</button></p>
          214  + <div id='x1620' style='display:none;' class='imgcontainer'>
          215  + <img alt="syntax diagram window-defn" src="images/syntax/window-defn.gif" />
          216  +<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
          217  +<button id='x1621' onclick='hideorshow("x1621","x1622")'>show</button></p>
          218  + <div id='x1622' style='display:none;' class='imgcontainer'>
          219  + <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
          220  +</div>
          221  +</div>
          222  +</div>
          223  +<p><b><a href="syntax/type-name.html">type-name:</a></b>
          224  +<button id='x1623' onclick='hideorshow("x1623","x1624")'>show</button></p>
          225  + <div id='x1624' style='display:none;' class='imgcontainer'>
          226  + <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
          227  +<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
          228  +<button id='x1625' onclick='hideorshow("x1625","x1626")'>show</button></p>
          229  + <div id='x1626' style='display:none;' class='imgcontainer'>
          230  + <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
          231  +</div>
          232  +</div>
          233  +</div>
          234  +<p><b><a href="syntax/qualified-table-name.html">qualified-table-name:</a></b>
          235  +<button id='x1627' onclick='hideorshow("x1627","x1628")'>show</button></p>
          236  + <div id='x1628' style='display:none;' class='imgcontainer'>
          237  + <img alt="syntax diagram qualified-table-name" src="images/syntax/qualified-table-name.gif" />
          238  +</div>
          239  +<p><b><a href="syntax/with-clause.html">with-clause:</a></b>
          240  +<button id='x1629' onclick='hideorshow("x1629","x1630")'>show</button></p>
          241  + <div id='x1630' style='display:none;' class='imgcontainer'>
          242  + <img alt="syntax diagram with-clause" src="images/syntax/with-clause.gif" />
          243  +<p><b><a href="syntax/cte-table-name.html">cte-table-name:</a></b>
          244  +<button id='x1631' onclick='hideorshow("x1631","x1632")'>show</button></p>
          245  + <div id='x1632' style='display:none;' class='imgcontainer'>
          246  + <img alt="syntax diagram cte-table-name" src="images/syntax/cte-table-name.gif" />
          247  +</div>
          248  +<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
          249  +<button id='x1633' onclick='hideorshow("x1633","x1634")'>show</button></p>
          250  + <div id='x1634' style='display:none;' class='imgcontainer'>
          251  + <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
          252  +<p><b><a href="syntax/common-table-expression.html">common-table-expression:</a></b>
          253  +<button id='x1635' onclick='hideorshow("x1635","x1636")'>show</button></p>
          254  + <div id='x1636' style='display:none;' class='imgcontainer'>
          255  + <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
          256  +</div>
          257  +<p><b><a href="syntax/compound-operator.html">compound-operator:</a></b>
          258  +<button id='x1637' onclick='hideorshow("x1637","x1638")'>show</button></p>
          259  + <div id='x1638' style='display:none;' class='imgcontainer'>
          260  + <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
          261  +</div>
          262  +<p><b><a href="syntax/join-clause.html">join-clause:</a></b>
          263  +<button id='x1639' onclick='hideorshow("x1639","x1640")'>show</button></p>
          264  + <div id='x1640' style='display:none;' class='imgcontainer'>
          265  + <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
          266  +<p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
          267  +<button id='x1641' onclick='hideorshow("x1641","x1642")'>show</button></p>
          268  + <div id='x1642' style='display:none;' class='imgcontainer'>
          269  + <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
          270  +</div>
          271  +<p><b><a href="syntax/join-operator.html">join-operator:</a></b>
          272  +<button id='x1643' onclick='hideorshow("x1643","x1644")'>show</button></p>
          273  + <div id='x1644' style='display:none;' class='imgcontainer'>
          274  + <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
          275  +</div>
          276  +</div>
          277  +<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
          278  +<button id='x1645' onclick='hideorshow("x1645","x1646")'>show</button></p>
          279  + <div id='x1646' style='display:none;' class='imgcontainer'>
          280  + <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
          281  +</div>
          282  +<p><b><a href="syntax/result-column.html">result-column:</a></b>
          283  +<button id='x1647' onclick='hideorshow("x1647","x1648")'>show</button></p>
          284  + <div id='x1648' style='display:none;' class='imgcontainer'>
          285  + <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
          286  +</div>
          287  +<p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
          288  +<button id='x1649' onclick='hideorshow("x1649","x1650")'>show</button></p>
          289  + <div id='x1650' style='display:none;' class='imgcontainer'>
          290  + <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
          291  +</div>
          292  +<p><b><a href="syntax/window-defn.html">window-defn:</a></b>
          293  +<button id='x1651' onclick='hideorshow("x1651","x1652")'>show</button></p>
          294  + <div id='x1652' style='display:none;' class='imgcontainer'>
          295  + <img alt="syntax diagram window-defn" src="images/syntax/window-defn.gif" />
          296  +<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
          297  +<button id='x1653' onclick='hideorshow("x1653","x1654")'>show</button></p>
          298  + <div id='x1654' style='display:none;' class='imgcontainer'>
          299  + <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
          300  +</div>
          301  +</div>
          302  +</div>
          303  +</div>
          304  +</div>
          305  +
          306  +
          307  +<p>The DELETE command removes records from the table identified by the
          308  +   <a href="syntax/qualified-table-name.html">qualified-table-name</a>.
          309  +
          310  +</p><p>If the WHERE clause is not present, all records in the table are deleted.
          311  +   If a WHERE clause is supplied, then only those rows for which the
          312  +   WHERE clause <a href="lang_expr.html#booleanexpr">boolean expression</a> is true are deleted.
          313  +   Rows for which the expression is false or NULL are retained.
          314  +
          315  +</p><h1 id="restrictions_on_delete_statements_within_create_trigger"><span>2. </span>Restrictions on DELETE Statements Within CREATE TRIGGER</h1>
          316  +
          317  +<p>The following restrictions apply to DELETE statements that occur within the
          318  +   body of a <a href="lang_createtrigger.html">CREATE TRIGGER</a> statement:
          319  +
          320  +</p><ul>
          321  +  <li><p>The <span class='yyterm'>table-name</span> specified as part of a 
          322  +    DELETE statement within
          323  +    a trigger body must be unqualified.  In other words, the
          324  +    <i>schema-name</i><b>.</b> prefix on the table name is not allowed 
          325  +    within triggers. If the table to which the trigger is attached is
          326  +    not in the temp database, then DELETE statements within the trigger
          327  +    body must operate on tables within the same database as it. If the table
          328  +    to which the trigger is attached is in the TEMP database, then the
          329  +    unqualified name of the table being deleted is resolved in the same way as
          330  +    it is for a top-level statement (by searching first the TEMP database, then
          331  +    the main database, then any other databases in the order they were
          332  +    attached).
          333  +    
          334  +  </p></li><li><p>The INDEXED BY and NOT INDEXED clauses are not allowed on DELETE
          335  +    statements within triggers.</p>
          336  +
          337  +  </li><li><p>The LIMIT and ORDER BY clauses (described below) are unsupported for
          338  +    DELETE statements within triggers.</p>
          339  +</li></ul>
          340  +
          341  +<h1 id="optional_limit_and_order_by_clauses"><span>3. </span>Optional LIMIT and ORDER BY clauses</h1>
          342  +
          343  +<p>If SQLite is compiled with the <a href="compile.html#enable_update_delete_limit">SQLITE_ENABLE_UPDATE_DELETE_LIMIT</a>
          344  +compile-time option, then the syntax of the DELETE statement is
          345  +extended by the addition of optional ORDER BY and LIMIT clauses:</p>
          346  +
          347  +<p><b><a href="syntax/delete-stmt-limited.html">delete-stmt-limited:</a></b></p><div class='imgcontainer'>
          348  + <img alt="syntax diagram delete-stmt-limited" src="images/syntax/delete-stmt-limited.gif"></img>
          349  + </div>
          350  +
          351  +
          352  +<p>If a DELETE statement has a LIMIT clause, the maximum number of rows that
          353  +will be deleted is found by evaluating the accompanying expression and casting
          354  +it to an integer value. If the result of the evaluating the LIMIT clause
          355  +cannot be losslessly converted to an integer value, it is an error. A 
          356  +negative LIMIT value is interpreted as "no limit". If the DELETE statement 
          357  +also has an OFFSET clause, then it is similarly evaluated and cast to an
          358  +integer value. Again, it is an error if the value cannot be losslessly
          359  +converted to an integer. If there is no OFFSET clause, or the calculated
          360  +integer value is negative, the effective OFFSET value is zero.
          361  +
          362  +</p><p>If the DELETE statement has an ORDER BY clause, then all rows that would 
          363  +be deleted in the absence of the LIMIT clause are sorted according to the 
          364  +ORDER BY. The first <i>M</i> rows, where <i>M</i> is the value found by
          365  +evaluating the OFFSET clause expression, are skipped, and the following 
          366  +<i>N</i>, where <i>N</i> is the value of the LIMIT expression, are deleted.
          367  +If there are less than <i>N</i> rows remaining after taking the OFFSET clause
          368  +into account, or if the LIMIT clause evaluated to a negative value, then all
          369  +remaining rows are deleted.
          370  +
          371  +</p><p>If the DELETE statement has no ORDER BY clause, then all rows that
          372  +would be deleted in the absence of the LIMIT clause are assembled in an
          373  +arbitrary order before applying the LIMIT and OFFSET clauses to determine 
          374  +the subset that are actually deleted.
          375  +
          376  +</p><p>The ORDER BY clause on a DELETE statement is used only to determine which
          377  +rows fall within the LIMIT. The order in which rows are deleted is arbitrary
          378  +and is not influenced by the ORDER BY clause.
          379  +
          380  +<a name="truncateopt"></a>
          381  +
          382  +</p><h1 id="the_truncate_optimization"><span>4. </span>The Truncate Optimization</h1>
          383  +
          384  +<p>When the WHERE is omitted from a DELETE statement and the table
          385  +being deleted has no triggers,
          386  +SQLite uses an optimization to erase the entire table content
          387  +without having to visit each row of the table individually.
          388  +This "truncate" optimization makes the delete run much faster.
          389  +Prior to SQLite <a href="releaselog/3_6_5.html">version 3.6.5</a> (2008-11-12), the truncate optimization
          390  +also meant that the <a href="c3ref/changes.html">sqlite3_changes()</a> and
          391  +<a href="c3ref/total_changes.html">sqlite3_total_changes()</a> interfaces
          392  +and the <a href="pragma.html#pragma_count_changes">count_changes pragma</a>
          393  +will not actually return the number of deleted rows.  
          394  +That problem has been fixed as of <a href="releaselog/3_6_5.html">version 3.6.5</a> (2008-11-12).
          395  +
          396  +</p><p>The truncate optimization can be permanently disabled for all queries
          397  +by recompiling
          398  +SQLite with the <a href="compile.html#omit_truncate_optimization">SQLITE_OMIT_TRUNCATE_OPTIMIZATION</a> compile-time switch.</p>
          399  +
          400  +<p>The truncate optimization can also be disabled at runtime using
          401  +the <a href="c3ref/set_authorizer.html">sqlite3_set_authorizer()</a> interface.  If an authorizer callback
          402  +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
          403  +the DELETE operation will proceed but the truncate optimization will
          404  +be bypassed and rows will be deleted one by one.</p>
          405  +

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>DETACH</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 || !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=fancy>
           95  +<div class=nosearch>
           96  +<div class="fancy_title">
           97  +DETACH
           98  +</div>
           99  +</div>
          100  +
          101  +
          102  +
          103  +
          104  +<p><b><a href="syntax/detach-stmt.html">detach-stmt:</a></b>
          105  +<button id='x1655' onclick='hideorshow("x1655","x1656")'>hide</button></p>
          106  + <div id='x1656' class='imgcontainer'>
          107  + <img alt="syntax diagram detach-stmt" src="images/syntax/detach-stmt.gif" />
          108  +</div>
          109  +
          110  +
          111  +<p>This statement detaches an additional database connection previously 
          112  +attached using the <a href="lang_attach.html">ATTACH</a> statement.  
          113  +When not in <a href="sharedcache.html">shared cache mode</a>, 
          114  +it is possible to have the same database file attached multiple times using 
          115  +different names, and detaching one connection to a file will leave the 
          116  +others intact.</p>
          117  +
          118  +<p>
          119  +In <a href="sharedcache.html">shared cache mode</a>, attempting to attach the same database file more
          120  +than once results in an error.
          121  +</p>

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>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 || !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=fancy>
           95  +<div class=nosearch>
           96  +<div class="fancy_title">
           97  +DROP INDEX
           98  +</div>
           99  +</div>
          100  +
          101  +
          102  +
          103  +
          104  +<p><b><a href="syntax/drop-index-stmt.html">drop-index-stmt:</a></b>
          105  +<button id='x1657' onclick='hideorshow("x1657","x1658")'>hide</button></p>
          106  + <div id='x1658' class='imgcontainer'>
          107  + <img alt="syntax diagram drop-index-stmt" src="images/syntax/drop-index-stmt.gif" />
          108  +</div>
          109  +
          110  +
          111  +<p>The DROP INDEX statement removes an index added
          112  +with the <a href="lang_createindex.html">CREATE INDEX</a> statement.  The index is completely removed from
          113  +the disk.  The only way to recover the index is to reenter the
          114  +appropriate <a href="lang_createindex.html">CREATE INDEX</a> command.</p>
          115  +
          116  +

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>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 || !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=fancy>
           95  +<div class=nosearch>
           96  +<div class="fancy_title">
           97  +DROP TABLE
           98  +</div>
           99  +</div>
          100  +
          101  +
          102  +
          103  +
          104  +<p><b><a href="syntax/drop-table-stmt.html">drop-table-stmt:</a></b>
          105  +<button id='x1659' onclick='hideorshow("x1659","x1660")'>hide</button></p>
          106  + <div id='x1660' class='imgcontainer'>
          107  + <img alt="syntax diagram drop-table-stmt" src="images/syntax/drop-table-stmt.gif" />
          108  +</div>
          109  +
          110  +
          111  +<p>The DROP TABLE statement removes a table added with the
          112  +<a href="lang_createtable.html">CREATE TABLE</a> statement.  The name specified is the
          113  +table name.  The dropped table is completely removed from the database 
          114  +schema and the disk file.  The table can not be recovered.  
          115  +All indices and triggers
          116  +associated with the table are also deleted.</p>
          117  +
          118  +<p>The optional IF EXISTS clause suppresses the error that would normally
          119  +result if the table does not exist.</p>
          120  +
          121  +<p>If <a href="foreignkeys.html">foreign key constraints</a> are enabled, a DROP TABLE command performs an
          122  +implicit <a href="lang_delete.html">DELETE FROM</a> command before removing the
          123  +table from the database schema. Any triggers attached to the table are
          124  +dropped from the database schema before the implicit DELETE FROM
          125  +is executed, so this cannot cause any triggers to fire. By contrast, an
          126  +implicit DELETE FROM does cause any configured
          127  +<a href="foreignkeys.html#fk_actions">foreign key actions</a> to take place. 
          128  +If the implicit DELETE FROM executed
          129  +as part of a DROP TABLE command violates any immediate foreign key constraints,
          130  +an error is returned and the table is not dropped. If 
          131  +the implicit DELETE FROM causes any 
          132  +deferred foreign key constraints to be violated, and the violations still
          133  +exist when the transaction is committed, an error is returned at the time
          134  +of commit.
          135  +</p>

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>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 || !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  +
           97  +<p><b><a href="syntax/drop-trigger-stmt.html">drop-trigger-stmt:</a></b>
           98  +<button id='x1661' onclick='hideorshow("x1661","x1662")'>hide</button></p>
           99  + <div id='x1662' class='imgcontainer'>
          100  + <img alt="syntax diagram drop-trigger-stmt" src="images/syntax/drop-trigger-stmt.gif" />
          101  +</div>
          102  +
          103  +
          104  +<p>The DROP TRIGGER statement removes a trigger created by the 
          105  +<a href="lang_createtrigger.html">CREATE TRIGGER</a> statement. Once removed, the trigger definition is no
          106  +longer present in the sqlite_master (or sqlite_temp_master) table and is
          107  +not fired by any subsequent INSERT, UPDATE or DELETE statements.
          108  +
          109  +<p>Note that triggers are automatically dropped when the associated table is
          110  +dropped.
          111  +

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>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 || !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=fancy>
           95  +<div class=nosearch>
           96  +<div class="fancy_title">
           97  +DROP VIEW
           98  +</div>
           99  +</div>
          100  +
          101  +
          102  +
          103  +
          104  +<p><b><a href="syntax/drop-view-stmt.html">drop-view-stmt:</a></b>
          105  +<button id='x1663' onclick='hideorshow("x1663","x1664")'>hide</button></p>
          106  + <div id='x1664' class='imgcontainer'>
          107  + <img alt="syntax diagram drop-view-stmt" src="images/syntax/drop-view-stmt.gif" />
          108  +</div>
          109  +
          110  +
          111  +<p>The DROP VIEW statement removes a view created by the <a href="lang_createview.html">CREATE VIEW</a> 
          112  +  statement. The view definition is removed from the database schema, but 
          113  +  no actual data in the underlying base tables is modified.
          114  +
          115  +</p><p>The view to drop is identified by the view-name and optional 
          116  +  schema-name specified as part of the DROP VIEW statement. This 
          117  +  reference is resolved using the standard procedure for <a href="lang_naming.html">object resolution</a>.
          118  +
          119  +</p><p>
          120  +  If the specified view cannot be found and the IF EXISTS clause is not 
          121  +  present, it is an error. If the specified view cannot be found and an IF
          122  +  EXISTS clause is present in the DROP VIEW statement, then the statement
          123  +  is a no-op.
          124  +
          125  +
          126  +</p>

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>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 || !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=fancy>
           95  +<div class=nosearch>
           96  +<div class="fancy_title">
           97  +EXPLAIN
           98  +</div>
           99  +</div>
          100  +
          101  +
          102  +
          103  +
          104  +<h1 id="syntax"><span>1. </span>Syntax</h1>
          105  +<p><b><a href="syntax/sql-stmt.html">sql-stmt:</a></b></p><div class='imgcontainer'>
          106  + <img alt="syntax diagram sql-stmt" src="images/syntax/sql-stmt.gif"></img>
          107  + </div>
          108  +
          109  +
          110  +<h1 id="description"><span>2. </span>Description</h1>
          111  +
          112  +<p>An SQL statement can be preceded by the keyword "EXPLAIN" or
          113  +by the phrase "EXPLAIN QUERY PLAN".  Either modification causes the
          114  +SQL statement to behave as a query and to return information about
          115  +how the SQL statement would have operated if the EXPLAIN keyword or
          116  +phrase had been omitted.</p>
          117  +
          118  +<p>The output from EXPLAIN and EXPLAIN QUERY PLAN is intended for
          119  +interactive analysis and troubleshooting only.  The details of the 
          120  +output format are subject to change from one release of SQLite to the next.
          121  +Applications should not use EXPLAIN or EXPLAIN QUERY PLAN since
          122  +their exact behavior is variable and only partially documented.</p>
          123  +
          124  +<p>When the EXPLAIN keyword appears by itself it causes the statement
          125  +to behave as a query that returns the sequence of 
          126  +<a href="opcode.html">virtual machine instructions</a> it would have used to execute the command had
          127  +the EXPLAIN keyword not been present. When the EXPLAIN QUERY PLAN phrase
          128  +appears, the statement returns high-level information regarding the query
          129  +plan that would have been used.
          130  +
          131  +</p><p>The EXPLAIN QUERY PLAN command is described in 
          132  +<a href="eqp.html">more detail here</a>.
          133  +
          134  +</p><h2 id="explain_operates_at_run_time_not_at_prepare_time"><span>2.1. </span>EXPLAIN operates at run-time, not at prepare-time</h2>
          135  +
          136  +<p>The EXPLAIN and EXPLAIN QUERY PLAN prefixes affect the behavior of
          137  +running a <a href="c3ref/stmt.html">prepared statement</a> using <a href="c3ref/step.html">sqlite3_step()</a>.  The process of
          138  +generating a new prepared statement using <a href="c3ref/prepare.html">sqlite3_prepare()</a> or similar
          139  +is (mostly) unaffected by EXPLAIN.  (The exception to the previous sentence
          140  +is that some special opcodes used by EXPLAIN QUERY PLAN are omitted when
          141  +building an EXPLAIN QUERY PLAN prepared statement, as a performance
          142  +optimization.)
          143  +
          144  +</p><p>This means that actions that occur during sqlite3_prepare() are
          145  +unaffected by EXPLAIN.
          146  +
          147  +</p><ul>
          148  +<li><p>
          149  +Some <a href="pragma.html#syntax">PRAGMA</a> statements do their work during sqlite3_prepare() rather
          150  +than during sqlite3_step().  Those PRAGMA statements are unaffected
          151  +by EXPLAIN.  They operate the same with or without the EXPLAIN prefix.
          152  +The set of PRAGMA statements that are unaffected by EXPLAIN can vary
          153  +from one release to the next.  Some PRAGMA statements operate during
          154  +sqlite3_prepare() depending on their arguments.  For consistent
          155  +results, avoid using EXPLAIN on PRAGMA statements.
          156  +
          157  +</p></li><li><p>
          158  +The <a href="c3ref/set_authorizer.html">authorizer callback</a> is invoked regardless of the presence of
          159  +EXPLAIN or EXPLAIN QUERY PLAN.
          160  +</p></li></ul>
          161  +

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

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>The INDEXED BY 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 || !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=fancy>
           95  +<div class=nosearch>
           96  +<div class="fancy_title">
           97  +The INDEXED BY Clause
           98  +</div>
           99  +</div>
          100  +
          101  +
          102  +
          103  +
          104  +<h1 id="how_indexed_by_works"><span>1. </span>How INDEXED BY Works</h1>
          105  +
          106  +<p>The INDEXED BY phrase forces the <a href="optoverview.html">SQLite query planner</a> to use a
          107  +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.
          108  +The INDEXED BY phrase is an SQLite extension and
          109  +is not portable to other SQL database engines.</p>
          110  +
          111  +<p><b><a href="syntax/qualified-table-name.html">qualified-table-name:</a></b>
          112  +<button id='x1705' onclick='hideorshow("x1705","x1706")'>hide</button></p>
          113  + <div id='x1706' class='imgcontainer'>
          114  + <img alt="syntax diagram qualified-table-name" src="images/syntax/qualified-table-name.gif" />
          115  +</div>
          116  +
          117  +
          118  +<p>The "INDEXED BY <span class='yyterm'>index-name</span>" phrase specifies 
          119  +that the named index
          120  +must be used in order to look up values on the preceding table.
          121  +If <span class='yyterm'>index-name</span> does not exist or cannot be used 
          122  +for the query, then the preparation of the SQL statement fails.
          123  +The "NOT INDEXED" clause specifies that no index shall be used when
          124  +accessing the preceding table, including implied indices create by
          125  +UNIQUE and PRIMARY KEY constraints.  However, the <a href="lang_createtable.html#rowid">rowid</a>
          126  +can still be used to look up entries even when "NOT INDEXED" is specified.</p>
          127  +
          128  +<p>Some SQL database engines provide non-standard "hint" mechanisms which
          129  +can be used to give the query optimizer clues about what indices it should
          130  +use for a particular statement.  The INDEX BY clause of SQLite is 
          131  +<em>not</em> a hinting mechanism and it should not be used as such.
          132  +The INDEXED BY clause does not give the optimizer hints about which index
          133  +to use; it gives the optimizer a requirement of which index to use.
          134  +If the query optimizer is unable to use the index specified by the
          135  +INDEX BY clause, then the query will fail with an error.</p>
          136  +
          137  +<p>The INDEXED BY clause is <em>not</em> intended for use in tuning
          138  +the performance of a query.  The intent of the INDEXED BY clause is
          139  +to raise a run-time error if a schema change, such as dropping or
          140  +creating an index, causes the query plan for a time-sensitive query
          141  +to change.  The INDEXED BY clause is designed to help detect
          142  +undesirable query plan changes during regression testing.
          143  +Application 
          144  +developers are admonished to omit all use of INDEXED BY during
          145  +application design, implementation, testing, and tuning.  If
          146  +INDEXED BY is to be used at all, it should be inserted at the very
          147  +end of the development process when "locking down" a design.</p>
          148  +
          149  +<h1 id="see_also"><span>2. </span>See Also</h1>
          150  +
          151  +<ol>
          152  +<li><p>The <a href="queryplanner-ng.html#howtofix">query planner checklist</a> describes steps that application
          153  +developers should following to help resolve query planner problems.
          154  +Notice the that the use of INDEXED BY is a last resort, to be used only
          155  +when all other measures fail.</p>
          156  +
          157  +</li><li><p><a href="optoverview.html#uplus">The unary "+" operator</a>
          158  +can be used to disqualify terms in the WHERE clause from use by indices.
          159  +Careful use of unary + can sometimes help prevent the query planner from
          160  +choosing a poor index without restricting it to using one specific index.
          161  +Careful placement of unary + operators is a better method for controlling 
          162  +which indices are used by a query.</p>
          163  +
          164  +</li><li><p>The <a href="c3ref/stmt_status.html">sqlite3_stmt_status()</a> C/C++ interface together with the
          165  +<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
          166  +can be used to detect at run-time when an SQL statement is not
          167  +making effective use of indices.  Many applications may prefer to
          168  +use the <a href="c3ref/stmt_status.html">sqlite3_stmt_status()</a> interface to detect index misuse
          169  +rather than the INDEXED BY phrase described here.</p>
          170  +</li></ol>
          171  +

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>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 || !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=fancy>
           95  +<div class=nosearch>
           96  +<div class="fancy_title">
           97  +INSERT
           98  +</div>
           99  +</div>
          100  +
          101  +
          102  +
          103  +
          104  +
          105  +<p><b><a href="syntax/insert-stmt.html">insert-stmt:</a></b>
          106  +<button id='x1707' onclick='hideorshow("x1707","x1708")'>hide</button></p>
          107  + <div id='x1708' class='imgcontainer'>
          108  + <img alt="syntax diagram insert-stmt" src="images/syntax/insert-stmt.gif" />
          109  +<p><b><a href="syntax/expr.html">expr:</a></b>
          110  +<button id='x1709' onclick='hideorshow("x1709","x1710")'>show</button></p>
          111  + <div id='x1710' style='display:none;' class='imgcontainer'>
          112  + <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
          113  +<p><b><a href="syntax/filter-clause.html">filter-clause:</a></b>
          114  +<button id='x1711' onclick='hideorshow("x1711","x1712")'>show</button></p>
          115  + <div id='x1712' style='display:none;' class='imgcontainer'>
          116  + <img alt="syntax diagram filter-clause" src="images/syntax/filter-clause.gif" />
          117  +</div>
          118  +<p><b><a href="syntax/literal-value.html">literal-value:</a></b>
          119  +<button id='x1713' onclick='hideorshow("x1713","x1714")'>show</button></p>
          120  + <div id='x1714' style='display:none;' class='imgcontainer'>
          121  + <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
          122  +</div>
          123  +<p><b><a href="syntax/over-clause.html">over-clause:</a></b>
          124  +<button id='x1715' onclick='hideorshow("x1715","x1716")'>show</button></p>
          125  + <div id='x1716' style='display:none;' class='imgcontainer'>
          126  + <img alt="syntax diagram over-clause" src="images/syntax/over-clause.gif" />
          127  +<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
          128  +<button id='x1717' onclick='hideorshow("x1717","x1718")'>show</button></p>
          129  + <div id='x1718' style='display:none;' class='imgcontainer'>
          130  + <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
          131  +</div>
          132  +<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
          133  +<button id='x1719' onclick='hideorshow("x1719","x1720")'>show</button></p>
          134  + <div id='x1720' style='display:none;' class='imgcontainer'>
          135  + <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
          136  +</div>
          137  +</div>
          138  +<p><b><a href="syntax/raise-function.html">raise-function:</a></b>
          139  +<button id='x1721' onclick='hideorshow("x1721","x1722")'>show</button></p>
          140  + <div id='x1722' style='display:none;' class='imgcontainer'>
          141  + <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
          142  +</div>
          143  +<p><b><a href="syntax/type-name.html">type-name:</a></b>
          144  +<button id='x1723' onclick='hideorshow("x1723","x1724")'>show</button></p>
          145  + <div id='x1724' style='display:none;' class='imgcontainer'>
          146  + <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
          147  +<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
          148  +<button id='x1725' onclick='hideorshow("x1725","x1726")'>show</button></p>
          149  + <div id='x1726' style='display:none;' class='imgcontainer'>
          150  + <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
          151  +</div>
          152  +</div>
          153  +</div>
          154  +<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
          155  +<button id='x1727' onclick='hideorshow("x1727","x1728")'>show</button></p>
          156  + <div id='x1728' style='display:none;' class='imgcontainer'>
          157  + <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
          158  +<p><b><a href="syntax/common-table-expression.html">common-table-expression:</a></b>
          159  +<button id='x1729' onclick='hideorshow("x1729","x1730")'>show</button></p>
          160  + <div id='x1730' style='display:none;' class='imgcontainer'>
          161  + <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
          162  +</div>
          163  +<p><b><a href="syntax/compound-operator.html">compound-operator:</a></b>
          164  +<button id='x1731' onclick='hideorshow("x1731","x1732")'>show</button></p>
          165  + <div id='x1732' style='display:none;' class='imgcontainer'>
          166  + <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
          167  +</div>
          168  +<p><b><a href="syntax/join-clause.html">join-clause:</a></b>
          169  +<button id='x1733' onclick='hideorshow("x1733","x1734")'>show</button></p>
          170  + <div id='x1734' style='display:none;' class='imgcontainer'>
          171  + <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
          172  +<p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
          173  +<button id='x1735' onclick='hideorshow("x1735","x1736")'>show</button></p>
          174  + <div id='x1736' style='display:none;' class='imgcontainer'>
          175  + <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
          176  +</div>
          177  +<p><b><a href="syntax/join-operator.html">join-operator:</a></b>
          178  +<button id='x1737' onclick='hideorshow("x1737","x1738")'>show</button></p>
          179  + <div id='x1738' style='display:none;' class='imgcontainer'>
          180  + <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
          181  +</div>
          182  +</div>
          183  +<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
          184  +<button id='x1739' onclick='hideorshow("x1739","x1740")'>show</button></p>
          185  + <div id='x1740' style='display:none;' class='imgcontainer'>
          186  + <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
          187  +</div>
          188  +<p><b><a href="syntax/result-column.html">result-column:</a></b>
          189  +<button id='x1741' onclick='hideorshow("x1741","x1742")'>show</button></p>
          190  + <div id='x1742' style='display:none;' class='imgcontainer'>
          191  + <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
          192  +</div>
          193  +<p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
          194  +<button id='x1743' onclick='hideorshow("x1743","x1744")'>show</button></p>
          195  + <div id='x1744' style='display:none;' class='imgcontainer'>
          196  + <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
          197  +</div>
          198  +<p><b><a href="syntax/window-defn.html">window-defn:</a></b>
          199  +<button id='x1745' onclick='hideorshow("x1745","x1746")'>show</button></p>
          200  + <div id='x1746' style='display:none;' class='imgcontainer'>
          201  + <img alt="syntax diagram window-defn" src="images/syntax/window-defn.gif" />
          202  +<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
          203  +<button id='x1747' onclick='hideorshow("x1747","x1748")'>show</button></p>
          204  + <div id='x1748' style='display:none;' class='imgcontainer'>
          205  + <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
          206  +</div>
          207  +</div>
          208  +</div>
          209  +<p><b><a href="syntax/upsert-clause.html">upsert-clause:</a></b>
          210  +<button id='x1749' onclick='hideorshow("x1749","x1750")'>show</button></p>
          211  + <div id='x1750' style='display:none;' class='imgcontainer'>
          212  + <img alt="syntax diagram upsert-clause" src="images/syntax/upsert-clause.gif" />
          213  +<p><b><a href="syntax/column-name-list.html">column-name-list:</a></b>