System.Data.SQLite

Check-in [d9f14318b7]
Login

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

Overview
Comment:Pickup the latest SQLite core library 3.32.0 docs from upstream.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | core-3.32.0
Files: files | file ages | folders
SHA1: d9f14318b7873d65cac2b77843e0a2c69cb02e3e
User & Date: mistachkin 2020-05-22 21:38:29.670
Context
2020-05-24
00:46
Merge updates from trunk. check-in: 8118694807 user: mistachkin tags: core-3.32.0
2020-05-22
21:38
Pickup the latest SQLite core library 3.32.0 docs from upstream. check-in: d9f14318b7 user: mistachkin tags: core-3.32.0
21:31
Update SQLite core library to the 3.32.0 release. check-in: ca54213ea5 user: mistachkin tags: core-3.32.0
Changes
Unified Diff Ignore Whitespace Patch
Changes to Doc/Extra/Core/images/syntax/insert-stmt.gif.

cannot compute difference between binary files

Changes to Doc/Extra/Core/lang.html.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148



149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
<a href="syntaxdiagrams.html">syntax diagrams</a>.

<p>The following syntax documentation topics are available:</p>

<table width="100%" cellpadding="5" border="0">
<tr><td valign="top"><ul>

<style>
#listtab33 tr td {vertical-align:top;}
</style>
<table id='listtab33' width='100%'></table>
<script>
var listitems33 = [{"u":"lang_aggfunc.html","x":"aggregate functions","s":0},
{"u":"lang_altertable.html","x":"ALTER TABLE","s":0},
{"u":"lang_analyze.html","x":"ANALYZE","s":0},
{"u":"lang_attach.html","x":"ATTACH DATABASE","s":0},
{"u":"lang_transaction.html","x":"BEGIN TRANSACTION","s":0},
{"u":"lang_comment.html","x":"comment","s":0},
{"u":"lang_transaction.html","x":"COMMIT TRANSACTION","s":0},
{"u":"lang_corefunc.html","x":"core functions","s":0},
{"u":"lang_createindex.html","x":"CREATE INDEX","s":0},
{"u":"lang_createtable.html","x":"CREATE TABLE","s":0},
{"u":"lang_createtrigger.html","x":"CREATE TRIGGER","s":0},
{"u":"lang_createview.html","x":"CREATE VIEW","s":0},
{"u":"lang_createvtab.html","x":"CREATE VIRTUAL TABLE","s":0},
{"u":"lang_datefunc.html","x":"date and time functions","s":0},
{"u":"lang_delete.html","x":"DELETE","s":0},
{"u":"lang_detach.html","x":"DETACH DATABASE","s":0},
{"u":"lang_dropindex.html","x":"DROP INDEX","s":0},
{"u":"lang_droptable.html","x":"DROP TABLE","s":0},
{"u":"lang_droptrigger.html","x":"DROP TRIGGER","s":0},
{"u":"lang_dropview.html","x":"DROP VIEW","s":0},
{"u":"lang_transaction.html","x":"END TRANSACTION","s":0},
{"u":"lang_explain.html","x":"EXPLAIN","s":0},
{"u":"lang_expr.html","x":"expression","s":0},
{"u":"lang_indexedby.html","x":"INDEXED BY","s":0},
{"u":"lang_insert.html","x":"INSERT","s":0},
{"u":"lang_keywords.html","x":"keywords","s":0},
{"u":"lang_conflict.html","x":"ON CONFLICT clause","s":0},
{"u":"pragma.html#syntax","x":"PRAGMA","s":0},
{"u":"lang_reindex.html","x":"REINDEX","s":0},
{"u":"lang_savepoint.html","x":"RELEASE SAVEPOINT","s":0},
{"u":"lang_replace.html","x":"REPLACE","s":0},
{"u":"lang_transaction.html","x":"ROLLBACK TRANSACTION","s":0},



{"u":"lang_savepoint.html","x":"SAVEPOINT","s":0},
{"u":"lang_select.html","x":"SELECT","s":0},
{"u":"lang_update.html","x":"UPDATE","s":0},
{"u":"lang_UPSERT.html","x":"UPSERT","s":0},
{"u":"lang_vacuum.html","x":"VACUUM","s":0},
{"u":"lang_with.html","x":"WITH clause","s":0}];
var j = 0;
var w = Math.max(document.documentElement.clientWidth,  window.innerWidth || 0);
var nCol = Math.floor(w/340);
if(nCol<=0) nCol=1;
var nRow = Math.ceil((listitems33.length+1)/nCol);
var h="<tr><td><ul class='multicol_list'>"
var ea
for(var i=0; i<listitems33.length; i++){
  if( (++j)>nRow ){
    h += "</ul></td>\n<td><ul class='multicol_list'>\n";
    j = 1;
  }
  if(listitems33[i].u=="" || listitems33[i].s==2){
    h += "<li>"
    ea = ""
  }else{
    h += "<li><a href='";
    h += listitems33[i].u;
    h += "'>";
    ea = "</a>"
  }
  if(listitems33[i].s==2 || listitems33[i].s==3) h += "<s>"
  h += listitems33[i].x;
  if(listitems33[i].s==2 || listitems33[i].s==3) h += "</s>"
  h += ea
  if(listitems33[i].s==1) h += "<small><i>(exp)</i></small>\n";
  if(listitems33[i].s==3) h += "&sup1\n";
  if(listitems33[i].s==4) h += "&sup2\n";
  if(listitems33[i].s==5) h += "&sup3\n";
}
document.getElementById("listtab33").innerHTML = h;
</script>

</ul></td></tr></table>

<p>The routines <a href="c3ref/prepare.html">sqlite3_prepare_v2()</a>, <a href="c3ref/prepare.html">sqlite3_prepare()</a>,
<a href="c3ref/prepare.html">sqlite3_prepare16()</a>, <a href="c3ref/prepare.html">sqlite3_prepare16_v2()</a>, 
<a href="c3ref/exec.html">sqlite3_exec()</a>, and <a href="c3ref/free_table.html">sqlite3_get_table()</a> accept
an SQL statement list (sql-stmt-list) which is a semicolon-separated
list of statements.</p>

<p><b><a href="syntax/sql-stmt-list.html">sql-stmt-list:</a></b></p><div class='imgcontainer'>
 <img alt="syntax diagram sql-stmt-list" src="images/syntax/sql-stmt-list.gif"></img>
 </div>


<p>Each SQL statement in the statement list is an instance of the
following:</p>

<p><b><a href="syntax/sql-stmt.html">sql-stmt:</a></b></p><div class='imgcontainer'>
 <img alt="syntax diagram sql-stmt" src="images/syntax/sql-stmt.gif"></img>
 </div>










|
<
|
<
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<
<
<
>
>
>
|
|
|
|
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
<
<
|
<
<
<
<
<
<
<
<
<
<
<
|






















<
105
106
107
108
109
110
111
112

113


114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142



143
144
145
146
147
148
149
150

















151


152











153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175

<a href="syntaxdiagrams.html">syntax diagrams</a>.

<p>The following syntax documentation topics are available:</p>

<table width="100%" cellpadding="5" border="0">
<tr><td valign="top"><ul>

<div class='columns' style='columns: 17em auto;'>

<ul style='padding-top:0;'>


<li><a href='lang_aggfunc.html'>aggregate functions</a></li>
<li><a href='lang_altertable.html'>ALTER TABLE</a></li>
<li><a href='lang_analyze.html'>ANALYZE</a></li>
<li><a href='lang_attach.html'>ATTACH DATABASE</a></li>
<li><a href=''>BEGIN TRANSACTION</a></li>
<li><a href='lang_comment.html'>comment</a></li>
<li><a href='lang_transaction.html'>COMMIT TRANSACTION</a></li>
<li><a href='lang_corefunc.html'>core functions</a></li>
<li><a href='lang_createindex.html'>CREATE INDEX</a></li>
<li><a href='lang_createtable.html'>CREATE TABLE</a></li>
<li><a href='lang_createtrigger.html'>CREATE TRIGGER</a></li>
<li><a href='lang_createview.html'>CREATE VIEW</a></li>
<li><a href='lang_createvtab.html'>CREATE VIRTUAL TABLE</a></li>
<li><a href='lang_datefunc.html'>date and time functions</a></li>
<li><a href='lang_delete.html'>DELETE</a></li>
<li><a href='lang_detach.html'>DETACH DATABASE</a></li>
<li><a href='lang_dropindex.html'>DROP INDEX</a></li>
<li><a href='lang_droptable.html'>DROP TABLE</a></li>
<li><a href='lang_droptrigger.html'>DROP TRIGGER</a></li>
<li><a href='lang_dropview.html'>DROP VIEW</a></li>
<li><a href='lang_transaction.html'>END TRANSACTION</a></li>
<li><a href='lang_explain.html'>EXPLAIN</a></li>
<li><a href='lang_expr.html'>expression</a></li>
<li><a href='lang_indexedby.html'>INDEXED BY</a></li>
<li><a href='lang_insert.html'>INSERT</a></li>
<li><a href='lang_keywords.html'>keywords</a></li>
<li><a href='lang_conflict.html'>ON CONFLICT clause</a></li>
<li><a href='pragma.html#syntax'>PRAGMA</a></li>
<li><a href='lang_reindex.html'>REINDEX</a></li>



<li><a href='lang_savepoint.html'>RELEASE SAVEPOINT</a></li>
<li><a href='lang_replace.html'>REPLACE</a></li>
<li><a href='lang_transaction.html'>ROLLBACK TRANSACTION</a></li>
<li><a href='lang_savepoint.html'>SAVEPOINT</a></li>
<li><a href='lang_select.html'>SELECT</a></li>
<li><a href='lang_update.html'>UPDATE</a></li>
<li><a href='lang_upsert.html'>UPSERT</a></li>
<li><a href='lang_vacuum.html'>VACUUM</a></li>

















<li><a href='lang_with.html'>WITH clause</a></li>


</ul>











</div>

</ul></td></tr></table>

<p>The routines <a href="c3ref/prepare.html">sqlite3_prepare_v2()</a>, <a href="c3ref/prepare.html">sqlite3_prepare()</a>,
<a href="c3ref/prepare.html">sqlite3_prepare16()</a>, <a href="c3ref/prepare.html">sqlite3_prepare16_v2()</a>, 
<a href="c3ref/exec.html">sqlite3_exec()</a>, and <a href="c3ref/free_table.html">sqlite3_get_table()</a> accept
an SQL statement list (sql-stmt-list) which is a semicolon-separated
list of statements.</p>

<p><b><a href="syntax/sql-stmt-list.html">sql-stmt-list:</a></b></p><div class='imgcontainer'>
 <img alt="syntax diagram sql-stmt-list" src="images/syntax/sql-stmt-list.gif"></img>
 </div>


<p>Each SQL statement in the statement list is an instance of the
following:</p>

<p><b><a href="syntax/sql-stmt.html">sql-stmt:</a></b></p><div class='imgcontainer'>
 <img alt="syntax diagram sql-stmt" src="images/syntax/sql-stmt.gif"></img>
 </div>



Changes to Doc/Extra/Core/lang_aggfunc.html.
1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>SQLite Query Language: Aggregate Functions</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>





|







1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>Built-in Aggregate Functions</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93

94




95
96




97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225

226

227

228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272

273

274
275
276
277
278
279
280
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>

<div class=nosearch><h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>Aggregate Functions</h2></div>










<p><b><a href="syntax/aggregate-function-invocation.html">aggregate-function-invocation:</a></b>
<button id='x1673' onclick='hideorshow("x1673","x1674")'>hide</button></p>
 <div id='x1674' class='imgcontainer'>
 <img alt="syntax diagram aggregate-function-invocation" src="images/syntax/aggregate-function-invocation.gif" />
<p><b><a href="syntax/expr.html">expr:</a></b>
<button id='x1675' onclick='hideorshow("x1675","x1676")'>show</button></p>
 <div id='x1676' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntax/literal-value.html">literal-value:</a></b>
<button id='x1677' onclick='hideorshow("x1677","x1678")'>show</button></p>
 <div id='x1678' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</div>
<p><b><a href="syntax/over-clause.html">over-clause:</a></b>
<button id='x1679' onclick='hideorshow("x1679","x1680")'>show</button></p>
 <div id='x1680' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram over-clause" src="images/syntax/over-clause.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x1681' onclick='hideorshow("x1681","x1682")'>show</button></p>
 <div id='x1682' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
<button id='x1683' onclick='hideorshow("x1683","x1684")'>show</button></p>
 <div id='x1684' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</div>
</div>
<p><b><a href="syntax/raise-function.html">raise-function:</a></b>
<button id='x1685' onclick='hideorshow("x1685","x1686")'>show</button></p>
 <div id='x1686' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</div>
<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
<button id='x1687' onclick='hideorshow("x1687","x1688")'>show</button></p>
 <div id='x1688' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntax/common-table-expression.html">common-table-expression:</a></b>
<button id='x1689' onclick='hideorshow("x1689","x1690")'>show</button></p>
 <div id='x1690' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
</div>
<p><b><a href="syntax/compound-operator.html">compound-operator:</a></b>
<button id='x1691' onclick='hideorshow("x1691","x1692")'>show</button></p>
 <div id='x1692' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</div>
<p><b><a href="syntax/join-clause.html">join-clause:</a></b>
<button id='x1693' onclick='hideorshow("x1693","x1694")'>show</button></p>
 <div id='x1694' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
<button id='x1695' onclick='hideorshow("x1695","x1696")'>show</button></p>
 <div id='x1696' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</div>
<p><b><a href="syntax/join-operator.html">join-operator:</a></b>
<button id='x1697' onclick='hideorshow("x1697","x1698")'>show</button></p>
 <div id='x1698' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</div>
</div>
<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
<button id='x1699' onclick='hideorshow("x1699","x1700")'>show</button></p>
 <div id='x1700' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</div>
<p><b><a href="syntax/result-column.html">result-column:</a></b>
<button id='x1701' onclick='hideorshow("x1701","x1702")'>show</button></p>
 <div id='x1702' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</div>
<p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
<button id='x1703' onclick='hideorshow("x1703","x1704")'>show</button></p>
 <div id='x1704' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</div>
<p><b><a href="syntax/window-defn.html">window-defn:</a></b>
<button id='x1705' onclick='hideorshow("x1705","x1706")'>show</button></p>
 <div id='x1706' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram window-defn" src="images/syntax/window-defn.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x1707' onclick='hideorshow("x1707","x1708")'>show</button></p>
 <div id='x1708' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
</div>
</div>
<p><b><a href="syntax/type-name.html">type-name:</a></b>
<button id='x1709' onclick='hideorshow("x1709","x1710")'>show</button></p>
 <div id='x1710' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
<button id='x1711' onclick='hideorshow("x1711","x1712")'>show</button></p>
 <div id='x1712' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</div>
</div>
</div>
<p><b><a href="syntax/filter-clause.html">filter-clause:</a></b>
<button id='x1713' onclick='hideorshow("x1713","x1714")'>show</button></p>
 <div id='x1714' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram filter-clause" src="images/syntax/filter-clause.gif" />
</div>
</div>


<p>
The aggregate functions shown below are available by default.  Additional
aggregate functions written in C may be added using the 
<a href="c3ref/create_function.html">sqlite3_create_function()</a></a>
API.</p>

<p>
In any aggregate function that takes a single argument, that argument
can be preceded by the keyword DISTINCT.  In such cases, duplicate
elements are filtered before being passed into the aggregate function.
For example, the function "count(distinct X)" will return the number
of distinct values of column X instead of the total number of non-null
values in column X.
</p>

<a name="aggfilter"></a>

<p>
If a FILTER clause is provided, then only rows for which the <i>expr</i> is
true are included in the aggregate.
</p>


<style>

#listtab35 tr td {vertical-align:top;}

</style>
<table id='listtab35' width='100%'></table>
<script>
var listitems35 = [{"u":"lang_aggfunc.html#avg","x":"avg(X)","s":0},
{"u":"lang_aggfunc.html#count","x":"count(*)","s":0},
{"u":"lang_aggfunc.html#count","x":"count(X)","s":0},
{"u":"lang_aggfunc.html#groupconcat","x":"group_concat(X)","s":0},
{"u":"lang_aggfunc.html#groupconcat","x":"group_concat(X,Y)","s":0},
{"u":"lang_corefunc.html#maxoreunc","x":"max(X)","s":0},
{"u":"lang_corefunc.html#minoreunc","x":"min(X)","s":0},
{"u":"lang_aggfunc.html#sumunc","x":"sum(X)","s":0},
{"u":"lang_aggfunc.html#sumunc","x":"total(X)","s":0}];
var j = 0;
var w = Math.max(document.documentElement.clientWidth,  window.innerWidth || 0);
var nCol = Math.floor(w/225);
if(nCol<=0) nCol=1;
var nRow = Math.ceil((listitems35.length+1)/nCol);
var h="<tr><td><ul class='multicol_list'>"
var ea
for(var i=0; i<listitems35.length; i++){
  if( (++j)>nRow ){
    h += "</ul></td>\n<td><ul class='multicol_list'>\n";
    j = 1;
  }
  if(listitems35[i].u=="" || listitems35[i].s==2){
    h += "<li>"
    ea = ""
  }else{
    h += "<li><a href='";
    h += listitems35[i].u;
    h += "'>";
    ea = "</a>"
  }
  if(listitems35[i].s==2 || listitems35[i].s==3) h += "<s>"
  h += listitems35[i].x;
  if(listitems35[i].s==2 || listitems35[i].s==3) h += "</s>"
  h += ea
  if(listitems35[i].s==1) h += "<small><i>(exp)</i></small>\n";
  if(listitems35[i].s==3) h += "&sup1\n";
  if(listitems35[i].s==4) h += "&sup2\n";
  if(listitems35[i].s==5) h += "&sup3\n";
}
document.getElementById("listtab35").innerHTML = h;
</script>
<hr class='xhr'>

<dl>

<a name="avg"></a>
<dt><p><b>avg(<i>X</i>)</b></dt><dd><p>
  The avg() function
  returns the average value of all non-NULL <i>X</i> within a
  group.  String and BLOB values that do not look like numbers are
  interpreted as 0.
  The result of avg() is always a floating point value as long as







|

















>
|
>
>
>
>


>
>
>
>

|
|


|
|


|
|



|
|


|
|



|
|




|
|



|
|


|
|



|
|



|
|


|
|



|
|




|
|



|
|



|
|



|
|


|
|





|
|


|
|





|
|








|


















>
|
>
|
>
|
<
<
|
|
|
|
|
|
|
|
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
<
<
<
|
|
<
<
<
<
<
<
<
<
|
<
<
<
>

>







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240


241
242
243
244
245
246
247
248
249















250



251
252








253



254
255
256
257
258
259
260
261
262
263
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<div class=fancy>
<div class=nosearch>
<div class="fancy_title">
Built-in Aggregate Functions
</div>
</div>





<h1 id="syntax"><span>1. </span>Syntax</h1>
<p><b><a href="syntax/aggregate-function-invocation.html">aggregate-function-invocation:</a></b>
<button id='x1191' onclick='hideorshow("x1191","x1192")'>hide</button></p>
 <div id='x1192' class='imgcontainer'>
 <img alt="syntax diagram aggregate-function-invocation" src="images/syntax/aggregate-function-invocation.gif" />
<p><b><a href="syntax/expr.html">expr:</a></b>
<button id='x1193' onclick='hideorshow("x1193","x1194")'>show</button></p>
 <div id='x1194' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntax/literal-value.html">literal-value:</a></b>
<button id='x1195' onclick='hideorshow("x1195","x1196")'>show</button></p>
 <div id='x1196' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</div>
<p><b><a href="syntax/over-clause.html">over-clause:</a></b>
<button id='x1197' onclick='hideorshow("x1197","x1198")'>show</button></p>
 <div id='x1198' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram over-clause" src="images/syntax/over-clause.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x1199' onclick='hideorshow("x1199","x1200")'>show</button></p>
 <div id='x1200' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
<button id='x1201' onclick='hideorshow("x1201","x1202")'>show</button></p>
 <div id='x1202' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</div>
</div>
<p><b><a href="syntax/raise-function.html">raise-function:</a></b>
<button id='x1203' onclick='hideorshow("x1203","x1204")'>show</button></p>
 <div id='x1204' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</div>
<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
<button id='x1205' onclick='hideorshow("x1205","x1206")'>show</button></p>
 <div id='x1206' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntax/common-table-expression.html">common-table-expression:</a></b>
<button id='x1207' onclick='hideorshow("x1207","x1208")'>show</button></p>
 <div id='x1208' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
</div>
<p><b><a href="syntax/compound-operator.html">compound-operator:</a></b>
<button id='x1209' onclick='hideorshow("x1209","x1210")'>show</button></p>
 <div id='x1210' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</div>
<p><b><a href="syntax/join-clause.html">join-clause:</a></b>
<button id='x1211' onclick='hideorshow("x1211","x1212")'>show</button></p>
 <div id='x1212' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
<button id='x1213' onclick='hideorshow("x1213","x1214")'>show</button></p>
 <div id='x1214' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</div>
<p><b><a href="syntax/join-operator.html">join-operator:</a></b>
<button id='x1215' onclick='hideorshow("x1215","x1216")'>show</button></p>
 <div id='x1216' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</div>
</div>
<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
<button id='x1217' onclick='hideorshow("x1217","x1218")'>show</button></p>
 <div id='x1218' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</div>
<p><b><a href="syntax/result-column.html">result-column:</a></b>
<button id='x1219' onclick='hideorshow("x1219","x1220")'>show</button></p>
 <div id='x1220' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</div>
<p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
<button id='x1221' onclick='hideorshow("x1221","x1222")'>show</button></p>
 <div id='x1222' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</div>
<p><b><a href="syntax/window-defn.html">window-defn:</a></b>
<button id='x1223' onclick='hideorshow("x1223","x1224")'>show</button></p>
 <div id='x1224' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram window-defn" src="images/syntax/window-defn.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x1225' onclick='hideorshow("x1225","x1226")'>show</button></p>
 <div id='x1226' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
</div>
</div>
<p><b><a href="syntax/type-name.html">type-name:</a></b>
<button id='x1227' onclick='hideorshow("x1227","x1228")'>show</button></p>
 <div id='x1228' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
<button id='x1229' onclick='hideorshow("x1229","x1230")'>show</button></p>
 <div id='x1230' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</div>
</div>
</div>
<p><b><a href="syntax/filter-clause.html">filter-clause:</a></b>
<button id='x1231' onclick='hideorshow("x1231","x1232")'>show</button></p>
 <div id='x1232' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram filter-clause" src="images/syntax/filter-clause.gif" />
</div>
</div>


<p>
The aggregate functions shown below are available by default.  Additional
aggregate functions written in C may be added using the 
<a href="c3ref/create_function.html">sqlite3_create_function()</a>
API.</p>

<p>
In any aggregate function that takes a single argument, that argument
can be preceded by the keyword DISTINCT.  In such cases, duplicate
elements are filtered before being passed into the aggregate function.
For example, the function "count(distinct X)" will return the number
of distinct values of column X instead of the total number of non-null
values in column X.
</p>

<a name="aggfilter"></a>

<p>
If a FILTER clause is provided, then only rows for which the <i>expr</i> is
true are included in the aggregate.
</p>

<a name="aggfunclist"></a>

<h1 id="list_of_built_in_aggregate_functions"><span>2. </span>List of built-in aggregate functions</h1>

<div class='columns' style='columns: 11em auto;'>
<ul style='padding-top:0;'>


<li><a href='lang_aggfunc.html#avg'>avg(X)</a></li>
<li><a href='lang_aggfunc.html#count'>count(*)</a></li>
<li><a href='lang_aggfunc.html#count'>count(X)</a></li>
<li><a href='lang_aggfunc.html#groupconcat'>group_concat(X)</a></li>
<li><a href='lang_aggfunc.html#groupconcat'>group_concat(X,Y)</a></li>
<li><a href='lang_corefunc.html#maxoreunc'>max(X)</a></li>
<li><a href='lang_corefunc.html#minoreunc'>min(X)</a></li>
<li><a href='lang_aggfunc.html#sumunc'>sum(X)</a></li>
<li><a href='lang_aggfunc.html#sumunc'>total(X)</a></li>















</ul>



</div>













<h1 id="descriptions_of_built_in_aggregate_functions"><span>3. </span>Descriptions of built-in aggregate functions</h1>
<dl>

<a name="avg"></a>
<dt><p><b>avg(<i>X</i>)</b></dt><dd><p>
  The avg() function
  returns the average value of all non-NULL <i>X</i> within a
  group.  String and BLOB values that do not look like numbers are
  interpreted as 0.
  The result of avg() is always a floating point value as long as
336
337
338
339
340
341
342

343
344
  which might be an approximation to the true sum.</p>

  <p>Sum() will throw an "integer overflow" exception if all inputs
  are integers or NULL
  and an integer overflow occurs at any point during the computation.
  Total() never throws an integer overflow.
</dd>

</dl>








>


319
320
321
322
323
324
325
326
327
328
  which might be an approximation to the true sum.</p>

  <p>Sum() will throw an "integer overflow" exception if all inputs
  are integers or NULL
  and an integer overflow occurs at any point during the computation.
  Total() never throws an integer overflow.
</dd>

</dl>

Changes to Doc/Extra/Core/lang_altertable.html.
1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>SQLite Query Language: ALTER TABLE</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>





|







1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>ALTER TABLE</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93













94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>













<div class=nosearch><h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>ALTER TABLE</h2></div><p><b><a href="syntax/alter-table-stmt.html">alter-table-stmt:</a></b>
<button id='x1191' onclick='hideorshow("x1191","x1192")'>hide</button></p>
 <div id='x1192' class='imgcontainer'>
 <img alt="syntax diagram alter-table-stmt" src="images/syntax/alter-table-stmt.gif" />
<p><b><a href="syntax/column-def.html">column-def:</a></b>
<button id='x1193' onclick='hideorshow("x1193","x1194")'>show</button></p>
 <div id='x1194' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram column-def" src="images/syntax/column-def.gif" />
<p><b><a href="syntax/column-constraint.html">column-constraint:</a></b>
<button id='x1195' onclick='hideorshow("x1195","x1196")'>show</button></p>
 <div id='x1196' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram column-constraint" src="images/syntax/column-constraint.gif" />
<p><b><a href="syntax/conflict-clause.html">conflict-clause:</a></b>
<button id='x1197' onclick='hideorshow("x1197","x1198")'>show</button></p>
 <div id='x1198' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram conflict-clause" src="images/syntax/conflict-clause.gif" />
</div>
<p><b><a href="syntax/expr.html">expr:</a></b>
<button id='x1199' onclick='hideorshow("x1199","x1200")'>show</button></p>
 <div id='x1200' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntax/filter-clause.html">filter-clause:</a></b>
<button id='x1201' onclick='hideorshow("x1201","x1202")'>show</button></p>
 <div id='x1202' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram filter-clause" src="images/syntax/filter-clause.gif" />
</div>
<p><b><a href="syntax/over-clause.html">over-clause:</a></b>
<button id='x1203' onclick='hideorshow("x1203","x1204")'>show</button></p>
 <div id='x1204' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram over-clause" src="images/syntax/over-clause.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x1205' onclick='hideorshow("x1205","x1206")'>show</button></p>
 <div id='x1206' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
<button id='x1207' onclick='hideorshow("x1207","x1208")'>show</button></p>
 <div id='x1208' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</div>
</div>
<p><b><a href="syntax/raise-function.html">raise-function:</a></b>
<button id='x1209' onclick='hideorshow("x1209","x1210")'>show</button></p>
 <div id='x1210' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</div>
<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
<button id='x1211' onclick='hideorshow("x1211","x1212")'>show</button></p>
 <div id='x1212' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntax/common-table-expression.html">common-table-expression:</a></b>
<button id='x1213' onclick='hideorshow("x1213","x1214")'>show</button></p>
 <div id='x1214' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
</div>
<p><b><a href="syntax/compound-operator.html">compound-operator:</a></b>
<button id='x1215' onclick='hideorshow("x1215","x1216")'>show</button></p>
 <div id='x1216' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</div>
<p><b><a href="syntax/join-clause.html">join-clause:</a></b>
<button id='x1217' onclick='hideorshow("x1217","x1218")'>show</button></p>
 <div id='x1218' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
<button id='x1219' onclick='hideorshow("x1219","x1220")'>show</button></p>
 <div id='x1220' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</div>
<p><b><a href="syntax/join-operator.html">join-operator:</a></b>
<button id='x1221' onclick='hideorshow("x1221","x1222")'>show</button></p>
 <div id='x1222' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</div>
</div>
<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
<button id='x1223' onclick='hideorshow("x1223","x1224")'>show</button></p>
 <div id='x1224' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</div>
<p><b><a href="syntax/result-column.html">result-column:</a></b>
<button id='x1225' onclick='hideorshow("x1225","x1226")'>show</button></p>
 <div id='x1226' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</div>
<p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
<button id='x1227' onclick='hideorshow("x1227","x1228")'>show</button></p>
 <div id='x1228' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</div>
<p><b><a href="syntax/window-defn.html">window-defn:</a></b>
<button id='x1229' onclick='hideorshow("x1229","x1230")'>show</button></p>
 <div id='x1230' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram window-defn" src="images/syntax/window-defn.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x1231' onclick='hideorshow("x1231","x1232")'>show</button></p>
 <div id='x1232' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
</div>
</div>
</div>
<p><b><a href="syntax/foreign-key-clause.html">foreign-key-clause:</a></b>
<button id='x1233' onclick='hideorshow("x1233","x1234")'>show</button></p>
 <div id='x1234' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram foreign-key-clause" src="images/syntax/foreign-key-clause.gif" />
</div>
<p><b><a href="syntax/literal-value.html">literal-value:</a></b>
<button id='x1235' onclick='hideorshow("x1235","x1236")'>show</button></p>
 <div id='x1236' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</div>
<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
<button id='x1237' onclick='hideorshow("x1237","x1238")'>show</button></p>
 <div id='x1238' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</div>
</div>
<p><b><a href="syntax/type-name.html">type-name:</a></b>
<button id='x1239' onclick='hideorshow("x1239","x1240")'>show</button></p>
 <div id='x1240' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
<button id='x1241' onclick='hideorshow("x1241","x1242")'>show</button></p>
 <div id='x1242' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</div>
</div>
</div>
</div>


<p>SQLite supports a limited subset of ALTER TABLE.
The ALTER TABLE command in SQLite allows the user to rename a table,
to rename a column within a table, or to add a new column to an existing table.

<a name="altertabrename"></a>

<h3>ALTER TABLE RENAME</h3>

<p> The RENAME TO syntax changes the name of <span class='yyterm'>table-name</span>
to <span class='yyterm'>new-table-name</span>.
This command 
cannot be used to move a table between attached databases, only to rename 
a table within the same database.
If the table being renamed has triggers or indices, then these remain
attached to the table after it has been renamed.

<blockquote style='background-color: #ffd0d0;'>
<b>Compatibility Note:</b>
The behavior of ALTER TABLE when renaming a table was enhanced
in versions 3.25.0 (2018-09-15) and 3.26.0 (2018-12-01)
in order to carry the rename operation forward into triggers and
views that reference the renamed table.  This is considered an
improvement. Applications that depend on the older (and
arguably buggy) behavior can use the







|

















>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
|


|
|


|
|


|
|



|
|


|
|



|
|


|
|



|
|




|
|



|
|


|
|



|
|



|
|


|
|



|
|




|
|



|
|



|
|



|
|


|
|






|
|



|
|



|
|




|
|


|
|













|









|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<div class=fancy>
<div class=nosearch>
<div class="fancy_title">
ALTER TABLE
</div>
</div>





<h1 id="overview"><span>1. </span>Overview</h1>

<p><b><a href="syntax/alter-table-stmt.html">alter-table-stmt:</a></b>
<button id='x1233' onclick='hideorshow("x1233","x1234")'>hide</button></p>
 <div id='x1234' class='imgcontainer'>
 <img alt="syntax diagram alter-table-stmt" src="images/syntax/alter-table-stmt.gif" />
<p><b><a href="syntax/column-def.html">column-def:</a></b>
<button id='x1235' onclick='hideorshow("x1235","x1236")'>show</button></p>
 <div id='x1236' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram column-def" src="images/syntax/column-def.gif" />
<p><b><a href="syntax/column-constraint.html">column-constraint:</a></b>
<button id='x1237' onclick='hideorshow("x1237","x1238")'>show</button></p>
 <div id='x1238' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram column-constraint" src="images/syntax/column-constraint.gif" />
<p><b><a href="syntax/conflict-clause.html">conflict-clause:</a></b>
<button id='x1239' onclick='hideorshow("x1239","x1240")'>show</button></p>
 <div id='x1240' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram conflict-clause" src="images/syntax/conflict-clause.gif" />
</div>
<p><b><a href="syntax/expr.html">expr:</a></b>
<button id='x1241' onclick='hideorshow("x1241","x1242")'>show</button></p>
 <div id='x1242' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntax/filter-clause.html">filter-clause:</a></b>
<button id='x1243' onclick='hideorshow("x1243","x1244")'>show</button></p>
 <div id='x1244' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram filter-clause" src="images/syntax/filter-clause.gif" />
</div>
<p><b><a href="syntax/over-clause.html">over-clause:</a></b>
<button id='x1245' onclick='hideorshow("x1245","x1246")'>show</button></p>
 <div id='x1246' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram over-clause" src="images/syntax/over-clause.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x1247' onclick='hideorshow("x1247","x1248")'>show</button></p>
 <div id='x1248' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
<button id='x1249' onclick='hideorshow("x1249","x1250")'>show</button></p>
 <div id='x1250' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</div>
</div>
<p><b><a href="syntax/raise-function.html">raise-function:</a></b>
<button id='x1251' onclick='hideorshow("x1251","x1252")'>show</button></p>
 <div id='x1252' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</div>
<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
<button id='x1253' onclick='hideorshow("x1253","x1254")'>show</button></p>
 <div id='x1254' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntax/common-table-expression.html">common-table-expression:</a></b>
<button id='x1255' onclick='hideorshow("x1255","x1256")'>show</button></p>
 <div id='x1256' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
</div>
<p><b><a href="syntax/compound-operator.html">compound-operator:</a></b>
<button id='x1257' onclick='hideorshow("x1257","x1258")'>show</button></p>
 <div id='x1258' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</div>
<p><b><a href="syntax/join-clause.html">join-clause:</a></b>
<button id='x1259' onclick='hideorshow("x1259","x1260")'>show</button></p>
 <div id='x1260' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
<button id='x1261' onclick='hideorshow("x1261","x1262")'>show</button></p>
 <div id='x1262' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</div>
<p><b><a href="syntax/join-operator.html">join-operator:</a></b>
<button id='x1263' onclick='hideorshow("x1263","x1264")'>show</button></p>
 <div id='x1264' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</div>
</div>
<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
<button id='x1265' onclick='hideorshow("x1265","x1266")'>show</button></p>
 <div id='x1266' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</div>
<p><b><a href="syntax/result-column.html">result-column:</a></b>
<button id='x1267' onclick='hideorshow("x1267","x1268")'>show</button></p>
 <div id='x1268' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</div>
<p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
<button id='x1269' onclick='hideorshow("x1269","x1270")'>show</button></p>
 <div id='x1270' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</div>
<p><b><a href="syntax/window-defn.html">window-defn:</a></b>
<button id='x1271' onclick='hideorshow("x1271","x1272")'>show</button></p>
 <div id='x1272' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram window-defn" src="images/syntax/window-defn.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x1273' onclick='hideorshow("x1273","x1274")'>show</button></p>
 <div id='x1274' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
</div>
</div>
</div>
<p><b><a href="syntax/foreign-key-clause.html">foreign-key-clause:</a></b>
<button id='x1275' onclick='hideorshow("x1275","x1276")'>show</button></p>
 <div id='x1276' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram foreign-key-clause" src="images/syntax/foreign-key-clause.gif" />
</div>
<p><b><a href="syntax/literal-value.html">literal-value:</a></b>
<button id='x1277' onclick='hideorshow("x1277","x1278")'>show</button></p>
 <div id='x1278' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</div>
<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
<button id='x1279' onclick='hideorshow("x1279","x1280")'>show</button></p>
 <div id='x1280' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</div>
</div>
<p><b><a href="syntax/type-name.html">type-name:</a></b>
<button id='x1281' onclick='hideorshow("x1281","x1282")'>show</button></p>
 <div id='x1282' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
<button id='x1283' onclick='hideorshow("x1283","x1284")'>show</button></p>
 <div id='x1284' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</div>
</div>
</div>
</div>


<p>SQLite supports a limited subset of ALTER TABLE.
The ALTER TABLE command in SQLite allows the user to rename a table,
to rename a column within a table, or to add a new column to an existing table.

<a name="altertabrename"></a>

</p><h1 id="alter_table_rename"><span>2. </span>ALTER TABLE RENAME</h1>

<p> The RENAME TO syntax changes the name of <span class='yyterm'>table-name</span>
to <span class='yyterm'>new-table-name</span>.
This command 
cannot be used to move a table between attached databases, only to rename 
a table within the same database.
If the table being renamed has triggers or indices, then these remain
attached to the table after it has been renamed.

</p><blockquote style="'background-color:" #ffd0d0;'="1">
<b>Compatibility Note:</b>
The behavior of ALTER TABLE when renaming a table was enhanced
in versions 3.25.0 (2018-09-15) and 3.26.0 (2018-12-01)
in order to carry the rename operation forward into triggers and
views that reference the renamed table.  This is considered an
improvement. Applications that depend on the older (and
arguably buggy) behavior can use the
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
<a href="pragma.html#pragma_legacy_alter_table">PRAGMA legacy_alter_table=ON</a> setting is engaged.  The following
table summaries the difference:</p>

<blockquote>
<table border="1" cellpadding="2" cellspacing="0">
<tr>
<th>PRAGMA foreign_keys
<th>PRAGMA legacy_alter_table
<th><a href="foreignkeys.html#parentchild">Parent Table</a>
references are updated
<th>SQLite version
<tr><td align="center">Off<td align="center">Off<td align="center">No<td align="center">&lt; 3.26.0
<tr><td align="center">Off<td align="center">Off<td align="center">Yes<td align="center">&gt;= 3.26.0
<tr><td align="center">On<td align="center">Off<td align="center">Yes<td align="center">all
<tr><td align="center">Off<td align="center">On<td align="center">No<td align="center">all
<tr><td align="center">On<td align="center">On<td align="center">Yes<td align="center">all
</table>
</blockquote>

<a name="altertabmvcol"></a>

<h3>ALTER TABLE RENAME COLUMN</h3>

<p> The RENAME COLUMN TO syntax changes the
<span class='yyterm'>column-name</span> of table <span class='yyterm'>table-name</span>
into <span class='yyterm'>new-column-name</span>.  The column name is changed both
within the table definition itself and also within all indexes, triggers,
and views that reference the column.  If the column name change would
result in a semantic ambiguity in a trigger or view, then the RENAME
COLUMN fails with an error and no changes are applied.

<a name="altertabaddcol"></a>

<h3>ALTER TABLE ADD COLUMN</h3>

<p> The ADD COLUMN syntax
is used to add a new column to an existing table.
The new column is always appended to the end of the list of existing columns.
The <a href="syntax/column-def.html">column-def</a> rule defines the characteristics of the new column.
The new column may take any of the forms permissible in a <a href="lang_createtable.html">CREATE TABLE</a>
statement, with the following restrictions:
<ul>
<li>The column may not have a PRIMARY KEY or UNIQUE constraint.</li>
<li>The column may not have a default value of CURRENT_TIME, CURRENT_DATE, 
    CURRENT_TIMESTAMP, or an expression in parentheses.</li>
<li>If a NOT NULL constraint is specified, then the column must have a
    default value other than NULL.
<li>If <a href="foreignkeys.html">foreign key constraints</a> are <a href="pragma.html#pragma_foreign_keys">enabled</a> and
    a column with a <a href="syntax/foreign-key-clause.html">REFERENCES clause</a>
    is added, the column must have a default value of NULL.
<li>The column may not be <a href="gencol.html">GENERATED ALWAYS ... STORED</a>,
though VIRTUAL columns are allowed.
</ul>

<p>Note also that when adding a <a href="lang_createtable.html#ckconst">CHECK constraint</a>, the CHECK constraint
is not tested against preexisting rows of the table.
This can result in a table that contains data that
is in violation of the CHECK constraint.  Future versions of SQLite might
change to validate CHECK constraints as they are added.</p>








|
|

|
|
|
|
|
|
|




|











|







|





|


|

|







282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
<a href="pragma.html#pragma_legacy_alter_table">PRAGMA legacy_alter_table=ON</a> setting is engaged.  The following
table summaries the difference:</p>

<blockquote>
<table border="1" cellpadding="2" cellspacing="0">
<tr>
<th>PRAGMA foreign_keys
</th><th>PRAGMA legacy_alter_table
</th><th><a href="foreignkeys.html#parentchild">Parent Table</a>
references are updated
</th><th>SQLite version
</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
</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
</td></tr><tr><td align="center">On</td><td align="center">Off</td><td align="center">Yes</td><td align="center">all
</td></tr><tr><td align="center">Off</td><td align="center">On</td><td align="center">No</td><td align="center">all
</td></tr><tr><td align="center">On</td><td align="center">On</td><td align="center">Yes</td><td align="center">all
</td></tr></table>
</blockquote>

<a name="altertabmvcol"></a>

<h1 id="alter_table_rename_column"><span>3. </span>ALTER TABLE RENAME COLUMN</h1>

<p> The RENAME COLUMN TO syntax changes the
<span class='yyterm'>column-name</span> of table <span class='yyterm'>table-name</span>
into <span class='yyterm'>new-column-name</span>.  The column name is changed both
within the table definition itself and also within all indexes, triggers,
and views that reference the column.  If the column name change would
result in a semantic ambiguity in a trigger or view, then the RENAME
COLUMN fails with an error and no changes are applied.

<a name="altertabaddcol"></a>

</p><h1 id="alter_table_add_column"><span>4. </span>ALTER TABLE ADD COLUMN</h1>

<p> The ADD COLUMN syntax
is used to add a new column to an existing table.
The new column is always appended to the end of the list of existing columns.
The <a href="syntax/column-def.html">column-def</a> rule defines the characteristics of the new column.
The new column may take any of the forms permissible in a <a href="lang_createtable.html">CREATE TABLE</a>
statement, with the following restrictions:
</p><ul>
<li>The column may not have a PRIMARY KEY or UNIQUE constraint.</li>
<li>The column may not have a default value of CURRENT_TIME, CURRENT_DATE, 
    CURRENT_TIMESTAMP, or an expression in parentheses.</li>
<li>If a NOT NULL constraint is specified, then the column must have a
    default value other than NULL.
</li><li>If <a href="foreignkeys.html">foreign key constraints</a> are <a href="pragma.html#pragma_foreign_keys">enabled</a> and
    a column with a <a href="syntax/foreign-key-clause.html">REFERENCES clause</a>
    is added, the column must have a default value of NULL.
</li><li>The column may not be <a href="gencol.html">GENERATED ALWAYS ... STORED</a>,
though VIRTUAL columns are allowed.
</li></ul>

<p>Note also that when adding a <a href="lang_createtable.html#ckconst">CHECK constraint</a>, the CHECK constraint
is not tested against preexisting rows of the table.
This can result in a table that contains data that
is in violation of the CHECK constraint.  Future versions of SQLite might
change to validate CHECK constraints as they are added.</p>

336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
</p>

<p>After ADD COLUMN has been run on a database, that database will not
be readable by SQLite version 3.1.3 (2005-02-20) and earlier.</p>

<a name="otheralter"></a>

<h3>Making Other Kinds Of Table Schema Changes</h3>

<p> The only schema altering commands directly supported by SQLite are the
"<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.  
However, applications
can make other arbitrary changes to the format of a table using a simple
sequence of operations.
The steps to make arbitrary changes to the schema design of some table X
are as follows:

<ol>
<li><p>
If foreign key constraints are enabled, disable them using <a href="pragma.html#pragma_foreign_keys">PRAGMA foreign_keys=OFF</a>.

<li><p>
Start a transaction.

<li><p>
Remember the format of all indexes, triggers, and views associated with table X.
This information will be needed in step 8 below.  One way to do this is
to run a query like the following:
SELECT type, sql FROM sqlite_master WHERE tbl_name='X'.

<li><p>
Use <a href="lang_createtable.html">CREATE TABLE</a> to construct a new table "new_X" that is in the desired
revised format of table X.  Make sure that the name "new_X" does not collide
with any existing table name, of course.

<li><p>
Transfer content from X into new_X using a statement
like: INSERT INTO new_X SELECT ... FROM X.

<li><p>
Drop the old table X:  <a href="lang_droptable.html">DROP TABLE X</a>.

<li><p>
Change the name of new_X to X using: ALTER TABLE new_X RENAME TO X.

<li><p>
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>
to reconstruct indexes, triggers, and views
associated with table X.  Perhaps use the old format of the triggers,
indexes, and views saved from step 3 above as a guide, making changes
as appropriate for the alteration.

<li><p>If any views refer to table X in a way that is affected by the
schema change, then drop those views using <a href="lang_dropview.html">DROP VIEW</a> and recreate them
with whatever changes are necessary to accommodate the schema change
using <a href="lang_createview.html">CREATE VIEW</a>.

<li><p>
If foreign key constraints were originally enabled
then run <a href="pragma.html#pragma_foreign_key_check">PRAGMA foreign_key_check</a> to verify that the schema
change did not break any foreign key constraints.


<li><p>
Commit the transaction started in step 2.

<li><p>
If foreign keys constraints were originally enabled, reenable them now.
</ol>

<a name="caution"></a>

<p>
<b>Caution:</b>
Take care to follow the procedure above precisely.  The boxes below
summarize two procedures for modifying a table definition.  At first
glance, they both appear to accomplish the same thing.  However, the
procedure on the right does not always work, especially with the
enhanced <a href="lang_altertable.html#altertabrename">rename table</a> capabilities added by versions 3.25.0 and
3.26.0.  In the procedure on the right, the initial rename of the
table to a temporary name might corrupt references to that table in
triggers, views, and foreign key constraints.  The safe procedure on
the left constructs the revised table definition using a new temporary
name, then renames the table into its final name, which does not break
links.

<center>
<table border="1" cellpadding="10" cellspacing="0">
<tr>
<td valign="top">
<ol>
<li>Create new table
<li>Copy data
<li>Drop old table
<li>Rename new into old
</ol>
<td valign="top">
<ol>
<li>Rename old table
<li>Create new table
<li>Copy data
<li>Drop old table
</ol>
<tr>
<th>&uarr;<br>Correct
<th>&uarr;<br>Incorrect
</table>
</center>

<p>The 12-step <a href="lang_altertable.html#otheralter">generalized ALTER TABLE procedure</a>
above will work even if the
schema change causes the information stored in the table to change.
So the full 12-step procedure above is appropriate for dropping a column,
changing the order of columns, adding or removing a UNIQUE constraint
or PRIMARY KEY, adding CHECK or FOREIGN KEY or NOT NULL constraints,
or changing the datatype for a column, for example.  However, a simpler
and faster procedure can optionally be used for
some changes that do no affect the on-disk content in any way.
The following simpler procedure is appropriate for removing
CHECK or FOREIGN KEY or NOT NULL constraints,
or adding, removing, or changing default values on
a column.

<ol>
<lI><p> Start a transaction.

<li><p> Run <a href="pragma.html#pragma_schema_version">PRAGMA schema_version</a> to determine the current schema
version number.  This number will be needed for step 6 below.

<li><p> Activate schema editing using 
<a href="pragma.html#pragma_writable_schema">PRAGMA writable_schema=ON</a>.

<li><p> Run an <a href="lang_update.html">UPDATE</a> statement to change the definition of table X
in the <a href="fileformat2.html#sqlite_master">sqlite_master table</a>: 
UPDATE sqlite_master SET sql=... WHERE type='table' AND name='X';
<p><em>Caution:</em>  Making a change to the sqlite_master table like this will
render the database corrupt and unreadable if the change contains
a syntax error.  It is suggested that careful testing of the UPDATE
statement be done on a separate blank database prior to using it on
a database containing important data.

<li><p> If the change to table X also affects other tables or indexes or
triggers are views within schema, then run <a href="lang_update.html">UPDATE</a> statements to modify
those other tables indexes and views too.  For example, if the name of
a column changes, all FOREIGN KEY constraints, triggers, indexes, and
views that refer to that column must be modified.
<p><em>Caution:</em>  Once again, making changes to the sqlite_master 
table like this will render the database corrupt and unreadable if the 
change contains an error.  Carefully test this entire procedure
on a separate test database prior to using it on
a database containing important data and/or make backup copies of
important databases prior to running this procedure.

<li><p> Increment the schema version number using
<a href="pragma.html#pragma_schema_version">PRAGMA schema_version=X</a> where X is one
more than the old schema version number found in step 2 above.

<li><p> Disable schema editing using 
<a href="pragma.html#pragma_writable_schema">PRAGMA writable_schema=OFF</a>.

<li><p> (Optional) Run <a href="pragma.html#pragma_integrity_check">PRAGMA integrity_check</a> to verify that the
schema changes did not damage the database.

<li><p> Commit the transaction started on step 1 above.
</ol>

<p>If some future version of SQLite adds new ALTER TABLE capabilities, 
those capabilities will very likely use one of the two procedures
outlined above.

<a name="altertableishard"></a>

<h3>Why ALTER TABLE is such a problem for SQLite</h3>

<p>Most SQL database engines store the schema already parsed into
various system tables.  On those database engines, ALTER TABLE merely 
has to make modifications to the corresponding system tables.

<p>SQLite is different in that it stores the schema
in the <a href="fileformat2.html#sqlite_master">sqlite_master</a> table as the original text of the CREATE
statements that define the schema.  Hence ALTER TABLE needs
to revise the text of the CREATE statement.  Doing
so can be tricky for certain "creative" schema designs.

<p>The SQLite approach of storing the schema as text has advantages
for an embedded relational database.  For one, it means that the
schema takes up less space in the database file.  This is important
since a common SQLite usage pattern is to have many small,
separate database files instead of putting everything in one
big global database file, which is the usual approach for client/server
database engines.
Since the schema is duplicated in each separate database file, it is
important to keep the schema representation compact.

<p>Storing the schema as text rather than as parsed tables also
give flexibility to the implementation.  Since the internal parse
of the schema is regenerated each time the database is opened, the
internal representation of the schema can change from one release
to the next.  This is important, as sometimes new features require
enhancements to the internal schema representation.  Changing the
internal schema representation would be much more difficult if the
schema representation was exposed in the database file.  So, in other
words, storing the schema as text helps maintain backwards 
compatibility, and helps ensure that older database files can be
read and written by newer versions of SQLite.

<p>Storing the schema a text also makes the 
<a href="fileformat2.html">SQLite database file format</a> easier to define, document, and 
understand. This helps make SQLite database files a
<a href="locrsf.html">recommended storage format</a> for long-term archiving of data.

<p>The downside of storing schema a text is that it can make
the schema tricky to modify.  And for that reason, the ALTER TABLE
support in SQLite has traditionally lagged behind other SQL
database engines that store their schemas as parsed system tables
that are easier to modify.














|









|



|


|





|




|



|


|


|






|




|





|


|

|

















|





|
|
|
|
|


|
|
|
|
|

|
|
















|
|

|


|


|


|





|




|






|



|


|


|
|







|





|





|









|











|




|








|
<
<
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569


</p>

<p>After ADD COLUMN has been run on a database, that database will not
be readable by SQLite version 3.1.3 (2005-02-20) and earlier.</p>

<a name="otheralter"></a>

<h1 id="making_other_kinds_of_table_schema_changes"><span>5. </span>Making Other Kinds Of Table Schema Changes</h1>

<p> The only schema altering commands directly supported by SQLite are the
"<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.  
However, applications
can make other arbitrary changes to the format of a table using a simple
sequence of operations.
The steps to make arbitrary changes to the schema design of some table X
are as follows:

</p><ol>
<li><p>
If foreign key constraints are enabled, disable them using <a href="pragma.html#pragma_foreign_keys">PRAGMA foreign_keys=OFF</a>.

</p></li><li><p>
Start a transaction.

</p></li><li><p>
Remember the format of all indexes, triggers, and views associated with table X.
This information will be needed in step 8 below.  One way to do this is
to run a query like the following:
SELECT type, sql FROM sqlite_master WHERE tbl_name='X'.

</p></li><li><p>
Use <a href="lang_createtable.html">CREATE TABLE</a> to construct a new table "new_X" that is in the desired
revised format of table X.  Make sure that the name "new_X" does not collide
with any existing table name, of course.

</p></li><li><p>
Transfer content from X into new_X using a statement
like: INSERT INTO new_X SELECT ... FROM X.

</p></li><li><p>
Drop the old table X:  <a href="lang_droptable.html">DROP TABLE X</a>.

</p></li><li><p>
Change the name of new_X to X using: ALTER TABLE new_X RENAME TO X.

</p></li><li><p>
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>
to reconstruct indexes, triggers, and views
associated with table X.  Perhaps use the old format of the triggers,
indexes, and views saved from step 3 above as a guide, making changes
as appropriate for the alteration.

</p></li><li><p>If any views refer to table X in a way that is affected by the
schema change, then drop those views using <a href="lang_dropview.html">DROP VIEW</a> and recreate them
with whatever changes are necessary to accommodate the schema change
using <a href="lang_createview.html">CREATE VIEW</a>.

</p></li><li><p>
If foreign key constraints were originally enabled
then run <a href="pragma.html#pragma_foreign_key_check">PRAGMA foreign_key_check</a> to verify that the schema
change did not break any foreign key constraints.


</p></li><li><p>
Commit the transaction started in step 2.

</p></li><li><p>
If foreign keys constraints were originally enabled, reenable them now.
</p></li></ol>

<a name="caution"></a>

<p>
<b>Caution:</b>
Take care to follow the procedure above precisely.  The boxes below
summarize two procedures for modifying a table definition.  At first
glance, they both appear to accomplish the same thing.  However, the
procedure on the right does not always work, especially with the
enhanced <a href="lang_altertable.html#altertabrename">rename table</a> capabilities added by versions 3.25.0 and
3.26.0.  In the procedure on the right, the initial rename of the
table to a temporary name might corrupt references to that table in
triggers, views, and foreign key constraints.  The safe procedure on
the left constructs the revised table definition using a new temporary
name, then renames the table into its final name, which does not break
links.

</p><center>
<table border="1" cellpadding="10" cellspacing="0">
<tr>
<td valign="top">
<ol>
<li>Create new table
</li><li>Copy data
</li><li>Drop old table
</li><li>Rename new into old
</li></ol>
</td><td valign="top">
<ol>
<li>Rename old table
</li><li>Create new table
</li><li>Copy data
</li><li>Drop old table
</li></ol>
</td></tr><tr>
<th>&uarr;<br>Correct
</th><th>&uarr;<br>Incorrect
</th></tr></table>
</center>

<p>The 12-step <a href="lang_altertable.html#otheralter">generalized ALTER TABLE procedure</a>
above will work even if the
schema change causes the information stored in the table to change.
So the full 12-step procedure above is appropriate for dropping a column,
changing the order of columns, adding or removing a UNIQUE constraint
or PRIMARY KEY, adding CHECK or FOREIGN KEY or NOT NULL constraints,
or changing the datatype for a column, for example.  However, a simpler
and faster procedure can optionally be used for
some changes that do no affect the on-disk content in any way.
The following simpler procedure is appropriate for removing
CHECK or FOREIGN KEY or NOT NULL constraints,
or adding, removing, or changing default values on
a column.

</p><ol>
<li><p> Start a transaction.

</p></li><li><p> Run <a href="pragma.html#pragma_schema_version">PRAGMA schema_version</a> to determine the current schema
version number.  This number will be needed for step 6 below.

</p></li><li><p> Activate schema editing using 
<a href="pragma.html#pragma_writable_schema">PRAGMA writable_schema=ON</a>.

</p></li><li><p> Run an <a href="lang_update.html">UPDATE</a> statement to change the definition of table X
in the <a href="fileformat2.html#sqlite_master">sqlite_master table</a>: 
UPDATE sqlite_master SET sql=... WHERE type='table' AND name='X';
</p><p><em>Caution:</em>  Making a change to the sqlite_master table like this will
render the database corrupt and unreadable if the change contains
a syntax error.  It is suggested that careful testing of the UPDATE
statement be done on a separate blank database prior to using it on
a database containing important data.

</p></li><li><p> If the change to table X also affects other tables or indexes or
triggers are views within schema, then run <a href="lang_update.html">UPDATE</a> statements to modify
those other tables indexes and views too.  For example, if the name of
a column changes, all FOREIGN KEY constraints, triggers, indexes, and
views that refer to that column must be modified.
</p><p><em>Caution:</em>  Once again, making changes to the sqlite_master 
table like this will render the database corrupt and unreadable if the 
change contains an error.  Carefully test this entire procedure
on a separate test database prior to using it on
a database containing important data and/or make backup copies of
important databases prior to running this procedure.

</p></li><li><p> Increment the schema version number using
<a href="pragma.html#pragma_schema_version">PRAGMA schema_version=X</a> where X is one
more than the old schema version number found in step 2 above.

</p></li><li><p> Disable schema editing using 
<a href="pragma.html#pragma_writable_schema">PRAGMA writable_schema=OFF</a>.

</p></li><li><p> (Optional) Run <a href="pragma.html#pragma_integrity_check">PRAGMA integrity_check</a> to verify that the
schema changes did not damage the database.

</p></li><li><p> Commit the transaction started on step 1 above.
</p></li></ol>

<p>If some future version of SQLite adds new ALTER TABLE capabilities, 
those capabilities will very likely use one of the two procedures
outlined above.

<a name="altertableishard"></a>

</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>

<p>Most SQL database engines store the schema already parsed into
various system tables.  On those database engines, ALTER TABLE merely 
has to make modifications to the corresponding system tables.

</p><p>SQLite is different in that it stores the schema
in the <a href="fileformat2.html#sqlite_master">sqlite_master</a> table as the original text of the CREATE
statements that define the schema.  Hence ALTER TABLE needs
to revise the text of the CREATE statement.  Doing
so can be tricky for certain "creative" schema designs.

</p><p>The SQLite approach of storing the schema as text has advantages
for an embedded relational database.  For one, it means that the
schema takes up less space in the database file.  This is important
since a common SQLite usage pattern is to have many small,
separate database files instead of putting everything in one
big global database file, which is the usual approach for client/server
database engines.
Since the schema is duplicated in each separate database file, it is
important to keep the schema representation compact.

</p><p>Storing the schema as text rather than as parsed tables also
give flexibility to the implementation.  Since the internal parse
of the schema is regenerated each time the database is opened, the
internal representation of the schema can change from one release
to the next.  This is important, as sometimes new features require
enhancements to the internal schema representation.  Changing the
internal schema representation would be much more difficult if the
schema representation was exposed in the database file.  So, in other
words, storing the schema as text helps maintain backwards 
compatibility, and helps ensure that older database files can be
read and written by newer versions of SQLite.

</p><p>Storing the schema a text also makes the 
<a href="fileformat2.html">SQLite database file format</a> easier to define, document, and 
understand. This helps make SQLite database files a
<a href="locrsf.html">recommended storage format</a> for long-term archiving of data.

</p><p>The downside of storing schema a text is that it can make
the schema tricky to modify.  And for that reason, the ALTER TABLE
support in SQLite has traditionally lagged behind other SQL
database engines that store their schemas as parsed system tables
that are easier to modify.




</p>


Changes to Doc/Extra/Core/lang_analyze.html.
1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>SQLite Query Language: ANALYZE</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>





|







1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>ANALYZE</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93












94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111





















112
113
114
115
116
117
118
119
120

121

122
123
124
125
126
127
128
129
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>












<div class=nosearch><h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>ANALYZE</h2></div><p><b><a href="syntax/analyze-stmt.html">analyze-stmt:</a></b>
<button id='x1243' onclick='hideorshow("x1243","x1244")'>hide</button></p>
 <div id='x1244' class='imgcontainer'>
 <img alt="syntax diagram analyze-stmt" src="images/syntax/analyze-stmt.gif" />
</div>


<p> The ANALYZE command gathers statistics about tables and
indices and stores the collected information
in <a href="fileformat2.html#intschema">internal tables</a> of the database where the query optimizer can
access the information and use it to help make better query planning choices.
If no arguments are given, all attached databases are
analyzed.  If a schema name is given as the argument, then all tables
and indices in that one database are analyzed.  
If the argument is a table name, then only that table and the
indices associated with that table are analyzed.  If the argument
is an index name, then only that one index is analyzed.</p>






















<p> The default implementation stores all statistics in a single
table named "<a href="fileformat2.html#stat1tab">sqlite_stat1</a>".  If SQLite is compiled with the
<a href="compile.html#enable_stat3">SQLITE_ENABLE_STAT3</a> option and without the <a href="compile.html#enable_stat4">SQLITE_ENABLE_STAT4</a>
option, then additional histogram data is
collected and stored in <a href="fileformat2.html#stat3tab">sqlite_stat3</a>.
 If SQLite is compiled with the
<a href="compile.html#enable_stat4">SQLITE_ENABLE_STAT4</a> option, then additional histogram data is
collected and stored in <a href="fileformat2.html#stat4tab">sqlite_stat4</a>.
Older versions of SQLite would make use of the <a href="fileformat2.html#stat2tab">sqlite_stat2</a> table

when compiled with <a href="compile.html#enable_stat2">SQLITE_ENABLE_STAT2</a> but all recent versions of

SQLite ignore the sqlite_stat2 table.
Future enhancements may create
additional <a href="fileformat2.html#intschema">internal tables</a> with the same name pattern except with
final digit larger than "4".
All of these tables are collectively referred to as "statistics tables".
</p>

<p> The content of the statistics tables can be queried using <a href="lang_select.html">SELECT</a>







|

















>
>
>
>
>
>
>
>
>
>
>
>
|
|
|















>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

|
<
<
<




>
|
>
|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146



147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<div class=fancy>
<div class=nosearch>
<div class="fancy_title">
ANALYZE
</div>
</div>




<h1 id="overview"><span>1. </span>Overview</h1>

<p><b><a href="syntax/analyze-stmt.html">analyze-stmt:</a></b>
<button id='x1285' onclick='hideorshow("x1285","x1286")'>hide</button></p>
 <div id='x1286' class='imgcontainer'>
 <img alt="syntax diagram analyze-stmt" src="images/syntax/analyze-stmt.gif" />
</div>


<p> The ANALYZE command gathers statistics about tables and
indices and stores the collected information
in <a href="fileformat2.html#intschema">internal tables</a> of the database where the query optimizer can
access the information and use it to help make better query planning choices.
If no arguments are given, all attached databases are
analyzed.  If a schema name is given as the argument, then all tables
and indices in that one database are analyzed.  
If the argument is a table name, then only that table and the
indices associated with that table are analyzed.  If the argument
is an index name, then only that one index is analyzed.</p>

<a name="req"></a>

<h2 id="recommended_usage_pattern"><span>1.1. </span>Recommended usage pattern</h2>

<p>Applications with long-lived databases that use complex
queries should consider running the following commands just prior
to closing each database connection:

</p><div class="codeblock"><pre>PRAGMA analysis_limit=400;
PRAGMA optimize;
</pre></div>

<p>The <a href="pragma.html#pragma_optimize">optimize pragma</a> is usually a no-op but it will occasionally
run ANALYZE if it seems like doing so will be useful to the query planner.
The <a href="pragma.html#pragma_analysis_limit">analysis_limit pragma</a> limits the scope of any ANALYZE command that
the <a href="pragma.html#pragma_optimize">optimize pragma</a> runs so that it does not consume too many CPU cycles.
The constant "400" can be adjusted as needed.  Values between 100 and
1000 work well for most applications.

</p><h1 id="details"><span>2. </span>Details</h1>

<p> The default implementation stores all statistics in a single
table named "<a href="fileformat2.html#stat1tab">sqlite_stat1</a>".  



 If SQLite is compiled with the
<a href="compile.html#enable_stat4">SQLITE_ENABLE_STAT4</a> option, then additional histogram data is
collected and stored in <a href="fileformat2.html#stat4tab">sqlite_stat4</a>.
Older versions of SQLite would make use of the <a href="fileformat2.html#stat2tab">sqlite_stat2</a> table
or <a href="fileformat2.html#stat3tab">sqlite_stat3</a> table
when compiled with <a href="compile.html#enable_stat2">SQLITE_ENABLE_STAT2</a> or <a href="compile.html#enable_stat3">SQLITE_ENABLE_STAT3</a>,
but all recent versions of
SQLite ignore the sqlite_stat2 and sqlite_stat3 tables.
Future enhancements may create
additional <a href="fileformat2.html#intschema">internal tables</a> with the same name pattern except with
final digit larger than "4".
All of these tables are collectively referred to as "statistics tables".
</p>

<p> The content of the statistics tables can be queried using <a href="lang_select.html">SELECT</a>
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
changes the statistics tables directly, SQLite will not immediately
notice the changes. An application
can force the query planner to reread the statistics tables by running
<b>ANALYZE sqlite_master</b>. </p>

<a name="autoanalyze"></a>

<h2>Automatically Running ANALYZE</h2>

<p>The <a href="pragma.html#pragma_optimize">PRAGMA optimize</a> command will automatically run ANALYZE on individual
tables on an as-needed basis.  The recommended practice is for applications
to invoke the <a href="pragma.html#pragma_optimize">PRAGMA optimize</a> statement just before closing each database
connection.</p>

<p>Each SQLite <a href="c3ref/sqlite3.html">database connection</a> records cases when the query planner would







|







181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
changes the statistics tables directly, SQLite will not immediately
notice the changes. An application
can force the query planner to reread the statistics tables by running
<b>ANALYZE sqlite_master</b>. </p>

<a name="autoanalyze"></a>

<h1 id="automatically_running_analyze"><span>3. </span>Automatically Running ANALYZE</h1>

<p>The <a href="pragma.html#pragma_optimize">PRAGMA optimize</a> command will automatically run ANALYZE on individual
tables on an as-needed basis.  The recommended practice is for applications
to invoke the <a href="pragma.html#pragma_optimize">PRAGMA optimize</a> statement just before closing each database
connection.</p>

<p>Each SQLite <a href="c3ref/sqlite3.html">database connection</a> records cases when the query planner would
184
185
186
187
188
189
190

191

192






193


194


195









196




197




198









199






200

201




to run the suggested ANALYZE commands, perhaps after prompting the user
for guidance.</p>

<p>The <a href="pragma.html#pragma_optimize">PRAGMA optimize</a> command was first introduced with 
SQLite 3.18.0 (2017-03-28) and is a no-op for all prior releases
of SQLite.</p>


<h2>Anticipated Future Enhancements</h2>








<p>All existing versions of SQLite do a full table scan for ANALYZE.  This can be


slow for multi-gigabyte and larger databases.  Future versions of SQLite might


use random sampling rather than a full table scan to obtain estimates for the









database shape, especially on larger tables.  The results would approximate, but 




will be close enough for query planning purposes.  As of 2017-03-20, this




concept has been tested in experimental branches and appears to work well, but









has not been folded into an official release.</p>




















>
|
>

>
>
>
>
>
>
|
>
>
|
>
>
|
>
>
>
>
>
>
>
>
>
|
>
>
>
>
|
>
>
>
>
|
>
>
>
>
>
>
>
>
>
|
>
>
>
>
>
>

>

>
>
>
>
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
to run the suggested ANALYZE commands, perhaps after prompting the user
for guidance.</p>

<p>The <a href="pragma.html#pragma_optimize">PRAGMA optimize</a> command was first introduced with 
SQLite 3.18.0 (2017-03-28) and is a no-op for all prior releases
of SQLite.</p>

<a name="approx"></a>

<h1 id="approximate_analyze_for_large_databases"><span>4. </span>Approximate ANALYZE For Large Databases</h1>

<p>By default, ANALYZE does a full scan of every index.  This can be slow for
large databases.  So beginning with SQLite version 3.32.0 (2020-05-22), the
<a href="pragma.html#pragma_analysis_limit">PRAGMA analysis_limit</a> command can be used to limit the amount of
scanning performed by ANALYZE, and thus help ANALYZE to run faster,
even on very large database files.  We call this running an
"approximate ANALYZE".

</p><p>The recommended usage pattern for the <a href="pragma.html#pragma_analysis_limit">analysis_limit</a> pragma is
like this:

</p><div class="codeblock"><pre>PRAGMA analysis_limit=1000;
</pre></div>

<p>This pragma tells the ANALYZE command to start a full scan
of the index as it normally would.  But when the number of rows visited
reaches 1000 (or whatever other limit is specified by the pragma), the
ANALYZE command will begin taking actions to stop the scan.  If
the left-most column of the index has changed at least once during the
previous 1000 steps, then the analysis stops immediately.  But if the
left-most column has always been the same, then ANALYZE skips ahead to
the first entry with a different left-most column and reads an additional
1000 rows before terminating.

</p><p>The details of the effects of the analysis limit described in the previous
paragraph are subject to change in future versions of SQLite.  But the
core idea will remain the same.  An analysis limit of N will strive to
limit the number of rows visited in each index to approximately N.

</p><p>Values of N between 100 and 1000 are recommended.
Or, to disable the analysis limit, causing ANALYZE to do a
complete scan of each index, set the analysis limit to 0.  The default
value for the analysis limit is 0 for backwards compatibility.

</p><p>The values placed in the sqlite_stat1 table by an approximate ANALYZE
are not exactly the same as what would be computed by an unrestricted 
analysis.  But they are usually close enough.  The index statistics in
the sqlite_stat1 table are approximations in any case, so the fact that
the results of an approximate ANALYZE are slightly different from
a traditional full scan ANALYZE has little practical impact.  It is
possible to construct a pathological case where an approximate ANALYZE
is noticeably inferior to a full-scan ANALYZE, but such cases rare in
real-world problems.

</p><p>A good rule of thumb seems to be to always set "PRAGMA analysis_limit=N"
for N between 100 and 1000 prior to running either "ANALYZE" or
"<a href="pragma.html#pragma_optimize">PRAGMA optimize</a>".  The results are not quite as precise, but they
are precise enough, and the fact that the results are computed so much
faster means that developers are more likely to compute them.  An
approximate ANALYZE is better than not running ANALYZE at all.

</p><h2 id="limitations_of_approximate_analyze"><span>4.1. </span>Limitations of approximate ANALYZE</h2>

<p>The content in the sqlite_stat4 table cannot be computed with
anything less than a full scan.  Hence, if a non-zero analysis limit
is specified, the sqlite_stat4 table is not computed.
</p>
Changes to Doc/Extra/Core/lang_attach.html.
1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>SQLite Query Language: ATTACH DATABASE</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>





|







1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>ATTACH DATABASE</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93











94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204


205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>











<div class=nosearch><h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>ATTACH DATABASE</h2></div><p><b><a href="syntax/attach-stmt.html">attach-stmt:</a></b>
<button id='x1245' onclick='hideorshow("x1245","x1246")'>hide</button></p>
 <div id='x1246' class='imgcontainer'>
 <img alt="syntax diagram attach-stmt" src="images/syntax/attach-stmt.gif" />
<p><b><a href="syntax/expr.html">expr:</a></b>
<button id='x1247' onclick='hideorshow("x1247","x1248")'>show</button></p>
 <div id='x1248' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntax/filter-clause.html">filter-clause:</a></b>
<button id='x1249' onclick='hideorshow("x1249","x1250")'>show</button></p>
 <div id='x1250' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram filter-clause" src="images/syntax/filter-clause.gif" />
</div>
<p><b><a href="syntax/literal-value.html">literal-value:</a></b>
<button id='x1251' onclick='hideorshow("x1251","x1252")'>show</button></p>
 <div id='x1252' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</div>
<p><b><a href="syntax/over-clause.html">over-clause:</a></b>
<button id='x1253' onclick='hideorshow("x1253","x1254")'>show</button></p>
 <div id='x1254' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram over-clause" src="images/syntax/over-clause.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x1255' onclick='hideorshow("x1255","x1256")'>show</button></p>
 <div id='x1256' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
<button id='x1257' onclick='hideorshow("x1257","x1258")'>show</button></p>
 <div id='x1258' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</div>
</div>
<p><b><a href="syntax/raise-function.html">raise-function:</a></b>
<button id='x1259' onclick='hideorshow("x1259","x1260")'>show</button></p>
 <div id='x1260' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</div>
<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
<button id='x1261' onclick='hideorshow("x1261","x1262")'>show</button></p>
 <div id='x1262' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntax/common-table-expression.html">common-table-expression:</a></b>
<button id='x1263' onclick='hideorshow("x1263","x1264")'>show</button></p>
 <div id='x1264' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
</div>
<p><b><a href="syntax/compound-operator.html">compound-operator:</a></b>
<button id='x1265' onclick='hideorshow("x1265","x1266")'>show</button></p>
 <div id='x1266' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</div>
<p><b><a href="syntax/join-clause.html">join-clause:</a></b>
<button id='x1267' onclick='hideorshow("x1267","x1268")'>show</button></p>
 <div id='x1268' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
<button id='x1269' onclick='hideorshow("x1269","x1270")'>show</button></p>
 <div id='x1270' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</div>
<p><b><a href="syntax/join-operator.html">join-operator:</a></b>
<button id='x1271' onclick='hideorshow("x1271","x1272")'>show</button></p>
 <div id='x1272' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</div>
</div>
<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
<button id='x1273' onclick='hideorshow("x1273","x1274")'>show</button></p>
 <div id='x1274' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</div>
<p><b><a href="syntax/result-column.html">result-column:</a></b>
<button id='x1275' onclick='hideorshow("x1275","x1276")'>show</button></p>
 <div id='x1276' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</div>
<p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
<button id='x1277' onclick='hideorshow("x1277","x1278")'>show</button></p>
 <div id='x1278' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</div>
<p><b><a href="syntax/window-defn.html">window-defn:</a></b>
<button id='x1279' onclick='hideorshow("x1279","x1280")'>show</button></p>
 <div id='x1280' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram window-defn" src="images/syntax/window-defn.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x1281' onclick='hideorshow("x1281","x1282")'>show</button></p>
 <div id='x1282' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
</div>
</div>
<p><b><a href="syntax/type-name.html">type-name:</a></b>
<button id='x1283' onclick='hideorshow("x1283","x1284")'>show</button></p>
 <div id='x1284' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
<button id='x1285' onclick='hideorshow("x1285","x1286")'>show</button></p>
 <div id='x1286' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</div>
</div>
</div>
</div>


<p> The ATTACH DATABASE statement adds another database 
file to the current <a href="c3ref/sqlite3.html">database connection</a>. 
Database files that were previously attached can be removed using
the <a href="lang_detach.html">DETACH DATABASE</a> command.



<p>The filename for the database to be attached is the value of
the expression that occurs before the AS keyword.
The filename of the database follows the same semantics as the
filename argument to <a href="c3ref/open.html">sqlite3_open()</a> and <a href="c3ref/open.html">sqlite3_open_v2()</a>; the
special name "<a href="inmemorydb.html">:memory:</a>" results in an <a href="inmemorydb.html">in-memory database</a> and an
empty string results in a new temporary database.
The filename argument can be a <a href="uri.html">URI filename</a> if URI filename processing
is enable on the database connection.  The default behavior is for
URI filenames to be disabled, however that might change in a future release
of SQLite, so application developers are advised to plan accordingly.

<p>The name that occurs after the AS keyword is the name of the database
used internally by SQLite.
The schema-names 'main' and 
'temp' refer to the main database and the database used for 
temporary tables.  The main and temp databases cannot be attached or
detached.</p>

<p> Tables in an attached database can be referred to using the syntax 







|

















>
>
>
>
>
>
>
>
>
>
>
|
|
|


|
|


|
|



|
|



|
|


|
|



|
|




|
|



|
|


|
|



|
|



|
|


|
|



|
|




|
|



|
|



|
|



|
|


|
|





|
|


|
|











>
>












|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<div class=fancy>
<div class=nosearch>
<div class="fancy_title">
ATTACH DATABASE
</div>
</div>




<h1 id="overview"><span>1. </span>Overview</h1>
<p><b><a href="syntax/attach-stmt.html">attach-stmt:</a></b>
<button id='x1287' onclick='hideorshow("x1287","x1288")'>hide</button></p>
 <div id='x1288' class='imgcontainer'>
 <img alt="syntax diagram attach-stmt" src="images/syntax/attach-stmt.gif" />
<p><b><a href="syntax/expr.html">expr:</a></b>
<button id='x1289' onclick='hideorshow("x1289","x1290")'>show</button></p>
 <div id='x1290' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntax/filter-clause.html">filter-clause:</a></b>
<button id='x1291' onclick='hideorshow("x1291","x1292")'>show</button></p>
 <div id='x1292' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram filter-clause" src="images/syntax/filter-clause.gif" />
</div>
<p><b><a href="syntax/literal-value.html">literal-value:</a></b>
<button id='x1293' onclick='hideorshow("x1293","x1294")'>show</button></p>
 <div id='x1294' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</div>
<p><b><a href="syntax/over-clause.html">over-clause:</a></b>
<button id='x1295' onclick='hideorshow("x1295","x1296")'>show</button></p>
 <div id='x1296' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram over-clause" src="images/syntax/over-clause.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x1297' onclick='hideorshow("x1297","x1298")'>show</button></p>
 <div id='x1298' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
<button id='x1299' onclick='hideorshow("x1299","x1300")'>show</button></p>
 <div id='x1300' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</div>
</div>
<p><b><a href="syntax/raise-function.html">raise-function:</a></b>
<button id='x1301' onclick='hideorshow("x1301","x1302")'>show</button></p>
 <div id='x1302' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</div>
<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
<button id='x1303' onclick='hideorshow("x1303","x1304")'>show</button></p>
 <div id='x1304' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntax/common-table-expression.html">common-table-expression:</a></b>
<button id='x1305' onclick='hideorshow("x1305","x1306")'>show</button></p>
 <div id='x1306' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
</div>
<p><b><a href="syntax/compound-operator.html">compound-operator:</a></b>
<button id='x1307' onclick='hideorshow("x1307","x1308")'>show</button></p>
 <div id='x1308' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</div>
<p><b><a href="syntax/join-clause.html">join-clause:</a></b>
<button id='x1309' onclick='hideorshow("x1309","x1310")'>show</button></p>
 <div id='x1310' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
<button id='x1311' onclick='hideorshow("x1311","x1312")'>show</button></p>
 <div id='x1312' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</div>
<p><b><a href="syntax/join-operator.html">join-operator:</a></b>
<button id='x1313' onclick='hideorshow("x1313","x1314")'>show</button></p>
 <div id='x1314' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</div>
</div>
<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
<button id='x1315' onclick='hideorshow("x1315","x1316")'>show</button></p>
 <div id='x1316' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</div>
<p><b><a href="syntax/result-column.html">result-column:</a></b>
<button id='x1317' onclick='hideorshow("x1317","x1318")'>show</button></p>
 <div id='x1318' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</div>
<p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
<button id='x1319' onclick='hideorshow("x1319","x1320")'>show</button></p>
 <div id='x1320' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</div>
<p><b><a href="syntax/window-defn.html">window-defn:</a></b>
<button id='x1321' onclick='hideorshow("x1321","x1322")'>show</button></p>
 <div id='x1322' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram window-defn" src="images/syntax/window-defn.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x1323' onclick='hideorshow("x1323","x1324")'>show</button></p>
 <div id='x1324' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
</div>
</div>
<p><b><a href="syntax/type-name.html">type-name:</a></b>
<button id='x1325' onclick='hideorshow("x1325","x1326")'>show</button></p>
 <div id='x1326' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
<button id='x1327' onclick='hideorshow("x1327","x1328")'>show</button></p>
 <div id='x1328' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</div>
</div>
</div>
</div>


<p> The ATTACH DATABASE statement adds another database 
file to the current <a href="c3ref/sqlite3.html">database connection</a>. 
Database files that were previously attached can be removed using
the <a href="lang_detach.html">DETACH DATABASE</a> command.

</p><h1 id="details"><span>2. </span>Details</h1>

<p>The filename for the database to be attached is the value of
the expression that occurs before the AS keyword.
The filename of the database follows the same semantics as the
filename argument to <a href="c3ref/open.html">sqlite3_open()</a> and <a href="c3ref/open.html">sqlite3_open_v2()</a>; the
special name "<a href="inmemorydb.html">:memory:</a>" results in an <a href="inmemorydb.html">in-memory database</a> and an
empty string results in a new temporary database.
The filename argument can be a <a href="uri.html">URI filename</a> if URI filename processing
is enable on the database connection.  The default behavior is for
URI filenames to be disabled, however that might change in a future release
of SQLite, so application developers are advised to plan accordingly.

</p><p>The name that occurs after the AS keyword is the name of the database
used internally by SQLite.
The schema-names 'main' and 
'temp' refer to the main database and the database used for 
temporary tables.  The main and temp databases cannot be attached or
detached.</p>

<p> Tables in an attached database can be referred to using the syntax 
240
241
242
243
244
245
246
247
248
some of those files might get the changes where others
might not.
</p>

<p> There is a limit, set using <a href="c3ref/limit.html">sqlite3_limit()</a> and 
<a href="c3ref/c_limit_attached.html#sqlitelimitattached">SQLITE_LIMIT_ATTACHED</a>, to the number of databases that can be
simultaneously attached to a single database connection.</p>










<
253
254
255
256
257
258
259
260

some of those files might get the changes where others
might not.
</p>

<p> There is a limit, set using <a href="c3ref/limit.html">sqlite3_limit()</a> and 
<a href="c3ref/c_limit_attached.html#sqlitelimitattached">SQLITE_LIMIT_ATTACHED</a>, to the number of databases that can be
simultaneously attached to a single database connection.</p>


Changes to Doc/Extra/Core/lang_comment.html.
1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>SQLite Query Language: comment</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>





|







1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>SQL Comment Syntax</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93











94
95
96
97
98
99
100
101
102
103
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>











<div class=nosearch><h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>comment</h2></div><p><b><a href="syntax/comment-syntax.html">comment-syntax:</a></b>
<button id='x1299' onclick='hideorshow("x1299","x1300")'>hide</button></p>
 <div id='x1300' class='imgcontainer'>
 <img alt="syntax diagram comment-syntax" src="images/syntax/comment-syntax.gif" />
</div>


<p>Comments are not SQL commands, but can occur within the text of
SQL queries passed to <a href="c3ref/prepare.html">sqlite3_prepare_v2()</a> and related interfaces.
Comments are treated as whitespace by the parser.







|

















>
>
>
>
>
>
>
>
>
>
>
|
|
|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<div class=fancy>
<div class=nosearch>
<div class="fancy_title">
SQL Comment Syntax
</div>
</div>





<p><b><a href="syntax/comment-syntax.html">comment-syntax:</a></b>
<button id='x1329' onclick='hideorshow("x1329","x1330")'>hide</button></p>
 <div id='x1330' class='imgcontainer'>
 <img alt="syntax diagram comment-syntax" src="images/syntax/comment-syntax.gif" />
</div>


<p>Comments are not SQL commands, but can occur within the text of
SQL queries passed to <a href="c3ref/prepare.html">sqlite3_prepare_v2()</a> and related interfaces.
Comments are treated as whitespace by the parser.
114
115
116
117
118
119
120
121
122
123
or until the end of input, whichever comes first.  C-style comments
can span multiple lines. </p>

<p>Comments can appear anywhere whitespace can occur,
including inside expressions and in the middle of other SQL statements.
Comments do not nest.
</p>











<
<
125
126
127
128
129
130
131
132


or until the end of input, whichever comes first.  C-style comments
can span multiple lines. </p>

<p>Comments can appear anywhere whitespace can occur,
including inside expressions and in the middle of other SQL statements.
Comments do not nest.
</p>



Changes to Doc/Extra/Core/lang_conflict.html.
1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>SQLite Query Language: ON CONFLICT clause</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>





|







1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>The ON CONFLICT Clause</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93










94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>










<div class=nosearch><h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>ON CONFLICT clause</h2></div><p><b><a href="syntax/conflict-clause.html">conflict-clause:</a></b>
<button id='x1813' onclick='hideorshow("x1813","x1814")'>hide</button></p>
 <div id='x1814' class='imgcontainer'>
 <img alt="syntax diagram conflict-clause" src="images/syntax/conflict-clause.gif" />
</div>


<p>The ON CONFLICT clause is a
non-standard extension specific to SQLite 
that can appear in many other SQL commands.
It is given its own section in this document because it is not
part of standard SQL and therefore might not be familiar.</p>

<p>The ON CONFLICT clause described here has been a part of
SQLite since before version 3.0.0 (2004-06-18).  The phrase
"ON&nbsp;CONFLICT" is also part of <a href="lang_UPSERT.html">UPSERT</a>, which is an extension
to <a href="lang_insert.html">INSERT</a> added in version 3.24.0 (2018-06-04).  Do not
confuse these two separate uses of the "ON&nbsp;CONFLICT" phrase.

<p>The syntax for the ON CONFLICT clause is as shown above for
the CREATE TABLE command.  For the INSERT and
UPDATE commands, the keywords "ON CONFLICT" are replaced by "OR" so that
the syntax reads more naturally.  For example, instead of
"INSERT ON CONFLICT IGNORE" we have "INSERT OR IGNORE".
The keywords change but the meaning of the clause is the same
either way.</p>








|

















>
>
>
>
>
>
>
>
>
>
|
|
|












|



|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<div class=fancy>
<div class=nosearch>
<div class="fancy_title">
The ON CONFLICT Clause
</div>
</div>




<p><b><a href="syntax/conflict-clause.html">conflict-clause:</a></b>
<button id='x1331' onclick='hideorshow("x1331","x1332")'>hide</button></p>
 <div id='x1332' class='imgcontainer'>
 <img alt="syntax diagram conflict-clause" src="images/syntax/conflict-clause.gif" />
</div>


<p>The ON CONFLICT clause is a
non-standard extension specific to SQLite 
that can appear in many other SQL commands.
It is given its own section in this document because it is not
part of standard SQL and therefore might not be familiar.</p>

<p>The ON CONFLICT clause described here has been a part of
SQLite since before version 3.0.0 (2004-06-18).  The phrase
"ON&nbsp;CONFLICT" is also part of <a href="lang_upsert.html">UPSERT</a>, which is an extension
to <a href="lang_insert.html">INSERT</a> added in version 3.24.0 (2018-06-04).  Do not
confuse these two separate uses of the "ON&nbsp;CONFLICT" phrase.

</p><p>The syntax for the ON CONFLICT clause is as shown above for
the CREATE TABLE command.  For the INSERT and
UPDATE commands, the keywords "ON CONFLICT" are replaced by "OR" so that
the syntax reads more naturally.  For example, instead of
"INSERT ON CONFLICT IGNORE" we have "INSERT OR IGNORE".
The keywords change but the meaning of the clause is the same
either way.</p>

194
195
196
197
198
199
200
201
202
203
204
205
206
207
<a href="pragma.html#pragma_recursive_triggers">recursive triggers</a> are enabled.</p>

<p>The <a href="c3ref/update_hook.html">update hook</a> is not invoked for rows that
are deleted by the REPLACE conflict resolution strategy.  Nor does
REPLACE increment the <a href="c3ref/changes.html">change counter</a>.
The exceptional behaviors defined in this paragraph might change 
in a future release.</p>
</dl>

<p>The algorithm specified in the OR clause of an INSERT or UPDATE
overrides any algorithm specified in a CREATE TABLE.
If no algorithm is specified anywhere, the ABORT algorithm is used.</p>









|





<
204
205
206
207
208
209
210
211
212
213
214
215
216

<a href="pragma.html#pragma_recursive_triggers">recursive triggers</a> are enabled.</p>

<p>The <a href="c3ref/update_hook.html">update hook</a> is not invoked for rows that
are deleted by the REPLACE conflict resolution strategy.  Nor does
REPLACE increment the <a href="c3ref/changes.html">change counter</a>.
The exceptional behaviors defined in this paragraph might change 
in a future release.</p>
</dd></dl>

<p>The algorithm specified in the OR clause of an INSERT or UPDATE
overrides any algorithm specified in a CREATE TABLE.
If no algorithm is specified anywhere, the ABORT algorithm is used.</p>


Changes to Doc/Extra/Core/lang_corefunc.html.
1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>SQLite Query Language: Core Functions</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>





|







1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>Built-In Scalar SQL Functions</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93

94










95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116

117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146













147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189

190

191
192
193
194
195
196
197
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>

<div class=nosearch><h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>Core Functions</h2></div>











<p>The core functions shown below are available by default. 
<a href="lang_datefunc.html">Date &amp; Time functions</a>,
<a href="lang_aggfunc.html">aggregate functions</a>,
<a href="windowfunctions.html#biwinfunc">window functions</a>, and
<a href="json1.html">JSON functions</a> are documented separately.  An
application may define additional
functions written in C and added to the database engine using
the <a href="c3ref/create_function.html">sqlite3_create_function()</a> API.</p>

<style>
#listtab34 tr td {vertical-align:top;}
</style>
<table id='listtab34' width='100%'></table>
<script>
var listitems34 = [{"u":"lang_corefunc.html#abs","x":"abs(X)","s":0},
{"u":"lang_corefunc.html#changes","x":"changes()","s":0},
{"u":"lang_corefunc.html#char","x":"char(X1,X2,...,XN)","s":0},
{"u":"lang_corefunc.html#coalesce","x":"coalesce(X,Y,...)","s":0},
{"u":"lang_corefunc.html#glob","x":"glob(X,Y)","s":0},
{"u":"lang_corefunc.html#hex","x":"hex(X)","s":0},
{"u":"lang_corefunc.html#ifnull","x":"ifnull(X,Y)","s":0},

{"u":"lang_corefunc.html#instr","x":"instr(X,Y)","s":0},
{"u":"lang_corefunc.html#last_insert_rowid","x":"last_insert_rowid()","s":0},
{"u":"lang_corefunc.html#length","x":"length(X)","s":0},
{"u":"lang_corefunc.html#like","x":"like(X,Y)","s":0},
{"u":"lang_corefunc.html#like","x":"like(X,Y,Z)","s":0},
{"u":"lang_corefunc.html#likelihood","x":"likelihood(X,Y)","s":0},
{"u":"lang_corefunc.html#likely","x":"likely(X)","s":0},
{"u":"lang_corefunc.html#load_extension","x":"load_extension(X)","s":0},
{"u":"lang_corefunc.html#load_extension","x":"load_extension(X,Y)","s":0},
{"u":"lang_corefunc.html#lower","x":"lower(X)","s":0},
{"u":"lang_corefunc.html#ltrim","x":"ltrim(X)","s":0},
{"u":"lang_corefunc.html#ltrim","x":"ltrim(X,Y)","s":0},
{"u":"lang_corefunc.html#maxoreunc","x":"max(X,Y,...)","s":0},
{"u":"lang_corefunc.html#minoreunc","x":"min(X,Y,...)","s":0},
{"u":"lang_corefunc.html#nullif","x":"nullif(X,Y)","s":0},
{"u":"lang_corefunc.html#printf","x":"printf(FORMAT,...)","s":0},
{"u":"lang_corefunc.html#quote","x":"quote(X)","s":0},
{"u":"lang_corefunc.html#random","x":"random()","s":0},
{"u":"lang_corefunc.html#randomblob","x":"randomblob(N)","s":0},
{"u":"lang_corefunc.html#replace","x":"replace(X,Y,Z)","s":0},
{"u":"lang_corefunc.html#round","x":"round(X)","s":0},
{"u":"lang_corefunc.html#round","x":"round(X,Y)","s":0},
{"u":"lang_corefunc.html#rtrim","x":"rtrim(X)","s":0},
{"u":"lang_corefunc.html#rtrim","x":"rtrim(X,Y)","s":0},
{"u":"lang_corefunc.html#soundex","x":"soundex(X)","s":0},
{"u":"lang_corefunc.html#sqlite_compileoption_get","x":"sqlite_compileoption_get(N)","s":0},
{"u":"lang_corefunc.html#sqlite_compileoption_used","x":"sqlite_compileoption_used(X)","s":0},
{"u":"lang_corefunc.html#sqlite_offset","x":"sqlite_offset(X)","s":0},
{"u":"lang_corefunc.html#sqlite_source_id","x":"sqlite_source_id()","s":0},
{"u":"lang_corefunc.html#sqlite_version","x":"sqlite_version()","s":0},













{"u":"lang_corefunc.html#substr","x":"substr(X,Y)","s":0},
{"u":"lang_corefunc.html#substr","x":"substr(X,Y,Z)","s":0},
{"u":"lang_corefunc.html#total_changes","x":"total_changes()","s":0},
{"u":"lang_corefunc.html#trim","x":"trim(X)","s":0},
{"u":"lang_corefunc.html#trim","x":"trim(X,Y)","s":0},
{"u":"lang_corefunc.html#typeof","x":"typeof(X)","s":0},
{"u":"lang_corefunc.html#unicode","x":"unicode(X)","s":0},
{"u":"lang_corefunc.html#unlikely","x":"unlikely(X)","s":0},
{"u":"lang_corefunc.html#upper","x":"upper(X)","s":0},
{"u":"lang_corefunc.html#zeroblob","x":"zeroblob(N)","s":0}];
var j = 0;
var w = Math.max(document.documentElement.clientWidth,  window.innerWidth || 0);
var nCol = Math.floor(w/225);
if(nCol<=0) nCol=1;
var nRow = Math.ceil((listitems34.length+1)/nCol);
var h="<tr><td><ul class='multicol_list'>"
var ea
for(var i=0; i<listitems34.length; i++){
  if( (++j)>nRow ){
    h += "</ul></td>\n<td><ul class='multicol_list'>\n";
    j = 1;
  }
  if(listitems34[i].u=="" || listitems34[i].s==2){
    h += "<li>"
    ea = ""
  }else{
    h += "<li><a href='";
    h += listitems34[i].u;
    h += "'>";
    ea = "</a>"
  }
  if(listitems34[i].s==2 || listitems34[i].s==3) h += "<s>"
  h += listitems34[i].x;
  if(listitems34[i].s==2 || listitems34[i].s==3) h += "</s>"
  h += ea
  if(listitems34[i].s==1) h += "<small><i>(exp)</i></small>\n";
  if(listitems34[i].s==3) h += "&sup1\n";
  if(listitems34[i].s==4) h += "&sup2\n";
  if(listitems34[i].s==5) h += "&sup3\n";
}
document.getElementById("listtab34").innerHTML = h;
</script>
<hr class='xhr'>

<dl>

<a name="abs"></a>
<dt><p><b>abs(<i>X</i>)</b></dt><dd><p>
  The abs(X) function returns the absolute value of the numeric
  argument X.  Abs(X) returns NULL if X is NULL. 
  Abs(X) returns 0.0 if X is a string or blob
  that cannot be converted to a numeric value.  If X is the 
  integer -9223372036854775808 then abs(X) throws an integer overflow







|

















>
|
>
>
>
>
>
>
>
>
>
>










|
|
|
<
<
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<
<
<
<
<
<
<
<
<
<
<
<
<
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
|
|
|
|
|
|
|
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
<
<
<
|
|
<
<
<
<
<
<
<
<
|
<
<
<
>

>







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118


119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143













144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166















167



168
169








170



171
172
173
174
175
176
177
178
179
180
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<div class=fancy>
<div class=nosearch>
<div class="fancy_title">
Built-In Scalar SQL Functions
</div>
</div>





<h1 id="overview"><span>1. </span>Overview</h1>

<p>The core functions shown below are available by default. 
<a href="lang_datefunc.html">Date &amp; Time functions</a>,
<a href="lang_aggfunc.html">aggregate functions</a>,
<a href="windowfunctions.html#biwinfunc">window functions</a>, and
<a href="json1.html">JSON functions</a> are documented separately.  An
application may define additional
functions written in C and added to the database engine using
the <a href="c3ref/create_function.html">sqlite3_create_function()</a> API.</p>

<p>
<div class='columns' style='columns: 15em auto;'>
<ul style='padding-top:0;'>


<li><a href='lang_corefunc.html#abs'>abs(X)</a></li>
<li><a href='lang_corefunc.html#changes'>changes()</a></li>
<li><a href='lang_corefunc.html#char'>char(X1,X2,...,XN)</a></li>
<li><a href='lang_corefunc.html#coalesce'>coalesce(X,Y,...)</a></li>
<li><a href='lang_corefunc.html#glob'>glob(X,Y)</a></li>
<li><a href='lang_corefunc.html#hex'>hex(X)</a></li>
<li><a href='lang_corefunc.html#ifnull'>ifnull(X,Y)</a></li>
<li><a href='lang_corefunc.html#iif'>iif(X,Y,Z)</a></li>
<li><a href='lang_corefunc.html#instr'>instr(X,Y)</a></li>
<li><a href='lang_corefunc.html#last_insert_rowid'>last_insert_rowid()</a></li>
<li><a href='lang_corefunc.html#length'>length(X)</a></li>
<li><a href='lang_corefunc.html#like'>like(X,Y)</a></li>
<li><a href='lang_corefunc.html#like'>like(X,Y,Z)</a></li>
<li><a href='lang_corefunc.html#likelihood'>likelihood(X,Y)</a></li>
<li><a href='lang_corefunc.html#likely'>likely(X)</a></li>
<li><a href='lang_corefunc.html#load_extension'>load_extension(X)</a></li>
<li><a href='lang_corefunc.html#load_extension'>load_extension(X,Y)</a></li>
<li><a href='lang_corefunc.html#lower'>lower(X)</a></li>
<li><a href='lang_corefunc.html#ltrim'>ltrim(X)</a></li>
<li><a href='lang_corefunc.html#ltrim'>ltrim(X,Y)</a></li>
<li><a href='lang_corefunc.html#maxoreunc'>max(X,Y,...)</a></li>
<li><a href='lang_corefunc.html#minoreunc'>min(X,Y,...)</a></li>
<li><a href='lang_corefunc.html#nullif'>nullif(X,Y)</a></li>
<li><a href='lang_corefunc.html#printf'>printf(FORMAT,...)</a></li>
<li><a href='lang_corefunc.html#quote'>quote(X)</a></li>













<li><a href='lang_corefunc.html#random'>random()</a></li>
<li><a href='lang_corefunc.html#randomblob'>randomblob(N)</a></li>
<li><a href='lang_corefunc.html#replace'>replace(X,Y,Z)</a></li>
<li><a href='lang_corefunc.html#round'>round(X)</a></li>
<li><a href='lang_corefunc.html#round'>round(X,Y)</a></li>
<li><a href='lang_corefunc.html#rtrim'>rtrim(X)</a></li>
<li><a href='lang_corefunc.html#rtrim'>rtrim(X,Y)</a></li>
<li><a href='lang_corefunc.html#soundex'>soundex(X)</a></li>
<li><a href='lang_corefunc.html#sqlite_compileoption_get'>sqlite_compileoption_get(N)</a></li>
<li><a href='lang_corefunc.html#sqlite_compileoption_used'>sqlite_compileoption_used(X)</a></li>
<li><a href='lang_corefunc.html#sqlite_offset'>sqlite_offset(X)</a></li>
<li><a href='lang_corefunc.html#sqlite_source_id'>sqlite_source_id()</a></li>
<li><a href='lang_corefunc.html#sqlite_version'>sqlite_version()</a></li>
<li><a href='lang_corefunc.html#substr'>substr(X,Y)</a></li>
<li><a href='lang_corefunc.html#substr'>substr(X,Y,Z)</a></li>
<li><a href='lang_corefunc.html#total_changes'>total_changes()</a></li>
<li><a href='lang_corefunc.html#trim'>trim(X)</a></li>
<li><a href='lang_corefunc.html#trim'>trim(X,Y)</a></li>
<li><a href='lang_corefunc.html#typeof'>typeof(X)</a></li>
<li><a href='lang_corefunc.html#unicode'>unicode(X)</a></li>
<li><a href='lang_corefunc.html#unlikely'>unlikely(X)</a></li>
<li><a href='lang_corefunc.html#upper'>upper(X)</a></li>
<li><a href='lang_corefunc.html#zeroblob'>zeroblob(N)</a></li>















</ul>



</div>













<h1 id="descriptions_of_built_in_scalar_sql_functions"><span>2. </span>Descriptions of built-in scalar SQL functions</h1>
<dl>

<a name="abs"></a>
<dt><p><b>abs(<i>X</i>)</b></dt><dd><p>
  The abs(X) function returns the absolute value of the numeric
  argument X.  Abs(X) returns NULL if X is NULL. 
  Abs(X) returns 0.0 if X is a string or blob
  that cannot be converted to a numeric value.  If X is the 
  integer -9223372036854775808 then abs(X) throws an integer overflow
239
240
241
242
243
244
245






246
247
248
249
250
251
252
</dd>
<a name="ifnull"></a>
<dt><p><b>ifnull(<i>X</i>,<i>Y</i>)</b></dt><dd><p>
  The ifnull() function returns a copy of its first non-NULL argument, or
  NULL if both arguments are NULL.  Ifnull() must have exactly 2 arguments.
  The ifnull() function is equivalent to <a href="lang_corefunc.html#coalesce">coalesce()</a> with two arguments.
</dd>






<a name="instr"></a>
<dt><p><b>instr(<i>X</i>,<i>Y</i>)</b></dt><dd><p>
  The instr(X,Y) function finds the first occurrence of string Y within 
  string X and returns the number of prior characters plus 1, or 0 if
  Y is nowhere found within X.
  Or, if X and Y are both BLOBs, then instr(X,Y) returns one
  more than the number bytes prior to the first occurrence of Y, or 0 if







>
>
>
>
>
>







222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
</dd>
<a name="ifnull"></a>
<dt><p><b>ifnull(<i>X</i>,<i>Y</i>)</b></dt><dd><p>
  The ifnull() function returns a copy of its first non-NULL argument, or
  NULL if both arguments are NULL.  Ifnull() must have exactly 2 arguments.
  The ifnull() function is equivalent to <a href="lang_corefunc.html#coalesce">coalesce()</a> with two arguments.
</dd>
<a name="iif"></a>
<dt><p><b>iif(<i>X</i>,<i>Y</i>,<i>Z</i>)</b></dt><dd><p>
  The iif(X,Y,Z) function returns the value Y if X is true, and Z otherwise.
  The iff(X,Y,Z) function is logically equivalent to and generates the same
  <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".
</dd>
<a name="instr"></a>
<dt><p><b>instr(<i>X</i>,<i>Y</i>)</b></dt><dd><p>
  The instr(X,Y) function finds the first occurrence of string Y within 
  string X and returns the number of prior characters plus 1, or 0 if
  Y is nowhere found within X.
  Or, if X and Y are both BLOBs, then instr(X,Y) returns one
  more than the number bytes prior to the first occurrence of Y, or 0 if
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
  reversed in the like() function relative to the infix <a href="lang_expr.html#like">LIKE</a> operator.
  X is the pattern and Y is the string to match against that pattern.
  Hence, the following expressions are equivalent:
  <blockquote><pre>
     name LIKE '%neon%'
     like('%neon%',name)
  </pre></blockquote>
  The <a href="c3ref/create_function.html">sqlite3_create_function()</a> interface can be used to override the
  like() function and thereby change the operation of the
  <a href="lang_expr.html#like">LIKE</a> operator.  When overriding the like() function, it may be important
  to override both the two and three argument versions of the like() 
  function. Otherwise, different code may be called to implement the
  <a href="lang_expr.html#like">LIKE</a> operator depending on whether or not an ESCAPE clause was 
  specified.
</dd>







|







273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
  reversed in the like() function relative to the infix <a href="lang_expr.html#like">LIKE</a> operator.
  X is the pattern and Y is the string to match against that pattern.
  Hence, the following expressions are equivalent:
  <blockquote><pre>
     name LIKE '%neon%'
     like('%neon%',name)
  </pre></blockquote>
  <p>The <a href="c3ref/create_function.html">sqlite3_create_function()</a> interface can be used to override the
  like() function and thereby change the operation of the
  <a href="lang_expr.html#like">LIKE</a> operator.  When overriding the like() function, it may be important
  to override both the two and three argument versions of the like() 
  function. Otherwise, different code may be called to implement the
  <a href="lang_expr.html#like">LIKE</a> operator depending on whether or not an ESCAPE clause was 
  specified.
</dd>
567
568
569
570
571
572
573

574
575
  The zeroblob(N) function returns a BLOB consisting of N bytes of 0x00.
  SQLite manages these zeroblobs very efficiently.  Zeroblobs can be used to
  reserve space for a BLOB that is later written using 
  <a href="c3ref/blob_open.html">incremental BLOB I/O</a>.
  This SQL function is implemented using the <a href="c3ref/result_blob.html">sqlite3_result_zeroblob()</a>
  routine from the C/C++ interface.
</dd>

</dl>








>


556
557
558
559
560
561
562
563
564
565
  The zeroblob(N) function returns a BLOB consisting of N bytes of 0x00.
  SQLite manages these zeroblobs very efficiently.  Zeroblobs can be used to
  reserve space for a BLOB that is later written using 
  <a href="c3ref/blob_open.html">incremental BLOB I/O</a>.
  This SQL function is implemented using the <a href="c3ref/result_blob.html">sqlite3_result_zeroblob()</a>
  routine from the C/C++ interface.
</dd>

</dl>

Changes to Doc/Extra/Core/lang_createindex.html.
1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>SQLite Query Language: CREATE INDEX</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>





|







1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>CREATE INDEX</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93











94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212









































213


214
215
216
217
218
219
220
221
222
223
224
225
226
227
228


229
230
231
232
233
234


235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>











<div class=nosearch><h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>CREATE INDEX</h2></div><p><b><a href="syntax/create-index-stmt.html">create-index-stmt:</a></b>
<button id='x1301' onclick='hideorshow("x1301","x1302")'>hide</button></p>
 <div id='x1302' class='imgcontainer'>
 <img alt="syntax diagram create-index-stmt" src="images/syntax/create-index-stmt.gif" />
<p><b><a href="syntax/expr.html">expr:</a></b>
<button id='x1303' onclick='hideorshow("x1303","x1304")'>show</button></p>
 <div id='x1304' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntax/filter-clause.html">filter-clause:</a></b>
<button id='x1305' onclick='hideorshow("x1305","x1306")'>show</button></p>
 <div id='x1306' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram filter-clause" src="images/syntax/filter-clause.gif" />
</div>
<p><b><a href="syntax/literal-value.html">literal-value:</a></b>
<button id='x1307' onclick='hideorshow("x1307","x1308")'>show</button></p>
 <div id='x1308' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</div>
<p><b><a href="syntax/over-clause.html">over-clause:</a></b>
<button id='x1309' onclick='hideorshow("x1309","x1310")'>show</button></p>
 <div id='x1310' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram over-clause" src="images/syntax/over-clause.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x1311' onclick='hideorshow("x1311","x1312")'>show</button></p>
 <div id='x1312' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
<button id='x1313' onclick='hideorshow("x1313","x1314")'>show</button></p>
 <div id='x1314' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</div>
</div>
<p><b><a href="syntax/raise-function.html">raise-function:</a></b>
<button id='x1315' onclick='hideorshow("x1315","x1316")'>show</button></p>
 <div id='x1316' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</div>
<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
<button id='x1317' onclick='hideorshow("x1317","x1318")'>show</button></p>
 <div id='x1318' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntax/common-table-expression.html">common-table-expression:</a></b>
<button id='x1319' onclick='hideorshow("x1319","x1320")'>show</button></p>
 <div id='x1320' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
</div>
<p><b><a href="syntax/compound-operator.html">compound-operator:</a></b>
<button id='x1321' onclick='hideorshow("x1321","x1322")'>show</button></p>
 <div id='x1322' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</div>
<p><b><a href="syntax/join-clause.html">join-clause:</a></b>
<button id='x1323' onclick='hideorshow("x1323","x1324")'>show</button></p>
 <div id='x1324' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
<button id='x1325' onclick='hideorshow("x1325","x1326")'>show</button></p>
 <div id='x1326' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</div>
<p><b><a href="syntax/join-operator.html">join-operator:</a></b>
<button id='x1327' onclick='hideorshow("x1327","x1328")'>show</button></p>
 <div id='x1328' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</div>
</div>
<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
<button id='x1329' onclick='hideorshow("x1329","x1330")'>show</button></p>
 <div id='x1330' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</div>
<p><b><a href="syntax/result-column.html">result-column:</a></b>
<button id='x1331' onclick='hideorshow("x1331","x1332")'>show</button></p>
 <div id='x1332' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</div>
<p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
<button id='x1333' onclick='hideorshow("x1333","x1334")'>show</button></p>
 <div id='x1334' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</div>
<p><b><a href="syntax/window-defn.html">window-defn:</a></b>
<button id='x1335' onclick='hideorshow("x1335","x1336")'>show</button></p>
 <div id='x1336' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram window-defn" src="images/syntax/window-defn.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x1337' onclick='hideorshow("x1337","x1338")'>show</button></p>
 <div id='x1338' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
</div>
</div>
<p><b><a href="syntax/type-name.html">type-name:</a></b>
<button id='x1339' onclick='hideorshow("x1339","x1340")'>show</button></p>
 <div id='x1340' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
<button id='x1341' onclick='hideorshow("x1341","x1342")'>show</button></p>
 <div id='x1342' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</div>
</div>
</div>
<p><b><a href="syntax/indexed-column.html">indexed-column:</a></b>
<button id='x1343' onclick='hideorshow("x1343","x1344")'>show</button></p>
 <div id='x1344' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram indexed-column" src="images/syntax/indexed-column.gif" />
</div>
</div>


<p>The CREATE INDEX command consists of the keywords "CREATE INDEX" followed
by the name of the new index, the keyword "ON", the name of a previously
created table that is to be indexed, and a parenthesized list of table column
names and/or expressions that are used for the index key.
If the optional WHERE clause is included, then the index is a "<a href="partialindex.html">partial index</a>".
</p>










































<a name="descidx"></a>



<p>Each column name or expression can be followed by one
of the "ASC" or "DESC" keywords to indicate sort order.
The sort order may or may not be ignored depending
on the database file format, and in particular the <a href="fileformat2.html#schemaformat">schema format number</a>.
The "legacy" schema format (1) ignores index
sort order.  The descending index schema format (4) takes index sort order
into account.  Only versions of SQLite 3.3.0 (2006-01-11)
and later are able to understand
the descending index format. For compatibility, version of SQLite between 3.3.0
and 3.7.9 use the legacy schema format by default.  The newer schema format is
used by default in version 3.7.10 (2012-01-16) and later.
The <a href="pragma.html#pragma_legacy_file_format">legacy_file_format pragma</a> can be used to change set the specific
behavior for any version of SQLite.</p>



<p>The NULLS FIRST and NULLS LAST predicates are not supported
for indexes.  For <a href="datatype3.html#sortorder">sorting purposes</a>, SQLite considers NULL values 
to be smaller than all other values.  Hence NULL values always appear at
the beginning of an ASC index and at the end of a DESC index.</p>

<a name="collidx"></a>



<p>The COLLATE clause optionally following each column name
or expression defines a
collating sequence used for text entries in that column.
The default collating
sequence is the collating sequence defined for that column in the
<a href="lang_createtable.html">CREATE TABLE</a> statement.  Or if no collating sequence is otherwise defined,
the built-in BINARY collating sequence is used.</p>

<a name="indexexpr"></a>

<p>Expressions in an index may not reference other tables
and may not use subqueries nor functions whose result might
change (ex: <a href="lang_corefunc.html#random">random()</a> or <a href="lang_corefunc.html#sqlite_version">sqlite_version()</a>).
Expressions in an index may only refer to columns in the table
that is being indexed.
Indexes on expression will not work with versions of SQLite prior
to <a href="releaselog/3_9_0.html">version 3.9.0</a> (2015-10-14).
See the <a href="expridx.html">Indexes On Expressions</a> document for additional information
about using general expressions in CREATE INDEX statements.

<p>There are no arbitrary limits on the number of indices that can be
attached to a single table.  The number of columns in an index is 
limited to the value set by
<a href="c3ref/limit.html">sqlite3_limit</a>(<a href="c3ref/c_limit_attached.html#sqlitelimitcolumn">SQLITE_LIMIT_COLUMN</a>,...).</p>

<a name="uniqueidx"></a>

<p>If the UNIQUE keyword appears between CREATE and INDEX then duplicate
index entries are not allowed.  Any attempt to insert a duplicate entry
will result in an error.  For the purposes of unique indices, all NULL values
are considered different from all other NULL values and are thus unique.
This is one of the two possible interpretations of the SQL-92 standard
(the language in the standard is ambiguous) and is the interpretation
followed by PostgreSQL, MySQL, Firebird, and Oracle.  Informix and
Microsoft SQL Server follow the other interpretation of the standard.</p>

<p>If the optional IF NOT EXISTS clause is present and another index
with the same name already exists, then this command becomes a no-op.</p>

<p>Indexes are removed with the <a href="lang_dropindex.html">DROP INDEX</a> command.</p>










|

















>
>
>
>
>
>
>
>
>
>
>
|
|
|


|
|


|
|



|
|



|
|


|
|



|
|




|
|



|
|


|
|



|
|



|
|


|
|



|
|




|
|



|
|



|
|



|
|


|
|





|
|


|
|





|
|












>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

>
>















>
>






>
>









<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301



































}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<div class=fancy>
<div class=nosearch>
<div class="fancy_title">
CREATE INDEX
</div>
</div>




<h1 id="syntax"><span>1. </span>Syntax</h1>
<p><b><a href="syntax/create-index-stmt.html">create-index-stmt:</a></b>
<button id='x1333' onclick='hideorshow("x1333","x1334")'>hide</button></p>
 <div id='x1334' class='imgcontainer'>
 <img alt="syntax diagram create-index-stmt" src="images/syntax/create-index-stmt.gif" />
<p><b><a href="syntax/expr.html">expr:</a></b>
<button id='x1335' onclick='hideorshow("x1335","x1336")'>show</button></p>
 <div id='x1336' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntax/filter-clause.html">filter-clause:</a></b>
<button id='x1337' onclick='hideorshow("x1337","x1338")'>show</button></p>
 <div id='x1338' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram filter-clause" src="images/syntax/filter-clause.gif" />
</div>
<p><b><a href="syntax/literal-value.html">literal-value:</a></b>
<button id='x1339' onclick='hideorshow("x1339","x1340")'>show</button></p>
 <div id='x1340' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</div>
<p><b><a href="syntax/over-clause.html">over-clause:</a></b>
<button id='x1341' onclick='hideorshow("x1341","x1342")'>show</button></p>
 <div id='x1342' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram over-clause" src="images/syntax/over-clause.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x1343' onclick='hideorshow("x1343","x1344")'>show</button></p>
 <div id='x1344' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
<button id='x1345' onclick='hideorshow("x1345","x1346")'>show</button></p>
 <div id='x1346' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</div>
</div>
<p><b><a href="syntax/raise-function.html">raise-function:</a></b>
<button id='x1347' onclick='hideorshow("x1347","x1348")'>show</button></p>
 <div id='x1348' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</div>
<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
<button id='x1349' onclick='hideorshow("x1349","x1350")'>show</button></p>
 <div id='x1350' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntax/common-table-expression.html">common-table-expression:</a></b>
<button id='x1351' onclick='hideorshow("x1351","x1352")'>show</button></p>
 <div id='x1352' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
</div>
<p><b><a href="syntax/compound-operator.html">compound-operator:</a></b>
<button id='x1353' onclick='hideorshow("x1353","x1354")'>show</button></p>
 <div id='x1354' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</div>
<p><b><a href="syntax/join-clause.html">join-clause:</a></b>
<button id='x1355' onclick='hideorshow("x1355","x1356")'>show</button></p>
 <div id='x1356' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
<button id='x1357' onclick='hideorshow("x1357","x1358")'>show</button></p>
 <div id='x1358' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</div>
<p><b><a href="syntax/join-operator.html">join-operator:</a></b>
<button id='x1359' onclick='hideorshow("x1359","x1360")'>show</button></p>
 <div id='x1360' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</div>
</div>
<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
<button id='x1361' onclick='hideorshow("x1361","x1362")'>show</button></p>
 <div id='x1362' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</div>
<p><b><a href="syntax/result-column.html">result-column:</a></b>
<button id='x1363' onclick='hideorshow("x1363","x1364")'>show</button></p>
 <div id='x1364' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</div>
<p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
<button id='x1365' onclick='hideorshow("x1365","x1366")'>show</button></p>
 <div id='x1366' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</div>
<p><b><a href="syntax/window-defn.html">window-defn:</a></b>
<button id='x1367' onclick='hideorshow("x1367","x1368")'>show</button></p>
 <div id='x1368' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram window-defn" src="images/syntax/window-defn.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x1369' onclick='hideorshow("x1369","x1370")'>show</button></p>
 <div id='x1370' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
</div>
</div>
<p><b><a href="syntax/type-name.html">type-name:</a></b>
<button id='x1371' onclick='hideorshow("x1371","x1372")'>show</button></p>
 <div id='x1372' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
<button id='x1373' onclick='hideorshow("x1373","x1374")'>show</button></p>
 <div id='x1374' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</div>
</div>
</div>
<p><b><a href="syntax/indexed-column.html">indexed-column:</a></b>
<button id='x1375' onclick='hideorshow("x1375","x1376")'>show</button></p>
 <div id='x1376' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram indexed-column" src="images/syntax/indexed-column.gif" />
</div>
</div>


<p>The CREATE INDEX command consists of the keywords "CREATE INDEX" followed
by the name of the new index, the keyword "ON", the name of a previously
created table that is to be indexed, and a parenthesized list of table column
names and/or expressions that are used for the index key.
If the optional WHERE clause is included, then the index is a "<a href="partialindex.html">partial index</a>".
</p>

<p>If the optional IF NOT EXISTS clause is present and another index
with the same name already exists, then this command becomes a no-op.</p>

<p>There are no arbitrary limits on the number of indices that can be
attached to a single table.  The number of columns in an index is 
limited to the value set by
<a href="c3ref/limit.html">sqlite3_limit</a>(<a href="c3ref/c_limit_attached.html#sqlitelimitcolumn">SQLITE_LIMIT_COLUMN</a>,...).</p>

<p>Indexes are removed with the <a href="lang_dropindex.html">DROP INDEX</a> command.</p>

<a name="uniqueidx"></a>

<h2 id="unique_indexes"><span>1.1. </span>Unique Indexes</h2>

<p>If the UNIQUE keyword appears between CREATE and INDEX then duplicate
index entries are not allowed.  Any attempt to insert a duplicate entry
will result in an error.</p>

<p>For the purposes of unique indices, all NULL values
are considered different from all other NULL values and are thus unique.
This is one of the two possible interpretations of the SQL-92 standard
(the language in the standard is ambiguous).  The interpretation used
by SQLite is the same and is the interpretation
followed by PostgreSQL, MySQL, Firebird, and Oracle.  Informix and
Microsoft SQL Server follow the other interpretation of the standard, which
is that all NULL values are equal to one another.</p>

<a name="indexexpr"></a>

<h2 id="indexes_on_expressions"><span>1.2. </span>Indexes on Expressions</h2>

<p>Expressions in an index may not reference other tables
and may not use subqueries nor functions whose result might
change (ex: <a href="lang_corefunc.html#random">random()</a> or <a href="lang_corefunc.html#sqlite_version">sqlite_version()</a>).
Expressions in an index may only refer to columns in the table
that is being indexed.
Indexes on expression will not work with versions of SQLite prior
to <a href="releaselog/3_9_0.html">version 3.9.0</a> (2015-10-14).
See the <a href="expridx.html">Indexes On Expressions</a> document for additional information
about using general expressions in CREATE INDEX statements.

<a name="descidx"></a>

</p><h2 id="descending_indexes"><span>1.3. </span>Descending Indexes</h2>

<p>Each column name or expression can be followed by one
of the "ASC" or "DESC" keywords to indicate sort order.
The sort order may or may not be ignored depending
on the database file format, and in particular the <a href="fileformat2.html#schemaformat">schema format number</a>.
The "legacy" schema format (1) ignores index
sort order.  The descending index schema format (4) takes index sort order
into account.  Only versions of SQLite 3.3.0 (2006-01-11)
and later are able to understand
the descending index format. For compatibility, version of SQLite between 3.3.0
and 3.7.9 use the legacy schema format by default.  The newer schema format is
used by default in version 3.7.10 (2012-01-16) and later.
The <a href="pragma.html#pragma_legacy_file_format">legacy_file_format pragma</a> can be used to change set the specific
behavior for any version of SQLite.</p>

<h2 id="nulls_first_and_nulls_last"><span>1.4. </span>NULLS FIRST and NULLS LAST</h2>

<p>The NULLS FIRST and NULLS LAST predicates are not supported
for indexes.  For <a href="datatype3.html#sortorder">sorting purposes</a>, SQLite considers NULL values 
to be smaller than all other values.  Hence NULL values always appear at
the beginning of an ASC index and at the end of a DESC index.</p>

<a name="collidx"></a>

<h2 id="collations"><span>1.5. </span>Collations</h2>

<p>The COLLATE clause optionally following each column name
or expression defines a
collating sequence used for text entries in that column.
The default collating
sequence is the collating sequence defined for that column in the
<a href="lang_createtable.html">CREATE TABLE</a> statement.  Or if no collating sequence is otherwise defined,
the built-in BINARY collating sequence is used.</p>




































Changes to Doc/Extra/Core/lang_createtable.html.
1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>SQLite Query Language: CREATE TABLE</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>





|







1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>CREATE TABLE</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93














































94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330


331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>














































<div class=nosearch><h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>CREATE TABLE</h2></div><p><b><a href="syntax/create-table-stmt.html">create-table-stmt:</a></b>
<button id='x1345' onclick='hideorshow("x1345","x1346")'>hide</button></p>
 <div id='x1346' class='imgcontainer'>
 <img alt="syntax diagram create-table-stmt" src="images/syntax/create-table-stmt.gif" />
<p><b><a href="syntax/column-def.html">column-def:</a></b>
<button id='x1347' onclick='hideorshow("x1347","x1348")'>show</button></p>
 <div id='x1348' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram column-def" src="images/syntax/column-def.gif" />
<p><b><a href="syntax/column-constraint.html">column-constraint:</a></b>
<button id='x1349' onclick='hideorshow("x1349","x1350")'>show</button></p>
 <div id='x1350' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram column-constraint" src="images/syntax/column-constraint.gif" />
<p><b><a href="syntax/conflict-clause.html">conflict-clause:</a></b>
<button id='x1351' onclick='hideorshow("x1351","x1352")'>show</button></p>
 <div id='x1352' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram conflict-clause" src="images/syntax/conflict-clause.gif" />
</div>
<p><b><a href="syntax/expr.html">expr:</a></b>
<button id='x1353' onclick='hideorshow("x1353","x1354")'>show</button></p>
 <div id='x1354' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntax/filter-clause.html">filter-clause:</a></b>
<button id='x1355' onclick='hideorshow("x1355","x1356")'>show</button></p>
 <div id='x1356' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram filter-clause" src="images/syntax/filter-clause.gif" />
</div>
<p><b><a href="syntax/over-clause.html">over-clause:</a></b>
<button id='x1357' onclick='hideorshow("x1357","x1358")'>show</button></p>
 <div id='x1358' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram over-clause" src="images/syntax/over-clause.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x1359' onclick='hideorshow("x1359","x1360")'>show</button></p>
 <div id='x1360' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
<button id='x1361' onclick='hideorshow("x1361","x1362")'>show</button></p>
 <div id='x1362' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</div>
</div>
<p><b><a href="syntax/raise-function.html">raise-function:</a></b>
<button id='x1363' onclick='hideorshow("x1363","x1364")'>show</button></p>
 <div id='x1364' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</div>
</div>
<p><b><a href="syntax/foreign-key-clause.html">foreign-key-clause:</a></b>
<button id='x1365' onclick='hideorshow("x1365","x1366")'>show</button></p>
 <div id='x1366' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram foreign-key-clause" src="images/syntax/foreign-key-clause.gif" />
</div>
<p><b><a href="syntax/literal-value.html">literal-value:</a></b>
<button id='x1367' onclick='hideorshow("x1367","x1368")'>show</button></p>
 <div id='x1368' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</div>
<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
<button id='x1369' onclick='hideorshow("x1369","x1370")'>show</button></p>
 <div id='x1370' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</div>
</div>
<p><b><a href="syntax/type-name.html">type-name:</a></b>
<button id='x1371' onclick='hideorshow("x1371","x1372")'>show</button></p>
 <div id='x1372' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
<button id='x1373' onclick='hideorshow("x1373","x1374")'>show</button></p>
 <div id='x1374' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</div>
</div>
</div>
<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
<button id='x1375' onclick='hideorshow("x1375","x1376")'>show</button></p>
 <div id='x1376' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntax/common-table-expression.html">common-table-expression:</a></b>
<button id='x1377' onclick='hideorshow("x1377","x1378")'>show</button></p>
 <div id='x1378' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
</div>
<p><b><a href="syntax/compound-operator.html">compound-operator:</a></b>
<button id='x1379' onclick='hideorshow("x1379","x1380")'>show</button></p>
 <div id='x1380' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</div>
<p><b><a href="syntax/expr.html">expr:</a></b>
<button id='x1381' onclick='hideorshow("x1381","x1382")'>show</button></p>
 <div id='x1382' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntax/filter-clause.html">filter-clause:</a></b>
<button id='x1383' onclick='hideorshow("x1383","x1384")'>show</button></p>
 <div id='x1384' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram filter-clause" src="images/syntax/filter-clause.gif" />
</div>
<p><b><a href="syntax/literal-value.html">literal-value:</a></b>
<button id='x1385' onclick='hideorshow("x1385","x1386")'>show</button></p>
 <div id='x1386' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</div>
<p><b><a href="syntax/over-clause.html">over-clause:</a></b>
<button id='x1387' onclick='hideorshow("x1387","x1388")'>show</button></p>
 <div id='x1388' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram over-clause" src="images/syntax/over-clause.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x1389' onclick='hideorshow("x1389","x1390")'>show</button></p>
 <div id='x1390' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
</div>
<p><b><a href="syntax/raise-function.html">raise-function:</a></b>
<button id='x1391' onclick='hideorshow("x1391","x1392")'>show</button></p>
 <div id='x1392' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</div>
<p><b><a href="syntax/type-name.html">type-name:</a></b>
<button id='x1393' onclick='hideorshow("x1393","x1394")'>show</button></p>
 <div id='x1394' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
<button id='x1395' onclick='hideorshow("x1395","x1396")'>show</button></p>
 <div id='x1396' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</div>
</div>
</div>
<p><b><a href="syntax/join-clause.html">join-clause:</a></b>
<button id='x1397' onclick='hideorshow("x1397","x1398")'>show</button></p>
 <div id='x1398' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
<button id='x1399' onclick='hideorshow("x1399","x1400")'>show</button></p>
 <div id='x1400' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</div>
<p><b><a href="syntax/join-operator.html">join-operator:</a></b>
<button id='x1401' onclick='hideorshow("x1401","x1402")'>show</button></p>
 <div id='x1402' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</div>
</div>
<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
<button id='x1403' onclick='hideorshow("x1403","x1404")'>show</button></p>
 <div id='x1404' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</div>
<p><b><a href="syntax/result-column.html">result-column:</a></b>
<button id='x1405' onclick='hideorshow("x1405","x1406")'>show</button></p>
 <div id='x1406' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</div>
<p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
<button id='x1407' onclick='hideorshow("x1407","x1408")'>show</button></p>
 <div id='x1408' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</div>
<p><b><a href="syntax/window-defn.html">window-defn:</a></b>
<button id='x1409' onclick='hideorshow("x1409","x1410")'>show</button></p>
 <div id='x1410' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram window-defn" src="images/syntax/window-defn.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x1411' onclick='hideorshow("x1411","x1412")'>show</button></p>
 <div id='x1412' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
</div>
</div>
<p><b><a href="syntax/table-constraint.html">table-constraint:</a></b>
<button id='x1413' onclick='hideorshow("x1413","x1414")'>show</button></p>
 <div id='x1414' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram table-constraint" src="images/syntax/table-constraint.gif" />
<p><b><a href="syntax/conflict-clause.html">conflict-clause:</a></b>
<button id='x1415' onclick='hideorshow("x1415","x1416")'>show</button></p>
 <div id='x1416' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram conflict-clause" src="images/syntax/conflict-clause.gif" />
</div>
<p><b><a href="syntax/expr.html">expr:</a></b>
<button id='x1417' onclick='hideorshow("x1417","x1418")'>show</button></p>
 <div id='x1418' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntax/filter-clause.html">filter-clause:</a></b>
<button id='x1419' onclick='hideorshow("x1419","x1420")'>show</button></p>
 <div id='x1420' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram filter-clause" src="images/syntax/filter-clause.gif" />
</div>
<p><b><a href="syntax/literal-value.html">literal-value:</a></b>
<button id='x1421' onclick='hideorshow("x1421","x1422")'>show</button></p>
 <div id='x1422' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</div>
<p><b><a href="syntax/over-clause.html">over-clause:</a></b>
<button id='x1423' onclick='hideorshow("x1423","x1424")'>show</button></p>
 <div id='x1424' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram over-clause" src="images/syntax/over-clause.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x1425' onclick='hideorshow("x1425","x1426")'>show</button></p>
 <div id='x1426' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
<button id='x1427' onclick='hideorshow("x1427","x1428")'>show</button></p>
 <div id='x1428' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</div>
</div>
<p><b><a href="syntax/raise-function.html">raise-function:</a></b>
<button id='x1429' onclick='hideorshow("x1429","x1430")'>show</button></p>
 <div id='x1430' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</div>
<p><b><a href="syntax/type-name.html">type-name:</a></b>
<button id='x1431' onclick='hideorshow("x1431","x1432")'>show</button></p>
 <div id='x1432' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
<button id='x1433' onclick='hideorshow("x1433","x1434")'>show</button></p>
 <div id='x1434' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</div>
</div>
</div>
<p><b><a href="syntax/foreign-key-clause.html">foreign-key-clause:</a></b>
<button id='x1435' onclick='hideorshow("x1435","x1436")'>show</button></p>
 <div id='x1436' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram foreign-key-clause" src="images/syntax/foreign-key-clause.gif" />
</div>
<p><b><a href="syntax/indexed-column.html">indexed-column:</a></b>
<button id='x1437' onclick='hideorshow("x1437","x1438")'>show</button></p>
 <div id='x1438' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram indexed-column" src="images/syntax/indexed-column.gif" />
</div>
</div>
</div>




<p>The "CREATE TABLE" command is used to create a new table in an SQLite 
database. A CREATE TABLE command specifies the following attributes of the
new table:

<ul>
  <li><p>The name of the new table.

  <li><p> The database in which the new table is created. Tables may be 
      created in the main database, the temp database, or in any attached
      database.

  <li><p> The name of each column in the table.

  <li><p> The declared type of each column in the table.

  <li><p> A default value or expression for each column in the table.

  <li><p> A default collation sequence to use with each column.

  <li><p> Optionally, a PRIMARY KEY for the table. Both single column and
       composite (multiple column) primary keys are supported.

  <li><p> A set of SQL constraints for each table. SQLite supports UNIQUE, NOT
       NULL, CHECK and FOREIGN KEY constraints.

  <li><p> Optionally, a <a href="gencol.html">generated column</a> constraint.

  <li><p> Whether the table is a <a href="withoutrowid.html">WITHOUT ROWID</a> table.
</ul>

<p>Every CREATE TABLE statement must specify a name for the new table.
  Table names that begin with "sqlite_" are reserved for internal use. It
  is an error to attempt to create a table with a name that starts with
  "sqlite_".

<p> If a <span class='yyterm'>schema-name</span> is specified, it must be either "main", 
  "temp", or the name of an <a href="lang_attach.html">attached database</a>. In this case
  the new table is created in the named database. If the "TEMP" or "TEMPORARY"
  keyword occurs between the "CREATE" and "TABLE" then the new table is
  created in the temp database. It is an error to specify both a 
  <span class='yyterm'>schema-name</span> and the TEMP or TEMPORARY keyword, unless the
  <span class='yyterm'>schema-name</span> is "temp". 
  If no schema name is specified and the
  TEMP keyword is not present then the table is created in the main
  database.

<p>
  It is usually an error to attempt to create a new table in a database that
  already contains a table, index or view of the same name. However, if the
  "IF NOT EXISTS" clause is specified as part of the CREATE TABLE statement and
  a table or view of the same name already exists, the CREATE TABLE command
  simply has no effect (and no error message is returned). An error is still
  returned if the table cannot be created because of an existing index, even 
  if the "IF NOT EXISTS" clause is specified.

<p>It is not an error to create a table that has the same name as an 
  existing <a href="lang_createtrigger.html">trigger</a>.

<p>Tables are removed using the <a href="lang_droptable.html">DROP TABLE</a> statement.  </p>

<a name="createtabas"></a>

<h3>CREATE TABLE ... AS SELECT Statements</h3>

<p>A "CREATE TABLE ... AS SELECT" statement creates and populates a database
table based on the results of a SELECT statement. The table has the same
number of columns as the rows returned by the SELECT statement. The name of
each column is the same as the name of the corresponding column in the result
set of the SELECT statement. The declared type of each column is determined
by the <a href="datatype3.html#expraff">expression affinity</a> of the corresponding expression in the result set
of the SELECT statement, as follows:
</p>

<center><table border=1>
  <tr><th>Expression Affinity   <th>Column Declared Type
  <tr><td>TEXT                  <td>"TEXT"
  <tr><td>NUMERIC               <td>"NUM"
  <tr><td>INTEGER               <td>"INT"
  <tr><td>REAL                  <td>"REAL"
  <tr><td>BLOB (a.k.a "NONE")   <td>"" (empty string)
</table></center>

<p>A table created using CREATE TABLE AS has no PRIMARY KEY and no
constraints of any kind. The default value of each column is NULL. The default
collation sequence for each column of the new table is BINARY.

<p>Tables created using CREATE TABLE AS are initially populated with the
rows of data returned by the SELECT statement. Rows are assigned contiguously
ascending <a href="lang_createtable.html#rowid">rowid</a> values, starting with 1, in the <a href="lang_select.html#orderby">order</a> that they
are returned by the SELECT statement.

<a name="tablecoldef"></a>

<h3>Column Definitions</h3>

<p>Unless it is a CREATE TABLE ... AS SELECT statement, a CREATE TABLE includes
one or more <a href="syntax/column-def.html">column definitions</a>, optionally followed by a list of
<a href="syntax/table-constraint.html">table constraints</a>.  Each column definition consists of the
name of the column, optionally followed by the declared type of the column,
then one or more optional <a href="syntax/column-constraint.html">column constraints</a>. Included in
the definition of "column constraints" for the purposes of the previous
statement are the COLLATE and DEFAULT clauses, even though these are not really
constraints in the sense that they do not restrict the data that the table may
contain. The other constraints - NOT NULL, CHECK, UNIQUE, PRIMARY KEY and
FOREIGN KEY constraints - impose restrictions on the table data.

<p>The number of columns in a table is limited by the <a href="limits.html#max_column">SQLITE_MAX_COLUMN</a>
compile-time parameter. A single row of a table cannot store more than
<a href="limits.html#max_length">SQLITE_MAX_LENGTH</a> bytes of data. Both of these limits can be lowered at
runtime using the <a href="c3ref/limit.html">sqlite3_limit()</a> C/C++ interface.</p>

<h4>Column Data Types</h4>

<p>Unlike most SQL databases, SQLite does not restrict the type of data that
may be inserted into a column based on the columns declared type. Instead,
SQLite uses <a href="datatype3.html">dynamic typing</a>. The declared type of a column is used to
determine the <a href="datatype3.html#affinity">affinity</a> of the column only.

<a name="dfltval"></a>

<h4>The DEFAULT clause</h4>
<p>The DEFAULT clause specifies a default value to use for the column if no
value is explicitly provided by the user when doing an <a href="lang_insert.html">INSERT</a>. If there
is no explicit DEFAULT clause attached to a column definition, then the 
default value of the column is NULL. An explicit DEFAULT clause may specify
that the default value is NULL, a string constant, a blob constant, a
signed-number, or any constant expression enclosed in parentheses. A
default value may also be one of the special case-independent keywords
CURRENT_TIME, CURRENT_DATE or CURRENT_TIMESTAMP. For the purposes of the
DEFAULT clause, an expression is considered constant if it
contains no sub-queries, column or table references, <a href="lang_expr.html#varparam">bound parameters</a>,
or string literals enclosed in double-quotes instead of single-quotes.

<p>Each time a row is inserted into the table by an INSERT statement that 
does not provide explicit values for all table columns the values stored in
the new row are determined by their default values, as follows:

<ul>
  <li><p>If the default value of the column is a constant NULL, text, blob or
    signed-number value, then that value is used directly in the new row.

  <li><p>If the default value of a column is an expression in parentheses, then
    the expression is evaluated once for each row inserted and the results
    used in the new row.

  <li><p>If the default value of a column is CURRENT_TIME, CURRENT_DATE or
    CURRENT_TIMESTAMP, then the value used in the new row is a text
    representation of the current UTC date and/or time. For CURRENT_TIME, the
    format of the value is "HH:MM:SS". For CURRENT_DATE, "YYYY-MM-DD". The
    format for CURRENT_TIMESTAMP is "YYYY-MM-DD HH:MM:SS".
</ul>

<a name="collateclause"></a>

<h4>The COLLATE clause</h4>
<p>The COLLATE clause specifies the name of a <a href="datatype3.html#collation">collating sequence</a> to use as
the default collation sequence for the column. If no COLLATE clause is
specified, the default collation sequence is <a href="datatype3.html#collation">BINARY</a>.

<h4>The GENERATED ALWAYS AS clause</h4>
<p>A column that includes a GENERATED ALWAY AS clause is a <a href="gencol.html">generated column</a>.
Generated columns are supported beginning with SQLite verison 3.31.0 (2020-01-22).
See the <a href="gencol.html">separate documentation</a> for details on the capabilities and
limitations of generated columns.

<a name="primkeyconst"></a>

<h4>The PRIMARY KEY</h4>
<p>Each table in SQLite may have at most one PRIMARY KEY. If the
  keywords PRIMARY KEY are added to a column definition, then the primary key
  for the table consists of that single column. Or, if a PRIMARY KEY clause 
  is specified as a <a href="syntax/table-constraint.html">table-constraint</a>, then the primary key of the table
  consists of the list of columns specified as part of the PRIMARY KEY clause.
  The PRIMARY KEY clause must contain only column names &mdash; the use of 
  expressions in an <a href="syntax/indexed-column.html">indexed-column</a> of a PRIMARY KEY is not supported.
  An error is raised if more than one PRIMARY KEY clause appears in a
  CREATE TABLE statement.  The PRIMARY KEY is optional for ordinary tables
  but is required for <a href="withoutrowid.html">WITHOUT ROWID</a> tables.

<p>If a table has a single column primary key and the declared type of that
  column is "INTEGER" and the table is not a <a href="withoutrowid.html">WITHOUT ROWID</a> table,
  then the column is known as an <a href="lang_createtable.html#rowid">INTEGER PRIMARY KEY</a>.
  See <a href="lang_createtable.html#rowid">below</a> for a description of the special properties and behaviors
  associated with an <a href="lang_createtable.html#rowid">INTEGER PRIMARY KEY</a>.

<p>Each row in a table with a primary key must have a unique combination
  of values in its primary key columns. For the purposes of determining
  the uniqueness of primary key values, NULL values are considered distinct from
  all other values, including other NULLs. If an <a href="lang_insert.html">INSERT</a> or <a href="lang_update.html">UPDATE</a>
  statement attempts to modify the table content so that two or more rows
  have identical primary key values, that is a constraint violation.

<p> According to the SQL standard, PRIMARY KEY should always imply NOT NULL.
  Unfortunately, due to a bug in some early versions, this is not the
  case in SQLite. Unless the column is an <a href="lang_createtable.html#rowid">INTEGER PRIMARY KEY</a> or
  the table is a <a href="withoutrowid.html">WITHOUT ROWID</a> table or the column is declared NOT NULL,
  SQLite allows NULL values in a PRIMARY KEY column.  SQLite could be fixed to
  conform to the standard, but doing so might break legacy applications.
  Hence, it has been decided to merely document the fact that SQLite
  allowing NULLs in most PRIMARY KEY columns.

<a name="uniqueconst"></a>

<h4>UNIQUE constraints</h4>
<p>A UNIQUE constraint is similar to a PRIMARY KEY constraint, except
  that a single table may have any number of UNIQUE constraints. For each
  UNIQUE constraint on the table, each row must contain a unique combination
  of values in the columns identified by the UNIQUE constraint. 
  For the purposes of UNIQUE constraints, NULL values
  are considered distinct from all other values, including other NULLs.
  As with PRIMARY KEYs, a UNIQUE <a href="syntax/table-constraint.html">table-constraint</a> clause must contain
  only column names &mdash; the use of 
  expressions in an <a href="syntax/indexed-column.html">indexed-column</a> of a UNIQUE <a href="syntax/table-constraint.html">table-constraint</a>
  is not supported.
  

<p>In most cases, UNIQUE and PRIMARY KEY
  constraints are implemented by creating a unique index in the database.
  (The exceptions are <a href="lang_createtable.html#rowid">INTEGER PRIMARY KEY</a> and PRIMARY KEYs on 
  <a href="withoutrowid.html">WITHOUT ROWID</a> tables.)
  Hence, the following schemas are logically equivalent:

  <ol>
  <li><p>CREATE TABLE t1(a, b UNIQUE);
  <li><p>CREATE TABLE t1(a, b PRIMARY KEY);
  <li><p>CREATE TABLE t1(a, b);<br>
         CREATE UNIQUE INDEX t1b ON t1(b);
  </ol>

<a name="ckconst"></a>

<h4>CHECK constraints</h4>
<p>A CHECK constraint may be attached to a column definition or
  specified as a table constraint. In practice it makes no difference. Each
  time a new row is inserted into the table or an existing row is updated,
  the expression associated with each CHECK constraint is evaluated and
  cast to a NUMERIC value in the same way as a <a href="lang_expr.html#castexpr">CAST expression</a>. If the 
  result is zero (integer value 0 or real value 0.0), then a constraint
  violation has occurred. If the CHECK expression evaluates to NULL, or
  any other non-zero value, it is not a constraint violation.
  The expression of a CHECK constraint may not contain a subquery.

<a name="notnullconst"></a>

<h4>NOT NULL constraints</h4>
<p>A NOT NULL constraint may only be attached to a column definition,
  not specified as a table constraint.  Not surprisingly, a NOT NULL
  constraint dictates that the associated column may not contain a NULL value.
  Attempting to set the column value to NULL when inserting a new row or
  updating an existing one causes a constraint violation.


<h3>Constraint violations</h3>
<p>Exactly how a constraint violation is dealt with is determined by the
  <a href="lang_conflict.html">constraint conflict resolution algorithm</a>. Each 
  PRIMARY KEY, UNIQUE, NOT NULL and CHECK constraint has a default conflict
  resolution algorithm. PRIMARY KEY, UNIQUE and NOT NULL constraints may be
  explicitly assigned a default conflict resolution algorithm by including
  a <a href="syntax/conflict-clause.html">conflict-clause</a> in their definitions. Or, if a constraint definition
  does not include a <a href="syntax/conflict-clause.html">conflict-clause</a> or it is a CHECK constraint, the default
  conflict resolution algorithm is ABORT. Different constraints within the
  same table may have different default conflict resolution algorithms. See
  the section titled <a href="lang_conflict.html">ON CONFLICT</a> for additional information.

<a name="rowid"></a>

<h3>ROWIDs and the INTEGER PRIMARY KEY</h3>

<p>Except for <a href="withoutrowid.html">WITHOUT ROWID</a> tables, all rows within SQLite tables
have a 64-bit signed integer key that uniquely identifies the row within its table.
This integer is usually
called the "rowid". The rowid value can be accessed using one of the special
case-independent names "rowid", "oid", or "_rowid_" in place of a column name.
If a table contains a user defined column named "rowid", "oid" or "_rowid_",
then that name always refers the explicitly declared column and cannot be used
to retrieve the integer rowid value.

<p>The rowid (and "oid" and "_rowid_") is omitted in <a href="withoutrowid.html">WITHOUT ROWID</a> tables.
WITHOUT ROWID tables are only available in SQLite <a href="releaselog/3_8_2.html">version 3.8.2</a>
(2013-12-06) and later.
A table that lacks the WITHOUT ROWID clause is called a "rowid table".

<p>The data for rowid tables is stored as a B-Tree structure containing
one entry for each table row, using the rowid value as the key. This means that
retrieving or sorting records by rowid is fast. Searching for a record with a
specific rowid, or for all records with rowids within a specified range is
around twice as fast as a similar search made by specifying any other PRIMARY
KEY or indexed value.

<p> With one exception noted below, if a rowid table has a primary key that consists
of a single column and the declared type of that column is "INTEGER" in any mixture of
upper and lower case, then the column becomes an alias for the rowid. Such a
column is usually referred to as an "integer primary key". A PRIMARY KEY column
only becomes an integer primary key if the declared type name is exactly
"INTEGER".  Other integer type names like "INT" or "BIGINT" or "SHORT INTEGER"
or "UNSIGNED INTEGER" causes the primary key column to behave as an ordinary
table column with integer <a href="datatype3.html#affinity">affinity</a> and a unique index, not as an alias for
the rowid.

<p> The exception mentioned above is that if the declaration of a column with
declared type "INTEGER" includes an "PRIMARY KEY DESC" clause, it does not
become an alias for the rowid and is not classified as an integer primary key.
This quirk is not by design. It is due to a bug in early versions of SQLite.
But fixing the bug could result in backwards incompatibilities.
Hence, the original behavior has been retained (and documented) because odd
behavior in a corner case is far better than a compatibility break.  This means
that the following three table declarations all cause the column "x" to be an
alias for the rowid (an integer primary key):

<ul>
<li><tt>CREATE TABLE t(x INTEGER PRIMARY KEY ASC, y, z);</tt>
<li><tt>CREATE TABLE t(x INTEGER, y, z, PRIMARY KEY(x ASC));</tt>
<li><tt>CREATE TABLE t(x INTEGER, y, z, PRIMARY KEY(x DESC));</tt>
</ul>

<p>But the following declaration does not result in "x" being an alias for
the rowid:
<ul>
<li><tt>CREATE TABLE t(x INTEGER PRIMARY KEY DESC, y, z);</tt>
</ul>

<p>Rowid values may be modified using an UPDATE statement in the same
way as any other column value can, either using one of the built-in aliases
("rowid", "oid" or "_rowid_") or by using an alias created by an integer
primary key. Similarly, an INSERT statement may provide a value to use as the
rowid for each row inserted. Unlike normal SQLite columns, an integer primary
key or rowid column must contain integer values. Integer primary key or rowid
columns are not able to hold floating point values, strings, BLOBs, or NULLs.

<p>If an UPDATE statement attempts to set an integer primary key or rowid column
to a NULL or blob value, or to a string or real value that cannot be losslessly
converted to an integer, a "datatype mismatch" error occurs and the statement
is aborted. If an INSERT statement attempts to insert a blob value, or a string
or real value that cannot be losslessly converted to an integer into an
integer primary key or rowid column, a "datatype mismatch" error occurs and the
statement is aborted.

<p>If an INSERT statement attempts to insert a NULL value into a rowid or
integer primary key column, the system chooses an integer value to use as the
rowid automatically. A detailed description of how this is done is provided
<a href="autoinc.html">separately</a>.</p>

<p>The <a href="foreignkeys.html#parentchild">parent key</a> of a <a href="foreignkeys.html">foreign key constraint</a> is not allowed to
use the rowid.  The parent key must used named columns only.</p>









|

















>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
|


|
|


|
|


|
|



|
|


|
|



|
|


|
|



|
|




|
|




|
|



|
|



|
|




|
|


|
|





|
|


|
|



|
|



|
|


|
|



|
|



|
|


|
|




|
|



|
|


|
|





|
|


|
|



|
|




|
|



|
|



|
|



|
|


|
|





|
|


|
|



|
|


|
|



|
|



|
|


|
|



|
|




|
|



|
|


|
|





|
|



|
|






>
>




|


|



|

|

|

|

|


|


|

|
|






|










|








|


|



|










|
|
|
|
|
|
|
|





|






|












|




|








|












|



|



|



|




|



|




|







|











|





|






|










|












|





|

|
|

|



|












|







|













|










|




|






|









|









|

|
|
|



|

|









|







|







<
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723

}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<div class=fancy>
<div class=nosearch>
<div class="fancy_title">
CREATE TABLE
</div>
<div class="fancy_toc">
<a onclick="toggle_toc()">
<span class="fancy_toc_mark" id="toc_mk">&#x25ba;</span>
Table Of Contents
</a>
<div id="toc_sub"><div class="fancy-toc1"><a href="#syntax">1. Syntax</a></div>
<div class="fancy-toc1"><a href="#the_create_table_command">2. The CREATE TABLE command</a></div>
<div class="fancy-toc2"><a href="#create_table_as_select_statements">2.1. CREATE TABLE ... AS SELECT Statements</a></div>
<div class="fancy-toc1"><a href="#column_definitions">3. Column Definitions</a></div>
<div class="fancy-toc2"><a href="#column_data_types">3.1. Column Data Types</a></div>
<div class="fancy-toc2"><a href="#the_default_clause">3.2. The DEFAULT clause</a></div>
<div class="fancy-toc2"><a href="#the_collate_clause">3.3. The COLLATE clause</a></div>
<div class="fancy-toc2"><a href="#the_generated_always_as_clause">3.4. The GENERATED ALWAYS AS clause</a></div>
<div class="fancy-toc2"><a href="#the_primary_key">3.5. The PRIMARY KEY</a></div>
<div class="fancy-toc2"><a href="#unique_constraints">3.6. UNIQUE constraints</a></div>
<div class="fancy-toc2"><a href="#check_constraints">3.7. CHECK constraints</a></div>
<div class="fancy-toc2"><a href="#not_null_constraints">3.8. NOT NULL constraints</a></div>
<div class="fancy-toc1"><a href="#constraint_violations">4. Constraint violations</a></div>
<div class="fancy-toc1"><a href="#rowids_and_the_integer_primary_key">5. ROWIDs and the INTEGER PRIMARY KEY</a></div>
</div>
</div>
<script>
function toggle_toc(){
var sub = document.getElementById("toc_sub")
var mk = document.getElementById("toc_mk")
if( sub.style.display!="block" ){
sub.style.display = "block";
mk.innerHTML = "&#x25bc;";
} else {
sub.style.display = "none";
mk.innerHTML = "&#x25ba;";
}
}
</script>
</div>




<h1 id="syntax"><span>1. </span>Syntax</h1>

<p><b><a href="syntax/create-table-stmt.html">create-table-stmt:</a></b>
<button id='x1377' onclick='hideorshow("x1377","x1378")'>hide</button></p>
 <div id='x1378' class='imgcontainer'>
 <img alt="syntax diagram create-table-stmt" src="images/syntax/create-table-stmt.gif" />
<p><b><a href="syntax/column-def.html">column-def:</a></b>
<button id='x1379' onclick='hideorshow("x1379","x1380")'>show</button></p>
 <div id='x1380' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram column-def" src="images/syntax/column-def.gif" />
<p><b><a href="syntax/column-constraint.html">column-constraint:</a></b>
<button id='x1381' onclick='hideorshow("x1381","x1382")'>show</button></p>
 <div id='x1382' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram column-constraint" src="images/syntax/column-constraint.gif" />
<p><b><a href="syntax/conflict-clause.html">conflict-clause:</a></b>
<button id='x1383' onclick='hideorshow("x1383","x1384")'>show</button></p>
 <div id='x1384' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram conflict-clause" src="images/syntax/conflict-clause.gif" />
</div>
<p><b><a href="syntax/expr.html">expr:</a></b>
<button id='x1385' onclick='hideorshow("x1385","x1386")'>show</button></p>
 <div id='x1386' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntax/filter-clause.html">filter-clause:</a></b>
<button id='x1387' onclick='hideorshow("x1387","x1388")'>show</button></p>
 <div id='x1388' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram filter-clause" src="images/syntax/filter-clause.gif" />
</div>
<p><b><a href="syntax/over-clause.html">over-clause:</a></b>
<button id='x1389' onclick='hideorshow("x1389","x1390")'>show</button></p>
 <div id='x1390' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram over-clause" src="images/syntax/over-clause.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x1391' onclick='hideorshow("x1391","x1392")'>show</button></p>
 <div id='x1392' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
<button id='x1393' onclick='hideorshow("x1393","x1394")'>show</button></p>
 <div id='x1394' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</div>
</div>
<p><b><a href="syntax/raise-function.html">raise-function:</a></b>
<button id='x1395' onclick='hideorshow("x1395","x1396")'>show</button></p>
 <div id='x1396' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</div>
</div>
<p><b><a href="syntax/foreign-key-clause.html">foreign-key-clause:</a></b>
<button id='x1397' onclick='hideorshow("x1397","x1398")'>show</button></p>
 <div id='x1398' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram foreign-key-clause" src="images/syntax/foreign-key-clause.gif" />
</div>
<p><b><a href="syntax/literal-value.html">literal-value:</a></b>
<button id='x1399' onclick='hideorshow("x1399","x1400")'>show</button></p>
 <div id='x1400' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</div>
<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
<button id='x1401' onclick='hideorshow("x1401","x1402")'>show</button></p>
 <div id='x1402' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</div>
</div>
<p><b><a href="syntax/type-name.html">type-name:</a></b>
<button id='x1403' onclick='hideorshow("x1403","x1404")'>show</button></p>
 <div id='x1404' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
<button id='x1405' onclick='hideorshow("x1405","x1406")'>show</button></p>
 <div id='x1406' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</div>
</div>
</div>
<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
<button id='x1407' onclick='hideorshow("x1407","x1408")'>show</button></p>
 <div id='x1408' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntax/common-table-expression.html">common-table-expression:</a></b>
<button id='x1409' onclick='hideorshow("x1409","x1410")'>show</button></p>
 <div id='x1410' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
</div>
<p><b><a href="syntax/compound-operator.html">compound-operator:</a></b>
<button id='x1411' onclick='hideorshow("x1411","x1412")'>show</button></p>
 <div id='x1412' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</div>
<p><b><a href="syntax/expr.html">expr:</a></b>
<button id='x1413' onclick='hideorshow("x1413","x1414")'>show</button></p>
 <div id='x1414' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntax/filter-clause.html">filter-clause:</a></b>
<button id='x1415' onclick='hideorshow("x1415","x1416")'>show</button></p>
 <div id='x1416' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram filter-clause" src="images/syntax/filter-clause.gif" />
</div>
<p><b><a href="syntax/literal-value.html">literal-value:</a></b>
<button id='x1417' onclick='hideorshow("x1417","x1418")'>show</button></p>
 <div id='x1418' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</div>
<p><b><a href="syntax/over-clause.html">over-clause:</a></b>
<button id='x1419' onclick='hideorshow("x1419","x1420")'>show</button></p>
 <div id='x1420' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram over-clause" src="images/syntax/over-clause.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x1421' onclick='hideorshow("x1421","x1422")'>show</button></p>
 <div id='x1422' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
</div>
<p><b><a href="syntax/raise-function.html">raise-function:</a></b>
<button id='x1423' onclick='hideorshow("x1423","x1424")'>show</button></p>
 <div id='x1424' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</div>
<p><b><a href="syntax/type-name.html">type-name:</a></b>
<button id='x1425' onclick='hideorshow("x1425","x1426")'>show</button></p>
 <div id='x1426' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
<button id='x1427' onclick='hideorshow("x1427","x1428")'>show</button></p>
 <div id='x1428' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</div>
</div>
</div>
<p><b><a href="syntax/join-clause.html">join-clause:</a></b>
<button id='x1429' onclick='hideorshow("x1429","x1430")'>show</button></p>
 <div id='x1430' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
<button id='x1431' onclick='hideorshow("x1431","x1432")'>show</button></p>
 <div id='x1432' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</div>
<p><b><a href="syntax/join-operator.html">join-operator:</a></b>
<button id='x1433' onclick='hideorshow("x1433","x1434")'>show</button></p>
 <div id='x1434' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</div>
</div>
<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
<button id='x1435' onclick='hideorshow("x1435","x1436")'>show</button></p>
 <div id='x1436' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</div>
<p><b><a href="syntax/result-column.html">result-column:</a></b>
<button id='x1437' onclick='hideorshow("x1437","x1438")'>show</button></p>
 <div id='x1438' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</div>
<p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
<button id='x1439' onclick='hideorshow("x1439","x1440")'>show</button></p>
 <div id='x1440' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</div>
<p><b><a href="syntax/window-defn.html">window-defn:</a></b>
<button id='x1441' onclick='hideorshow("x1441","x1442")'>show</button></p>
 <div id='x1442' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram window-defn" src="images/syntax/window-defn.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x1443' onclick='hideorshow("x1443","x1444")'>show</button></p>
 <div id='x1444' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
</div>
</div>
<p><b><a href="syntax/table-constraint.html">table-constraint:</a></b>
<button id='x1445' onclick='hideorshow("x1445","x1446")'>show</button></p>
 <div id='x1446' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram table-constraint" src="images/syntax/table-constraint.gif" />
<p><b><a href="syntax/conflict-clause.html">conflict-clause:</a></b>
<button id='x1447' onclick='hideorshow("x1447","x1448")'>show</button></p>
 <div id='x1448' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram conflict-clause" src="images/syntax/conflict-clause.gif" />
</div>
<p><b><a href="syntax/expr.html">expr:</a></b>
<button id='x1449' onclick='hideorshow("x1449","x1450")'>show</button></p>
 <div id='x1450' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntax/filter-clause.html">filter-clause:</a></b>
<button id='x1451' onclick='hideorshow("x1451","x1452")'>show</button></p>
 <div id='x1452' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram filter-clause" src="images/syntax/filter-clause.gif" />
</div>
<p><b><a href="syntax/literal-value.html">literal-value:</a></b>
<button id='x1453' onclick='hideorshow("x1453","x1454")'>show</button></p>
 <div id='x1454' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</div>
<p><b><a href="syntax/over-clause.html">over-clause:</a></b>
<button id='x1455' onclick='hideorshow("x1455","x1456")'>show</button></p>
 <div id='x1456' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram over-clause" src="images/syntax/over-clause.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x1457' onclick='hideorshow("x1457","x1458")'>show</button></p>
 <div id='x1458' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
<button id='x1459' onclick='hideorshow("x1459","x1460")'>show</button></p>
 <div id='x1460' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</div>
</div>
<p><b><a href="syntax/raise-function.html">raise-function:</a></b>
<button id='x1461' onclick='hideorshow("x1461","x1462")'>show</button></p>
 <div id='x1462' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</div>
<p><b><a href="syntax/type-name.html">type-name:</a></b>
<button id='x1463' onclick='hideorshow("x1463","x1464")'>show</button></p>
 <div id='x1464' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
<button id='x1465' onclick='hideorshow("x1465","x1466")'>show</button></p>
 <div id='x1466' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</div>
</div>
</div>
<p><b><a href="syntax/foreign-key-clause.html">foreign-key-clause:</a></b>
<button id='x1467' onclick='hideorshow("x1467","x1468")'>show</button></p>
 <div id='x1468' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram foreign-key-clause" src="images/syntax/foreign-key-clause.gif" />
</div>
<p><b><a href="syntax/indexed-column.html">indexed-column:</a></b>
<button id='x1469' onclick='hideorshow("x1469","x1470")'>show</button></p>
 <div id='x1470' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram indexed-column" src="images/syntax/indexed-column.gif" />
</div>
</div>
</div>


<h1 id="the_create_table_command"><span>2. </span>The CREATE TABLE command</h1>

<p>The "CREATE TABLE" command is used to create a new table in an SQLite 
database. A CREATE TABLE command specifies the following attributes of the
new table:

</p><ul>
  <li><p>The name of the new table.

  </p></li><li><p> The database in which the new table is created. Tables may be 
      created in the main database, the temp database, or in any attached
      database.

  </p></li><li><p> The name of each column in the table.

  </p></li><li><p> The declared type of each column in the table.

  </p></li><li><p> A default value or expression for each column in the table.

  </p></li><li><p> A default collation sequence to use with each column.

  </p></li><li><p> Optionally, a PRIMARY KEY for the table. Both single column and
       composite (multiple column) primary keys are supported.

  </p></li><li><p> A set of SQL constraints for each table. SQLite supports UNIQUE, NOT
       NULL, CHECK and FOREIGN KEY constraints.

  </p></li><li><p> Optionally, a <a href="gencol.html">generated column</a> constraint.

  </p></li><li><p> Whether the table is a <a href="withoutrowid.html">WITHOUT ROWID</a> table.
</p></li></ul>

<p>Every CREATE TABLE statement must specify a name for the new table.
  Table names that begin with "sqlite_" are reserved for internal use. It
  is an error to attempt to create a table with a name that starts with
  "sqlite_".

</p><p> If a <span class='yyterm'>schema-name</span> is specified, it must be either "main", 
  "temp", or the name of an <a href="lang_attach.html">attached database</a>. In this case
  the new table is created in the named database. If the "TEMP" or "TEMPORARY"
  keyword occurs between the "CREATE" and "TABLE" then the new table is
  created in the temp database. It is an error to specify both a 
  <span class='yyterm'>schema-name</span> and the TEMP or TEMPORARY keyword, unless the
  <span class='yyterm'>schema-name</span> is "temp". 
  If no schema name is specified and the
  TEMP keyword is not present then the table is created in the main
  database.

</p><p>
  It is usually an error to attempt to create a new table in a database that
  already contains a table, index or view of the same name. However, if the
  "IF NOT EXISTS" clause is specified as part of the CREATE TABLE statement and
  a table or view of the same name already exists, the CREATE TABLE command
  simply has no effect (and no error message is returned). An error is still
  returned if the table cannot be created because of an existing index, even 
  if the "IF NOT EXISTS" clause is specified.

</p><p>It is not an error to create a table that has the same name as an 
  existing <a href="lang_createtrigger.html">trigger</a>.

</p><p>Tables are removed using the <a href="lang_droptable.html">DROP TABLE</a> statement.  </p>

<a name="createtabas"></a>

<h2 id="create_table_as_select_statements"><span>2.1. </span>CREATE TABLE ... AS SELECT Statements</h2>

<p>A "CREATE TABLE ... AS SELECT" statement creates and populates a database
table based on the results of a SELECT statement. The table has the same
number of columns as the rows returned by the SELECT statement. The name of
each column is the same as the name of the corresponding column in the result
set of the SELECT statement. The declared type of each column is determined
by the <a href="datatype3.html#expraff">expression affinity</a> of the corresponding expression in the result set
of the SELECT statement, as follows:
</p>

<center><table border="1">
  <tr><th>Expression Affinity   </th><th>Column Declared Type
  </th></tr><tr><td>TEXT                  </td><td>"TEXT"
  </td></tr><tr><td>NUMERIC               </td><td>"NUM"
  </td></tr><tr><td>INTEGER               </td><td>"INT"
  </td></tr><tr><td>REAL                  </td><td>"REAL"
  </td></tr><tr><td>BLOB (a.k.a "NONE")   </td><td>"" (empty string)
</td></tr></table></center>

<p>A table created using CREATE TABLE AS has no PRIMARY KEY and no
constraints of any kind. The default value of each column is NULL. The default
collation sequence for each column of the new table is BINARY.

</p><p>Tables created using CREATE TABLE AS are initially populated with the
rows of data returned by the SELECT statement. Rows are assigned contiguously
ascending <a href="lang_createtable.html#rowid">rowid</a> values, starting with 1, in the <a href="lang_select.html#orderby">order</a> that they
are returned by the SELECT statement.

<a name="tablecoldef"></a>

</p><h1 id="column_definitions"><span>3. </span>Column Definitions</h1>

<p>Unless it is a CREATE TABLE ... AS SELECT statement, a CREATE TABLE includes
one or more <a href="syntax/column-def.html">column definitions</a>, optionally followed by a list of
<a href="syntax/table-constraint.html">table constraints</a>.  Each column definition consists of the
name of the column, optionally followed by the declared type of the column,
then one or more optional <a href="syntax/column-constraint.html">column constraints</a>. Included in
the definition of "column constraints" for the purposes of the previous
statement are the COLLATE and DEFAULT clauses, even though these are not really
constraints in the sense that they do not restrict the data that the table may
contain. The other constraints - NOT NULL, CHECK, UNIQUE, PRIMARY KEY and
FOREIGN KEY constraints - impose restrictions on the table data.

</p><p>The number of columns in a table is limited by the <a href="limits.html#max_column">SQLITE_MAX_COLUMN</a>
compile-time parameter. A single row of a table cannot store more than
<a href="limits.html#max_length">SQLITE_MAX_LENGTH</a> bytes of data. Both of these limits can be lowered at
runtime using the <a href="c3ref/limit.html">sqlite3_limit()</a> C/C++ interface.</p>

<h2 id="column_data_types"><span>3.1. </span>Column Data Types</h2>

<p>Unlike most SQL databases, SQLite does not restrict the type of data that
may be inserted into a column based on the columns declared type. Instead,
SQLite uses <a href="datatype3.html">dynamic typing</a>. The declared type of a column is used to
determine the <a href="datatype3.html#affinity">affinity</a> of the column only.

<a name="dfltval"></a>

</p><h2 id="the_default_clause"><span>3.2. </span>The DEFAULT clause</h2>
<p>The DEFAULT clause specifies a default value to use for the column if no
value is explicitly provided by the user when doing an <a href="lang_insert.html">INSERT</a>. If there
is no explicit DEFAULT clause attached to a column definition, then the 
default value of the column is NULL. An explicit DEFAULT clause may specify
that the default value is NULL, a string constant, a blob constant, a
signed-number, or any constant expression enclosed in parentheses. A
default value may also be one of the special case-independent keywords
CURRENT_TIME, CURRENT_DATE or CURRENT_TIMESTAMP. For the purposes of the
DEFAULT clause, an expression is considered constant if it
contains no sub-queries, column or table references, <a href="lang_expr.html#varparam">bound parameters</a>,
or string literals enclosed in double-quotes instead of single-quotes.

</p><p>Each time a row is inserted into the table by an INSERT statement that 
does not provide explicit values for all table columns the values stored in
the new row are determined by their default values, as follows:

</p><ul>
  <li><p>If the default value of the column is a constant NULL, text, blob or
    signed-number value, then that value is used directly in the new row.

  </p></li><li><p>If the default value of a column is an expression in parentheses, then
    the expression is evaluated once for each row inserted and the results
    used in the new row.

  </p></li><li><p>If the default value of a column is CURRENT_TIME, CURRENT_DATE or
    CURRENT_TIMESTAMP, then the value used in the new row is a text
    representation of the current UTC date and/or time. For CURRENT_TIME, the
    format of the value is "HH:MM:SS". For CURRENT_DATE, "YYYY-MM-DD". The
    format for CURRENT_TIMESTAMP is "YYYY-MM-DD HH:MM:SS".
</p></li></ul>

<a name="collateclause"></a>

<h2 id="the_collate_clause"><span>3.3. </span>The COLLATE clause</h2>
<p>The COLLATE clause specifies the name of a <a href="datatype3.html#collation">collating sequence</a> to use as
the default collation sequence for the column. If no COLLATE clause is
specified, the default collation sequence is <a href="datatype3.html#collation">BINARY</a>.

</p><h2 id="the_generated_always_as_clause"><span>3.4. </span>The GENERATED ALWAYS AS clause</h2>
<p>A column that includes a GENERATED ALWAY AS clause is a <a href="gencol.html">generated column</a>.
Generated columns are supported beginning with SQLite verison 3.31.0 (2020-01-22).
See the <a href="gencol.html">separate documentation</a> for details on the capabilities and
limitations of generated columns.

<a name="primkeyconst"></a>

</p><h2 id="the_primary_key"><span>3.5. </span>The PRIMARY KEY</h2>
<p>Each table in SQLite may have at most one PRIMARY KEY. If the
  keywords PRIMARY KEY are added to a column definition, then the primary key
  for the table consists of that single column. Or, if a PRIMARY KEY clause 
  is specified as a <a href="syntax/table-constraint.html">table-constraint</a>, then the primary key of the table
  consists of the list of columns specified as part of the PRIMARY KEY clause.
  The PRIMARY KEY clause must contain only column names &mdash; the use of 
  expressions in an <a href="syntax/indexed-column.html">indexed-column</a> of a PRIMARY KEY is not supported.
  An error is raised if more than one PRIMARY KEY clause appears in a
  CREATE TABLE statement.  The PRIMARY KEY is optional for ordinary tables
  but is required for <a href="withoutrowid.html">WITHOUT ROWID</a> tables.

</p><p>If a table has a single column primary key and the declared type of that
  column is "INTEGER" and the table is not a <a href="withoutrowid.html">WITHOUT ROWID</a> table,
  then the column is known as an <a href="lang_createtable.html#rowid">INTEGER PRIMARY KEY</a>.
  See <a href="lang_createtable.html#rowid">below</a> for a description of the special properties and behaviors
  associated with an <a href="lang_createtable.html#rowid">INTEGER PRIMARY KEY</a>.

</p><p>Each row in a table with a primary key must have a unique combination
  of values in its primary key columns. For the purposes of determining
  the uniqueness of primary key values, NULL values are considered distinct from
  all other values, including other NULLs. If an <a href="lang_insert.html">INSERT</a> or <a href="lang_update.html">UPDATE</a>
  statement attempts to modify the table content so that two or more rows
  have identical primary key values, that is a constraint violation.

</p><p> According to the SQL standard, PRIMARY KEY should always imply NOT NULL.
  Unfortunately, due to a bug in some early versions, this is not the
  case in SQLite. Unless the column is an <a href="lang_createtable.html#rowid">INTEGER PRIMARY KEY</a> or
  the table is a <a href="withoutrowid.html">WITHOUT ROWID</a> table or the column is declared NOT NULL,
  SQLite allows NULL values in a PRIMARY KEY column.  SQLite could be fixed to
  conform to the standard, but doing so might break legacy applications.
  Hence, it has been decided to merely document the fact that SQLite
  allowing NULLs in most PRIMARY KEY columns.

<a name="uniqueconst"></a>

</p><h2 id="unique_constraints"><span>3.6. </span>UNIQUE constraints</h2>
<p>A UNIQUE constraint is similar to a PRIMARY KEY constraint, except
  that a single table may have any number of UNIQUE constraints. For each
  UNIQUE constraint on the table, each row must contain a unique combination
  of values in the columns identified by the UNIQUE constraint. 
  For the purposes of UNIQUE constraints, NULL values
  are considered distinct from all other values, including other NULLs.
  As with PRIMARY KEYs, a UNIQUE <a href="syntax/table-constraint.html">table-constraint</a> clause must contain
  only column names &mdash; the use of 
  expressions in an <a href="syntax/indexed-column.html">indexed-column</a> of a UNIQUE <a href="syntax/table-constraint.html">table-constraint</a>
  is not supported.
  

</p><p>In most cases, UNIQUE and PRIMARY KEY
  constraints are implemented by creating a unique index in the database.
  (The exceptions are <a href="lang_createtable.html#rowid">INTEGER PRIMARY KEY</a> and PRIMARY KEYs on 
  <a href="withoutrowid.html">WITHOUT ROWID</a> tables.)
  Hence, the following schemas are logically equivalent:

  </p><ol>
  <li><p>CREATE TABLE t1(a, b UNIQUE);
  </p></li><li><p>CREATE TABLE t1(a, b PRIMARY KEY);
  </p></li><li><p>CREATE TABLE t1(a, b);<br>
         CREATE UNIQUE INDEX t1b ON t1(b);
  </p></li></ol>

<a name="ckconst"></a>

<h2 id="check_constraints"><span>3.7. </span>CHECK constraints</h2>
<p>A CHECK constraint may be attached to a column definition or
  specified as a table constraint. In practice it makes no difference. Each
  time a new row is inserted into the table or an existing row is updated,
  the expression associated with each CHECK constraint is evaluated and
  cast to a NUMERIC value in the same way as a <a href="lang_expr.html#castexpr">CAST expression</a>. If the 
  result is zero (integer value 0 or real value 0.0), then a constraint
  violation has occurred. If the CHECK expression evaluates to NULL, or
  any other non-zero value, it is not a constraint violation.
  The expression of a CHECK constraint may not contain a subquery.

<a name="notnullconst"></a>

</p><h2 id="not_null_constraints"><span>3.8. </span>NOT NULL constraints</h2>
<p>A NOT NULL constraint may only be attached to a column definition,
  not specified as a table constraint.  Not surprisingly, a NOT NULL
  constraint dictates that the associated column may not contain a NULL value.
  Attempting to set the column value to NULL when inserting a new row or
  updating an existing one causes a constraint violation.


</p><h1 id="constraint_violations"><span>4. </span>Constraint violations</h1>
<p>Exactly how a constraint violation is dealt with is determined by the
  <a href="lang_conflict.html">constraint conflict resolution algorithm</a>. Each 
  PRIMARY KEY, UNIQUE, NOT NULL and CHECK constraint has a default conflict
  resolution algorithm. PRIMARY KEY, UNIQUE and NOT NULL constraints may be
  explicitly assigned a default conflict resolution algorithm by including
  a <a href="syntax/conflict-clause.html">conflict-clause</a> in their definitions. Or, if a constraint definition
  does not include a <a href="syntax/conflict-clause.html">conflict-clause</a> or it is a CHECK constraint, the default
  conflict resolution algorithm is ABORT. Different constraints within the
  same table may have different default conflict resolution algorithms. See
  the section titled <a href="lang_conflict.html">ON CONFLICT</a> for additional information.

<a name="rowid"></a>

</p><h1 id="rowids_and_the_integer_primary_key"><span>5. </span>ROWIDs and the INTEGER PRIMARY KEY</h1>

<p>Except for <a href="withoutrowid.html">WITHOUT ROWID</a> tables, all rows within SQLite tables
have a 64-bit signed integer key that uniquely identifies the row within its table.
This integer is usually
called the "rowid". The rowid value can be accessed using one of the special
case-independent names "rowid", "oid", or "_rowid_" in place of a column name.
If a table contains a user defined column named "rowid", "oid" or "_rowid_",
then that name always refers the explicitly declared column and cannot be used
to retrieve the integer rowid value.

</p><p>The rowid (and "oid" and "_rowid_") is omitted in <a href="withoutrowid.html">WITHOUT ROWID</a> tables.
WITHOUT ROWID tables are only available in SQLite <a href="releaselog/3_8_2.html">version 3.8.2</a>
(2013-12-06) and later.
A table that lacks the WITHOUT ROWID clause is called a "rowid table".

</p><p>The data for rowid tables is stored as a B-Tree structure containing
one entry for each table row, using the rowid value as the key. This means that
retrieving or sorting records by rowid is fast. Searching for a record with a
specific rowid, or for all records with rowids within a specified range is
around twice as fast as a similar search made by specifying any other PRIMARY
KEY or indexed value.

</p><p> With one exception noted below, if a rowid table has a primary key that consists
of a single column and the declared type of that column is "INTEGER" in any mixture of
upper and lower case, then the column becomes an alias for the rowid. Such a
column is usually referred to as an "integer primary key". A PRIMARY KEY column
only becomes an integer primary key if the declared type name is exactly
"INTEGER".  Other integer type names like "INT" or "BIGINT" or "SHORT INTEGER"
or "UNSIGNED INTEGER" causes the primary key column to behave as an ordinary
table column with integer <a href="datatype3.html#affinity">affinity</a> and a unique index, not as an alias for
the rowid.

</p><p> The exception mentioned above is that if the declaration of a column with
declared type "INTEGER" includes an "PRIMARY KEY DESC" clause, it does not
become an alias for the rowid and is not classified as an integer primary key.
This quirk is not by design. It is due to a bug in early versions of SQLite.
But fixing the bug could result in backwards incompatibilities.
Hence, the original behavior has been retained (and documented) because odd
behavior in a corner case is far better than a compatibility break.  This means
that the following three table declarations all cause the column "x" to be an
alias for the rowid (an integer primary key):

</p><ul>
<li><tt>CREATE TABLE t(x INTEGER PRIMARY KEY ASC, y, z);</tt>
</li><li><tt>CREATE TABLE t(x INTEGER, y, z, PRIMARY KEY(x ASC));</tt>
</li><li><tt>CREATE TABLE t(x INTEGER, y, z, PRIMARY KEY(x DESC));</tt>
</li></ul>

<p>But the following declaration does not result in "x" being an alias for
the rowid:
</p><ul>
<li><tt>CREATE TABLE t(x INTEGER PRIMARY KEY DESC, y, z);</tt>
</li></ul>

<p>Rowid values may be modified using an UPDATE statement in the same
way as any other column value can, either using one of the built-in aliases
("rowid", "oid" or "_rowid_") or by using an alias created by an integer
primary key. Similarly, an INSERT statement may provide a value to use as the
rowid for each row inserted. Unlike normal SQLite columns, an integer primary
key or rowid column must contain integer values. Integer primary key or rowid
columns are not able to hold floating point values, strings, BLOBs, or NULLs.

</p><p>If an UPDATE statement attempts to set an integer primary key or rowid column
to a NULL or blob value, or to a string or real value that cannot be losslessly
converted to an integer, a "datatype mismatch" error occurs and the statement
is aborted. If an INSERT statement attempts to insert a blob value, or a string
or real value that cannot be losslessly converted to an integer into an
integer primary key or rowid column, a "datatype mismatch" error occurs and the
statement is aborted.

</p><p>If an INSERT statement attempts to insert a NULL value into a rowid or
integer primary key column, the system chooses an integer value to use as the
rowid automatically. A detailed description of how this is done is provided
<a href="autoinc.html">separately</a>.</p>

<p>The <a href="foreignkeys.html#parentchild">parent key</a> of a <a href="foreignkeys.html">foreign key constraint</a> is not allowed to
use the rowid.  The parent key must used named columns only.</p>


Changes to Doc/Extra/Core/lang_createtrigger.html.
1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>SQLite Query Language: CREATE TRIGGER</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>





|







1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>CREATE TRIGGER</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93









































94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226

227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247




248
249
250
251
252
253
254
255
256
257
258
259
260

261
262
263
264
265
266
267
268
269
270
271
272








273








































































274
275

276
277
278
279
280
281
282
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>









































<div class=nosearch><h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>CREATE TRIGGER</h2></div><p><b><a href="syntax/create-trigger-stmt.html">create-trigger-stmt:</a></b>
<button id='x1439' onclick='hideorshow("x1439","x1440")'>hide</button></p>
 <div id='x1440' class='imgcontainer'>
 <img alt="syntax diagram create-trigger-stmt" src="images/syntax/create-trigger-stmt.gif" />
<p><b><a href="syntax/delete-stmt.html">delete-stmt:</a></b>
<button id='x1441' onclick='hideorshow("x1441","x1442")'>show</button></p>
 <div id='x1442' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram delete-stmt" src="images/syntax/delete-stmt.gif" />
<p><b><a href="syntax/qualified-table-name.html">qualified-table-name:</a></b>
<button id='x1443' onclick='hideorshow("x1443","x1444")'>show</button></p>
 <div id='x1444' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram qualified-table-name" src="images/syntax/qualified-table-name.gif" />
</div>
<p><b><a href="syntax/with-clause.html">with-clause:</a></b>
<button id='x1445' onclick='hideorshow("x1445","x1446")'>show</button></p>
 <div id='x1446' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram with-clause" src="images/syntax/with-clause.gif" />
<p><b><a href="syntax/cte-table-name.html">cte-table-name:</a></b>
<button id='x1447' onclick='hideorshow("x1447","x1448")'>show</button></p>
 <div id='x1448' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram cte-table-name" src="images/syntax/cte-table-name.gif" />
</div>
</div>
</div>
<p><b><a href="syntax/expr.html">expr:</a></b>
<button id='x1449' onclick='hideorshow("x1449","x1450")'>show</button></p>
 <div id='x1450' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntax/filter-clause.html">filter-clause:</a></b>
<button id='x1451' onclick='hideorshow("x1451","x1452")'>show</button></p>
 <div id='x1452' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram filter-clause" src="images/syntax/filter-clause.gif" />
</div>
<p><b><a href="syntax/literal-value.html">literal-value:</a></b>
<button id='x1453' onclick='hideorshow("x1453","x1454")'>show</button></p>
 <div id='x1454' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</div>
<p><b><a href="syntax/over-clause.html">over-clause:</a></b>
<button id='x1455' onclick='hideorshow("x1455","x1456")'>show</button></p>
 <div id='x1456' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram over-clause" src="images/syntax/over-clause.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x1457' onclick='hideorshow("x1457","x1458")'>show</button></p>
 <div id='x1458' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
<button id='x1459' onclick='hideorshow("x1459","x1460")'>show</button></p>
 <div id='x1460' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</div>
</div>
<p><b><a href="syntax/raise-function.html">raise-function:</a></b>
<button id='x1461' onclick='hideorshow("x1461","x1462")'>show</button></p>
 <div id='x1462' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</div>
<p><b><a href="syntax/type-name.html">type-name:</a></b>
<button id='x1463' onclick='hideorshow("x1463","x1464")'>show</button></p>
 <div id='x1464' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
<button id='x1465' onclick='hideorshow("x1465","x1466")'>show</button></p>
 <div id='x1466' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</div>
</div>
</div>
<p><b><a href="syntax/insert-stmt.html">insert-stmt:</a></b>
<button id='x1467' onclick='hideorshow("x1467","x1468")'>show</button></p>
 <div id='x1468' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram insert-stmt" src="images/syntax/insert-stmt.gif" />
<p><b><a href="syntax/upsert-clause.html">upsert-clause:</a></b>
<button id='x1469' onclick='hideorshow("x1469","x1470")'>show</button></p>
 <div id='x1470' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram upsert-clause" src="images/syntax/upsert-clause.gif" />
<p><b><a href="syntax/column-name-list.html">column-name-list:</a></b>
<button id='x1471' onclick='hideorshow("x1471","x1472")'>show</button></p>
 <div id='x1472' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram column-name-list" src="images/syntax/column-name-list.gif" />
</div>
<p><b><a href="syntax/indexed-column.html">indexed-column:</a></b>
<button id='x1473' onclick='hideorshow("x1473","x1474")'>show</button></p>
 <div id='x1474' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram indexed-column" src="images/syntax/indexed-column.gif" />
</div>
</div>
<p><b><a href="syntax/with-clause.html">with-clause:</a></b>
<button id='x1475' onclick='hideorshow("x1475","x1476")'>show</button></p>
 <div id='x1476' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram with-clause" src="images/syntax/with-clause.gif" />
<p><b><a href="syntax/cte-table-name.html">cte-table-name:</a></b>
<button id='x1477' onclick='hideorshow("x1477","x1478")'>show</button></p>
 <div id='x1478' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram cte-table-name" src="images/syntax/cte-table-name.gif" />
</div>
</div>
</div>
<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
<button id='x1479' onclick='hideorshow("x1479","x1480")'>show</button></p>
 <div id='x1480' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntax/common-table-expression.html">common-table-expression:</a></b>
<button id='x1481' onclick='hideorshow("x1481","x1482")'>show</button></p>
 <div id='x1482' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
</div>
<p><b><a href="syntax/compound-operator.html">compound-operator:</a></b>
<button id='x1483' onclick='hideorshow("x1483","x1484")'>show</button></p>
 <div id='x1484' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</div>
<p><b><a href="syntax/join-clause.html">join-clause:</a></b>
<button id='x1485' onclick='hideorshow("x1485","x1486")'>show</button></p>
 <div id='x1486' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
<button id='x1487' onclick='hideorshow("x1487","x1488")'>show</button></p>
 <div id='x1488' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</div>
<p><b><a href="syntax/join-operator.html">join-operator:</a></b>
<button id='x1489' onclick='hideorshow("x1489","x1490")'>show</button></p>
 <div id='x1490' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</div>
</div>
<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
<button id='x1491' onclick='hideorshow("x1491","x1492")'>show</button></p>
 <div id='x1492' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</div>

<p><b><a href="syntax/result-column.html">result-column:</a></b>
<button id='x1493' onclick='hideorshow("x1493","x1494")'>show</button></p>
 <div id='x1494' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</div>
<p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
<button id='x1495' onclick='hideorshow("x1495","x1496")'>show</button></p>
 <div id='x1496' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</div>
<p><b><a href="syntax/window-defn.html">window-defn:</a></b>
<button id='x1497' onclick='hideorshow("x1497","x1498")'>show</button></p>
 <div id='x1498' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram window-defn" src="images/syntax/window-defn.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x1499' onclick='hideorshow("x1499","x1500")'>show</button></p>
 <div id='x1500' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
</div>
</div>




<p><b><a href="syntax/update-stmt.html">update-stmt:</a></b>
<button id='x1501' onclick='hideorshow("x1501","x1502")'>show</button></p>
 <div id='x1502' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram update-stmt" src="images/syntax/update-stmt.gif" />
<p><b><a href="syntax/column-name-list.html">column-name-list:</a></b>
<button id='x1503' onclick='hideorshow("x1503","x1504")'>show</button></p>
 <div id='x1504' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram column-name-list" src="images/syntax/column-name-list.gif" />
</div>
<p><b><a href="syntax/qualified-table-name.html">qualified-table-name:</a></b>
<button id='x1505' onclick='hideorshow("x1505","x1506")'>show</button></p>
 <div id='x1506' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram qualified-table-name" src="images/syntax/qualified-table-name.gif" />

</div>
<p><b><a href="syntax/with-clause.html">with-clause:</a></b>
<button id='x1507' onclick='hideorshow("x1507","x1508")'>show</button></p>
 <div id='x1508' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram with-clause" src="images/syntax/with-clause.gif" />
<p><b><a href="syntax/cte-table-name.html">cte-table-name:</a></b>
<button id='x1509' onclick='hideorshow("x1509","x1510")'>show</button></p>
 <div id='x1510' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram cte-table-name" src="images/syntax/cte-table-name.gif" />
</div>
</div>
</div>








</div>











































































<p>The CREATE TRIGGER statement is used to add triggers to the 
database schema. Triggers are database operations 
that are automatically performed when a specified database event
occurs.  </p>

<p>Each trigger must specify that it will fire for one of
the following operations: <a href="lang_delete.html">DELETE</a>, <a href="lang_insert.html">INSERT</a>, <a href="lang_update.html">UPDATE</a>.







|

















>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
|


|
|


|
|



|
|


|
|





|
|


|
|



|
|



|
|


<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


|
<






>
|


|

|


|
<
|


|
<
<
<
<



>
>
>
>
|


|





|


|
>












>
>
>
>
>
>
>
>

>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>


>







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
















































































178
179
180

181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196

197
198
199
200




201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<div class=fancy>
<div class=nosearch>
<div class="fancy_title">
CREATE TRIGGER
</div>
<div class="fancy_toc">
<a onclick="toggle_toc()">
<span class="fancy_toc_mark" id="toc_mk">&#x25ba;</span>
Table Of Contents
</a>
<div id="toc_sub"><div class="fancy-toc1"><a href="#syntax">1. Syntax</a></div>
<div class="fancy-toc1"><a href="#description">2. Description</a></div>
<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
Triggers</a></div>
<div class="fancy-toc1"><a href="#instead_of_triggers">3. INSTEAD OF triggers</a></div>
<div class="fancy-toc1"><a href="#some_example_triggers">4. Some Example Triggers</a></div>
<div class="fancy-toc1"><a href="#cautions_on_the_use_of_before_triggers">5. Cautions On The Use Of BEFORE triggers</a></div>
<div class="fancy-toc1"><a href="#the_raise_function">6. The RAISE() function</a></div>
<div class="fancy-toc1"><a href="#temp_triggers_on_non_temp_tables">7. TEMP Triggers on Non-TEMP Tables</a></div>
</div>
</div>
<script>
function toggle_toc(){
var sub = document.getElementById("toc_sub")
var mk = document.getElementById("toc_mk")
if( sub.style.display!="block" ){
sub.style.display = "block";
mk.innerHTML = "&#x25bc;";
} else {
sub.style.display = "none";
mk.innerHTML = "&#x25ba;";
}
}
</script>
</div>




<h1 id="syntax"><span>1. </span>Syntax</h1>

<p><b><a href="syntax/create-trigger-stmt.html">create-trigger-stmt:</a></b>
<button id='x1471' onclick='hideorshow("x1471","x1472")'>hide</button></p>
 <div id='x1472' class='imgcontainer'>
 <img alt="syntax diagram create-trigger-stmt" src="images/syntax/create-trigger-stmt.gif" />
<p><b><a href="syntax/delete-stmt.html">delete-stmt:</a></b>
<button id='x1473' onclick='hideorshow("x1473","x1474")'>show</button></p>
 <div id='x1474' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram delete-stmt" src="images/syntax/delete-stmt.gif" />
<p><b><a href="syntax/qualified-table-name.html">qualified-table-name:</a></b>
<button id='x1475' onclick='hideorshow("x1475","x1476")'>show</button></p>
 <div id='x1476' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram qualified-table-name" src="images/syntax/qualified-table-name.gif" />
</div>
<p><b><a href="syntax/with-clause.html">with-clause:</a></b>
<button id='x1477' onclick='hideorshow("x1477","x1478")'>show</button></p>
 <div id='x1478' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram with-clause" src="images/syntax/with-clause.gif" />
<p><b><a href="syntax/cte-table-name.html">cte-table-name:</a></b>
<button id='x1479' onclick='hideorshow("x1479","x1480")'>show</button></p>
 <div id='x1480' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram cte-table-name" src="images/syntax/cte-table-name.gif" />
</div>
</div>
</div>
<p><b><a href="syntax/expr.html">expr:</a></b>
<button id='x1481' onclick='hideorshow("x1481","x1482")'>show</button></p>
 <div id='x1482' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntax/filter-clause.html">filter-clause:</a></b>
<button id='x1483' onclick='hideorshow("x1483","x1484")'>show</button></p>
 <div id='x1484' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram filter-clause" src="images/syntax/filter-clause.gif" />
</div>
<p><b><a href="syntax/literal-value.html">literal-value:</a></b>
<button id='x1485' onclick='hideorshow("x1485","x1486")'>show</button></p>
 <div id='x1486' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</div>
<p><b><a href="syntax/over-clause.html">over-clause:</a></b>
<button id='x1487' onclick='hideorshow("x1487","x1488")'>show</button></p>
 <div id='x1488' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram over-clause" src="images/syntax/over-clause.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
















































































<button id='x1489' onclick='hideorshow("x1489","x1490")'>show</button></p>
 <div id='x1490' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />

</div>
<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
<button id='x1491' onclick='hideorshow("x1491","x1492")'>show</button></p>
 <div id='x1492' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</div>
</div>
<p><b><a href="syntax/raise-function.html">raise-function:</a></b>
<button id='x1493' onclick='hideorshow("x1493","x1494")'>show</button></p>
 <div id='x1494' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</div>
<p><b><a href="syntax/type-name.html">type-name:</a></b>
<button id='x1495' onclick='hideorshow("x1495","x1496")'>show</button></p>
 <div id='x1496' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />

<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
<button id='x1497' onclick='hideorshow("x1497","x1498")'>show</button></p>
 <div id='x1498' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />




</div>
</div>
</div>
<p><b><a href="syntax/insert-stmt.html">insert-stmt:</a></b>
<button id='x1499' onclick='hideorshow("x1499","x1500")'>show</button></p>
 <div id='x1500' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram insert-stmt" src="images/syntax/insert-stmt.gif" />
<p><b><a href="syntax/upsert-clause.html">upsert-clause:</a></b>
<button id='x1501' onclick='hideorshow("x1501","x1502")'>show</button></p>
 <div id='x1502' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram upsert-clause" src="images/syntax/upsert-clause.gif" />
<p><b><a href="syntax/column-name-list.html">column-name-list:</a></b>
<button id='x1503' onclick='hideorshow("x1503","x1504")'>show</button></p>
 <div id='x1504' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram column-name-list" src="images/syntax/column-name-list.gif" />
</div>
<p><b><a href="syntax/indexed-column.html">indexed-column:</a></b>
<button id='x1505' onclick='hideorshow("x1505","x1506")'>show</button></p>
 <div id='x1506' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram indexed-column" src="images/syntax/indexed-column.gif" />
</div>
</div>
<p><b><a href="syntax/with-clause.html">with-clause:</a></b>
<button id='x1507' onclick='hideorshow("x1507","x1508")'>show</button></p>
 <div id='x1508' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram with-clause" src="images/syntax/with-clause.gif" />
<p><b><a href="syntax/cte-table-name.html">cte-table-name:</a></b>
<button id='x1509' onclick='hideorshow("x1509","x1510")'>show</button></p>
 <div id='x1510' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram cte-table-name" src="images/syntax/cte-table-name.gif" />
</div>
</div>
</div>
<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
<button id='x1511' onclick='hideorshow("x1511","x1512")'>show</button></p>
 <div id='x1512' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntax/common-table-expression.html">common-table-expression:</a></b>
<button id='x1513' onclick='hideorshow("x1513","x1514")'>show</button></p>
 <div id='x1514' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
</div>
<p><b><a href="syntax/compound-operator.html">compound-operator:</a></b>
<button id='x1515' onclick='hideorshow("x1515","x1516")'>show</button></p>
 <div id='x1516' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</div>
<p><b><a href="syntax/join-clause.html">join-clause:</a></b>
<button id='x1517' onclick='hideorshow("x1517","x1518")'>show</button></p>
 <div id='x1518' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
<button id='x1519' onclick='hideorshow("x1519","x1520")'>show</button></p>
 <div id='x1520' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</div>
<p><b><a href="syntax/join-operator.html">join-operator:</a></b>
<button id='x1521' onclick='hideorshow("x1521","x1522")'>show</button></p>
 <div id='x1522' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</div>
</div>
<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
<button id='x1523' onclick='hideorshow("x1523","x1524")'>show</button></p>
 <div id='x1524' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</div>
<p><b><a href="syntax/result-column.html">result-column:</a></b>
<button id='x1525' onclick='hideorshow("x1525","x1526")'>show</button></p>
 <div id='x1526' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</div>
<p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
<button id='x1527' onclick='hideorshow("x1527","x1528")'>show</button></p>
 <div id='x1528' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</div>
<p><b><a href="syntax/window-defn.html">window-defn:</a></b>
<button id='x1529' onclick='hideorshow("x1529","x1530")'>show</button></p>
 <div id='x1530' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram window-defn" src="images/syntax/window-defn.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x1531' onclick='hideorshow("x1531","x1532")'>show</button></p>
 <div id='x1532' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
</div>
</div>
<p><b><a href="syntax/update-stmt.html">update-stmt:</a></b>
<button id='x1533' onclick='hideorshow("x1533","x1534")'>show</button></p>
 <div id='x1534' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram update-stmt" src="images/syntax/update-stmt.gif" />
<p><b><a href="syntax/column-name-list.html">column-name-list:</a></b>
<button id='x1535' onclick='hideorshow("x1535","x1536")'>show</button></p>
 <div id='x1536' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram column-name-list" src="images/syntax/column-name-list.gif" />
</div>
<p><b><a href="syntax/qualified-table-name.html">qualified-table-name:</a></b>
<button id='x1537' onclick='hideorshow("x1537","x1538")'>show</button></p>
 <div id='x1538' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram qualified-table-name" src="images/syntax/qualified-table-name.gif" />
</div>
<p><b><a href="syntax/with-clause.html">with-clause:</a></b>
<button id='x1539' onclick='hideorshow("x1539","x1540")'>show</button></p>
 <div id='x1540' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram with-clause" src="images/syntax/with-clause.gif" />
<p><b><a href="syntax/cte-table-name.html">cte-table-name:</a></b>
<button id='x1541' onclick='hideorshow("x1541","x1542")'>show</button></p>
 <div id='x1542' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram cte-table-name" src="images/syntax/cte-table-name.gif" />
</div>
</div>
</div>
</div>


<h1 id="description"><span>2. </span>Description</h1>
<p>The CREATE TRIGGER statement is used to add triggers to the 
database schema. Triggers are database operations 
that are automatically performed when a specified database event
occurs.  </p>

<p>Each trigger must specify that it will fire for one of
the following operations: <a href="lang_delete.html">DELETE</a>, <a href="lang_insert.html">INSERT</a>, <a href="lang_update.html">UPDATE</a>.
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
<p>Both the WHEN clause and the trigger actions may access elements of 
the row being inserted, deleted or updated using references of the form 
"NEW.<i>column-name</i>" and "OLD.<i>column-name</i>", where
<i>column-name</i> is the name of a column from the table that the trigger
is associated with. OLD and NEW references may only be used in triggers on
events for which they are relevant, as follows:</p>

<table border=0 cellpadding=10>
<tr>
<td valign="top" align="right" width=120><i>INSERT</i></td>
<td valign="top">NEW references are valid</td>
</tr>
<tr>
<td valign="top" align="right" width=120><i>UPDATE</i></td>
<td valign="top">NEW and OLD references are valid</td>
</tr>
<tr>
<td valign="top" align="right" width=120><i>DELETE</i></td>
<td valign="top">OLD references are valid</td>
</tr>
</table>
</p>

<p>If a WHEN clause is supplied, the SQL statements specified
are only executed if the WHEN clause is true.
If no WHEN clause is supplied, the SQL statements
are executed every time the trigger fires.</p>

<p>The BEFORE or AFTER keyword determines when the trigger actions
will be executed relative to the insertion, modification or removal of the
associated row.</p>

<p>An <a href="lang_conflict.html">ON CONFLICT</a> clause may be specified as part of an <a href="lang_update.html">UPDATE</a> or <a href="lang_insert.html">INSERT</a>
action within the body of the trigger.
However if an <a href="lang_conflict.html">ON CONFLICT</a> clause is specified as part of 
the statement causing the trigger to fire, then conflict handling
policy of the outer statement is used instead.</p>

<p>Triggers are automatically <a href="lang_droptrigger.html">dropped</a>
when the table that they are 
associated with (the <i>table-name</i> table) is 
<a href="lang_droptable.html">dropped</a>.  However if the trigger actions reference
other tables, the trigger is not dropped or modified if those other
tables are <a href="lang_droptable.html">dropped</a> or <a href="lang_altertable.html">modified</a>.</p>

<p>Triggers are removed using the <a href="lang_droptrigger.html">DROP TRIGGER</a> statement.</p>

<h3>Syntax Restrictions On UPDATE, DELETE, and INSERT Statements Within
    Triggers</h3>

<p>The <a href="lang_update.html">UPDATE</a>, <a href="lang_delete.html">DELETE</a>, and <a href="lang_insert.html">INSERT</a>
statements within triggers do not support
the full syntax for <a href="lang_update.html">UPDATE</a>, <a href="lang_delete.html">DELETE</a>, and <a href="lang_insert.html">INSERT</a> statements.  The following
restrictions apply:</p>

<ul>







|

|



|



|



|








|
















|
|







346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
<p>Both the WHEN clause and the trigger actions may access elements of 
the row being inserted, deleted or updated using references of the form 
"NEW.<i>column-name</i>" and "OLD.<i>column-name</i>", where
<i>column-name</i> is the name of a column from the table that the trigger
is associated with. OLD and NEW references may only be used in triggers on
events for which they are relevant, as follows:</p>

<table border="0" cellpadding="10">
<tr>
<td valign="top" align="right" width="120"><i>INSERT</i></td>
<td valign="top">NEW references are valid</td>
</tr>
<tr>
<td valign="top" align="right" width="120"><i>UPDATE</i></td>
<td valign="top">NEW and OLD references are valid</td>
</tr>
<tr>
<td valign="top" align="right" width="120"><i>DELETE</i></td>
<td valign="top">OLD references are valid</td>
</tr>
</table>


<p>If a WHEN clause is supplied, the SQL statements specified
are only executed if the WHEN clause is true.
If no WHEN clause is supplied, the SQL statements
are executed every time the trigger fires.</p>

<p>The BEFORE or AFTER keyword determines when the trigger actions
will be executed relative to the insertion, modification or removal of the
associated row.  BEFORE is the default when neither keyword is present.</p>

<p>An <a href="lang_conflict.html">ON CONFLICT</a> clause may be specified as part of an <a href="lang_update.html">UPDATE</a> or <a href="lang_insert.html">INSERT</a>
action within the body of the trigger.
However if an <a href="lang_conflict.html">ON CONFLICT</a> clause is specified as part of 
the statement causing the trigger to fire, then conflict handling
policy of the outer statement is used instead.</p>

<p>Triggers are automatically <a href="lang_droptrigger.html">dropped</a>
when the table that they are 
associated with (the <i>table-name</i> table) is 
<a href="lang_droptable.html">dropped</a>.  However if the trigger actions reference
other tables, the trigger is not dropped or modified if those other
tables are <a href="lang_droptable.html">dropped</a> or <a href="lang_altertable.html">modified</a>.</p>

<p>Triggers are removed using the <a href="lang_droptrigger.html">DROP TRIGGER</a> statement.</p>

<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
    Triggers</h2>

<p>The <a href="lang_update.html">UPDATE</a>, <a href="lang_delete.html">DELETE</a>, and <a href="lang_insert.html">INSERT</a>
statements within triggers do not support
the full syntax for <a href="lang_update.html">UPDATE</a>, <a href="lang_delete.html">DELETE</a>, and <a href="lang_insert.html">INSERT</a> statements.  The following
restrictions apply:</p>

<ul>
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
  <a href="syntax/common-table-expression.html">Common table expression</a> are not supported for
  statements inside of triggers.
  </p></li>
</ul>

<a name="instead_of_trigger"></a>

<h3>INSTEAD OF triggers</h3>

<p>Triggers may be created on <a href="lang_createview.html">views</a>, as well as ordinary tables, by
specifying INSTEAD OF in the CREATE TRIGGER statement. 
If one or more ON INSERT, ON DELETE
or ON UPDATE triggers are defined on a view, then it is not an
error to execute an INSERT, DELETE or UPDATE statement on the view, 
respectively.  Instead,
executing an INSERT, DELETE or UPDATE on the view causes the associated
triggers to fire. The real tables underlying the view are not modified
(except possibly explicitly, by a trigger program).</p>

<p>Note that the <a href="c3ref/changes.html">sqlite3_changes()</a> and <a href="c3ref/total_changes.html">sqlite3_total_changes()</a> interfaces
do not count INSTEAD OF trigger firings, but the
<a href="pragma.html#pragma_count_changes">count_changes pragma</a> does count INSTEAD OF trigger firing.</p>

<h3>Some Example Triggers</h3>

<p>Assuming that customer records are stored in the "customers" table, and
that order records are stored in the "orders" table, the following
UPDATE trigger
ensures that all associated orders are redirected when a customer changes
his or her address:</p>








|















|







436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
  <a href="syntax/common-table-expression.html">Common table expression</a> are not supported for
  statements inside of triggers.
  </p></li>
</ul>

<a name="instead_of_trigger"></a>

<h1 id="instead_of_triggers"><span>3. </span>INSTEAD OF triggers</h1>

<p>Triggers may be created on <a href="lang_createview.html">views</a>, as well as ordinary tables, by
specifying INSTEAD OF in the CREATE TRIGGER statement. 
If one or more ON INSERT, ON DELETE
or ON UPDATE triggers are defined on a view, then it is not an
error to execute an INSERT, DELETE or UPDATE statement on the view, 
respectively.  Instead,
executing an INSERT, DELETE or UPDATE on the view causes the associated
triggers to fire. The real tables underlying the view are not modified
(except possibly explicitly, by a trigger program).</p>

<p>Note that the <a href="c3ref/changes.html">sqlite3_changes()</a> and <a href="c3ref/total_changes.html">sqlite3_total_changes()</a> interfaces
do not count INSTEAD OF trigger firings, but the
<a href="pragma.html#pragma_count_changes">count_changes pragma</a> does count INSTEAD OF trigger firing.</p>

<h1 id="some_example_triggers"><span>4. </span>Some Example Triggers</h1>

<p>Assuming that customer records are stored in the "customers" table, and
that order records are stored in the "orders" table, the following
UPDATE trigger
ensures that all associated orders are redirected when a customer changes
his or her address:</p>

455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
INSTEAD OF UPDATE OF cust_addr ON customer_address
BEGIN
  UPDATE customer SET cust_addr=NEW.cust_addr
   WHERE cust_id=NEW.cust_id;
END;
</pre></blockquote>

<p>With the schema above, a statement of the form:</p>

<blockquote><pre>
UPDATE customer_address SET cust_addr=$new_address WHERE cust_id=$cust_id;
</pre></blockquote>

<p>Causes the customer.cust_addr field to be updated for a specific
customer entry that has customer.cust_id equal to the $cust_id parameter.
Note how the values assigned to the view are made available as field
in the special "NEW" table within the trigger body.</p>

<a name="undef_before"></a>

<h3>Cautions On The Use Of BEFORE triggers</h3>

<p>If a BEFORE UPDATE or BEFORE DELETE trigger modifies or deletes a row
that was to have been updated or deleted, then the result of the subsequent
update or delete operation is undefined.  Furthermore, if a BEFORE trigger
modifies or deletes a row, then it is undefined whether or not AFTER triggers
that would have otherwise run on those rows will in fact run.
</p>

<p>The value of NEW.rowid is undefined in a BEFORE INSERT trigger in which
the rowid is not explicitly set to an integer.</p>

<p>Because of the behaviors described above, programmers are encouraged to
prefer AFTER triggers over BEFORE triggers.</p>

<a name="raise"></a>

<h3>The RAISE() function</h3>

<p>A special SQL function RAISE() may be used within a trigger-program,
with the following syntax</p> 

<p><b><a href="syntax/raise-function.html">raise-function:</a></b></p><div class='imgcontainer'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif"></img>
 </div>


<p>When one of RAISE(ROLLBACK,...), RAISE(ABORT,...) or RAISE(FAIL,...)
is called during trigger-program
execution, the specified <a href="lang_conflict.html">ON CONFLICT</a> processing is performed
the current query terminates.
An error code of <a href="rescode.html#constraint">SQLITE_CONSTRAINT</a> is returned to the application,
along with the specified error message.</p>

<p>When RAISE(IGNORE) is called, the remainder of the current trigger program,
the statement that caused the trigger program to execute and any subsequent
trigger programs that would have been executed are abandoned. No database
changes are rolled back.  If the statement that caused the trigger program
to execute is itself part of a trigger program, then that trigger program
resumes execution at the beginning of the next step.
</p>

<a name="temptrig"></a>

<h3>TEMP Triggers on Non-TEMP Tables</h3>

<p>A trigger normally exists in the same database as the table named
after the "ON" keyword in the CREATE TRIGGER statement.  Except, it is
possible to create a TEMP TRIGGER on a table in another database.  
Such a trigger will only fire when changes
are made to the target table by the application that defined the trigger.
Other applications that modify the database will not be able to see the







|












|
















|











|














|







497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
INSTEAD OF UPDATE OF cust_addr ON customer_address
BEGIN
  UPDATE customer SET cust_addr=NEW.cust_addr
   WHERE cust_id=NEW.cust_id;
END;
</pre></blockquote>

</p><p>With the schema above, a statement of the form:</p>

<blockquote><pre>
UPDATE customer_address SET cust_addr=$new_address WHERE cust_id=$cust_id;
</pre></blockquote>

<p>Causes the customer.cust_addr field to be updated for a specific
customer entry that has customer.cust_id equal to the $cust_id parameter.
Note how the values assigned to the view are made available as field
in the special "NEW" table within the trigger body.</p>

<a name="undef_before"></a>

<h1 id="cautions_on_the_use_of_before_triggers"><span>5. </span>Cautions On The Use Of BEFORE triggers</h1>

<p>If a BEFORE UPDATE or BEFORE DELETE trigger modifies or deletes a row
that was to have been updated or deleted, then the result of the subsequent
update or delete operation is undefined.  Furthermore, if a BEFORE trigger
modifies or deletes a row, then it is undefined whether or not AFTER triggers
that would have otherwise run on those rows will in fact run.
</p>

<p>The value of NEW.rowid is undefined in a BEFORE INSERT trigger in which
the rowid is not explicitly set to an integer.</p>

<p>Because of the behaviors described above, programmers are encouraged to
prefer AFTER triggers over BEFORE triggers.</p>

<a name="raise"></a>

<h1 id="the_raise_function"><span>6. </span>The RAISE() function</h1>

<p>A special SQL function RAISE() may be used within a trigger-program,
with the following syntax</p> 

<p><b><a href="syntax/raise-function.html">raise-function:</a></b></p><div class='imgcontainer'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif"></img>
 </div>


<p>When one of RAISE(ROLLBACK,...), RAISE(ABORT,...) or RAISE(FAIL,...)
is called during trigger-program
execution, the specified <a href="lang_conflict.html">ON CONFLICT</a> processing is performed and
the current query terminates.
An error code of <a href="rescode.html#constraint">SQLITE_CONSTRAINT</a> is returned to the application,
along with the specified error message.</p>

<p>When RAISE(IGNORE) is called, the remainder of the current trigger program,
the statement that caused the trigger program to execute and any subsequent
trigger programs that would have been executed are abandoned. No database
changes are rolled back.  If the statement that caused the trigger program
to execute is itself part of a trigger program, then that trigger program
resumes execution at the beginning of the next step.
</p>

<a name="temptrig"></a>

<h1 id="temp_triggers_on_non_temp_tables"><span>7. </span>TEMP Triggers on Non-TEMP Tables</h1>

<p>A trigger normally exists in the same database as the table named
after the "ON" keyword in the CREATE TRIGGER statement.  Except, it is
possible to create a TEMP TRIGGER on a table in another database.  
Such a trigger will only fire when changes
are made to the target table by the application that defined the trigger.
Other applications that modify the database will not be able to see the
534
535
536
537
538
539
540
541
542
<blockquote><pre>
CREATE TEMP TRIGGER ex1 AFTER INSERT ON <b>main.</b>tab1 BEGIN ...
</pre></blockquote>

<p>Failure to specify the schema name on the target table could result
in the TEMP trigger being reattached to a table with the same name in
another database whenever any schema change occurs.</p>










<
576
577
578
579
580
581
582
583

<blockquote><pre>
CREATE TEMP TRIGGER ex1 AFTER INSERT ON <b>main.</b>tab1 BEGIN ...
</pre></blockquote>

<p>Failure to specify the schema name on the target table could result
in the TEMP trigger being reattached to a table with the same name in
another database whenever any schema change occurs.</p>


Changes to Doc/Extra/Core/lang_createview.html.
1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>SQLite Query Language: CREATE VIEW</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>





|







1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>CREATE VIEW</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93












94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194


195
196
197
198
199
200
201
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>












<div class=nosearch><h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>CREATE VIEW</h2></div><p><b><a href="syntax/create-view-stmt.html">create-view-stmt:</a></b>
<button id='x1511' onclick='hideorshow("x1511","x1512")'>hide</button></p>
 <div id='x1512' class='imgcontainer'>
 <img alt="syntax diagram create-view-stmt" src="images/syntax/create-view-stmt.gif" />
<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
<button id='x1513' onclick='hideorshow("x1513","x1514")'>show</button></p>
 <div id='x1514' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntax/common-table-expression.html">common-table-expression:</a></b>
<button id='x1515' onclick='hideorshow("x1515","x1516")'>show</button></p>
 <div id='x1516' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
</div>
<p><b><a href="syntax/compound-operator.html">compound-operator:</a></b>
<button id='x1517' onclick='hideorshow("x1517","x1518")'>show</button></p>
 <div id='x1518' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</div>
<p><b><a href="syntax/expr.html">expr:</a></b>
<button id='x1519' onclick='hideorshow("x1519","x1520")'>show</button></p>
 <div id='x1520' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntax/filter-clause.html">filter-clause:</a></b>
<button id='x1521' onclick='hideorshow("x1521","x1522")'>show</button></p>
 <div id='x1522' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram filter-clause" src="images/syntax/filter-clause.gif" />
</div>
<p><b><a href="syntax/literal-value.html">literal-value:</a></b>
<button id='x1523' onclick='hideorshow("x1523","x1524")'>show</button></p>
 <div id='x1524' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</div>
<p><b><a href="syntax/over-clause.html">over-clause:</a></b>
<button id='x1525' onclick='hideorshow("x1525","x1526")'>show</button></p>
 <div id='x1526' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram over-clause" src="images/syntax/over-clause.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x1527' onclick='hideorshow("x1527","x1528")'>show</button></p>
 <div id='x1528' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
</div>
<p><b><a href="syntax/raise-function.html">raise-function:</a></b>
<button id='x1529' onclick='hideorshow("x1529","x1530")'>show</button></p>
 <div id='x1530' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</div>
<p><b><a href="syntax/type-name.html">type-name:</a></b>
<button id='x1531' onclick='hideorshow("x1531","x1532")'>show</button></p>
 <div id='x1532' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
<button id='x1533' onclick='hideorshow("x1533","x1534")'>show</button></p>
 <div id='x1534' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</div>
</div>
</div>
<p><b><a href="syntax/join-clause.html">join-clause:</a></b>
<button id='x1535' onclick='hideorshow("x1535","x1536")'>show</button></p>
 <div id='x1536' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
<button id='x1537' onclick='hideorshow("x1537","x1538")'>show</button></p>
 <div id='x1538' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</div>
<p><b><a href="syntax/join-operator.html">join-operator:</a></b>
<button id='x1539' onclick='hideorshow("x1539","x1540")'>show</button></p>
 <div id='x1540' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</div>
</div>
<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
<button id='x1541' onclick='hideorshow("x1541","x1542")'>show</button></p>
 <div id='x1542' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</div>
<p><b><a href="syntax/result-column.html">result-column:</a></b>
<button id='x1543' onclick='hideorshow("x1543","x1544")'>show</button></p>
 <div id='x1544' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</div>
<p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
<button id='x1545' onclick='hideorshow("x1545","x1546")'>show</button></p>
 <div id='x1546' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</div>
<p><b><a href="syntax/window-defn.html">window-defn:</a></b>
<button id='x1547' onclick='hideorshow("x1547","x1548")'>show</button></p>
 <div id='x1548' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram window-defn" src="images/syntax/window-defn.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x1549' onclick='hideorshow("x1549","x1550")'>show</button></p>
 <div id='x1550' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
</div>
</div>
</div>




<p>The CREATE VIEW command assigns a name to a pre-packaged 
<a href="lang_select.html">SELECT</a> statement. 
Once the view is created, it can be used in the FROM clause
of another <a href="lang_select.html">SELECT</a> in place of a table name.
</p>








|

















>
>
>
>
>
>
>
>
>
>
>
>
|
|
|


|
|


|
|



|
|



|
|


|
|



|
|



|
|


|
|




|
|



|
|


|
|





|
|


|
|



|
|




|
|



|
|



|
|



|
|


|
|






>
>







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<div class=fancy>
<div class=nosearch>
<div class="fancy_title">
CREATE VIEW
</div>
</div>




<h1 id="syntax"><span>1. </span>Syntax</h1>

<p><b><a href="syntax/create-view-stmt.html">create-view-stmt:</a></b>
<button id='x1543' onclick='hideorshow("x1543","x1544")'>hide</button></p>
 <div id='x1544' class='imgcontainer'>
 <img alt="syntax diagram create-view-stmt" src="images/syntax/create-view-stmt.gif" />
<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
<button id='x1545' onclick='hideorshow("x1545","x1546")'>show</button></p>
 <div id='x1546' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntax/common-table-expression.html">common-table-expression:</a></b>
<button id='x1547' onclick='hideorshow("x1547","x1548")'>show</button></p>
 <div id='x1548' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
</div>
<p><b><a href="syntax/compound-operator.html">compound-operator:</a></b>
<button id='x1549' onclick='hideorshow("x1549","x1550")'>show</button></p>
 <div id='x1550' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</div>
<p><b><a href="syntax/expr.html">expr:</a></b>
<button id='x1551' onclick='hideorshow("x1551","x1552")'>show</button></p>
 <div id='x1552' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntax/filter-clause.html">filter-clause:</a></b>
<button id='x1553' onclick='hideorshow("x1553","x1554")'>show</button></p>
 <div id='x1554' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram filter-clause" src="images/syntax/filter-clause.gif" />
</div>
<p><b><a href="syntax/literal-value.html">literal-value:</a></b>
<button id='x1555' onclick='hideorshow("x1555","x1556")'>show</button></p>
 <div id='x1556' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</div>
<p><b><a href="syntax/over-clause.html">over-clause:</a></b>
<button id='x1557' onclick='hideorshow("x1557","x1558")'>show</button></p>
 <div id='x1558' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram over-clause" src="images/syntax/over-clause.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x1559' onclick='hideorshow("x1559","x1560")'>show</button></p>
 <div id='x1560' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
</div>
<p><b><a href="syntax/raise-function.html">raise-function:</a></b>
<button id='x1561' onclick='hideorshow("x1561","x1562")'>show</button></p>
 <div id='x1562' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</div>
<p><b><a href="syntax/type-name.html">type-name:</a></b>
<button id='x1563' onclick='hideorshow("x1563","x1564")'>show</button></p>
 <div id='x1564' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
<button id='x1565' onclick='hideorshow("x1565","x1566")'>show</button></p>
 <div id='x1566' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</div>
</div>
</div>
<p><b><a href="syntax/join-clause.html">join-clause:</a></b>
<button id='x1567' onclick='hideorshow("x1567","x1568")'>show</button></p>
 <div id='x1568' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
<button id='x1569' onclick='hideorshow("x1569","x1570")'>show</button></p>
 <div id='x1570' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</div>
<p><b><a href="syntax/join-operator.html">join-operator:</a></b>
<button id='x1571' onclick='hideorshow("x1571","x1572")'>show</button></p>
 <div id='x1572' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</div>
</div>
<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
<button id='x1573' onclick='hideorshow("x1573","x1574")'>show</button></p>
 <div id='x1574' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</div>
<p><b><a href="syntax/result-column.html">result-column:</a></b>
<button id='x1575' onclick='hideorshow("x1575","x1576")'>show</button></p>
 <div id='x1576' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</div>
<p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
<button id='x1577' onclick='hideorshow("x1577","x1578")'>show</button></p>
 <div id='x1578' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</div>
<p><b><a href="syntax/window-defn.html">window-defn:</a></b>
<button id='x1579' onclick='hideorshow("x1579","x1580")'>show</button></p>
 <div id='x1580' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram window-defn" src="images/syntax/window-defn.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x1581' onclick='hideorshow("x1581","x1582")'>show</button></p>
 <div id='x1582' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
</div>
</div>
</div>


<h1 id="description"><span>2. </span>Description</h1>

<p>The CREATE VIEW command assigns a name to a pre-packaged 
<a href="lang_select.html">SELECT</a> statement. 
Once the view is created, it can be used in the FROM clause
of another <a href="lang_select.html">SELECT</a> in place of a table name.
</p>

229
230
231
232
233
234
235
236
237
238
239
well-defined names using the 
"<a href="syntax/result-column.html">AS column-alias</a>" syntax.
SQLite allows you to create views that depend on automatically 
generated column names, but you should avoid using them since the 
rules used to generate column names are not a defined part of the
interface and might change in future releases of SQLite.

<p>The <span class='yyterm'>column-name</span> list syntax was added in
SQLite versions 3.9.0 (2015-10-14).









|


|
243
244
245
246
247
248
249
250
251
252
253
well-defined names using the 
"<a href="syntax/result-column.html">AS column-alias</a>" syntax.
SQLite allows you to create views that depend on automatically 
generated column names, but you should avoid using them since the 
rules used to generate column names are not a defined part of the
interface and might change in future releases of SQLite.

</p><p>The <span class='yyterm'>column-name</span> list syntax was added in
SQLite versions 3.9.0 (2015-10-14).

</p>
Changes to Doc/Extra/Core/lang_createvtab.html.
1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>SQLite Query Language: CREATE VIRTUAL TABLE</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>





|







1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>CREATE VIRTUAL TABLE</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93











94
95
96
97
98
99
100
101
102
103
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>











<div class=nosearch><h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>CREATE VIRTUAL TABLE</h2></div><p><b><a href="syntax/create-virtual-table-stmt.html">create-virtual-table-stmt:</a></b>
<button id='x1551' onclick='hideorshow("x1551","x1552")'>hide</button></p>
 <div id='x1552' class='imgcontainer'>
 <img alt="syntax diagram create-virtual-table-stmt" src="images/syntax/create-virtual-table-stmt.gif" />
</div>


<p>A <a href="vtab.html">virtual table</a> is an interface to an external storage or computation
engine that appears to be a table but does not actually store information
in the database file.</p>







|

















>
>
>
>
>
>
>
>
>
>
>
|
|
|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<div class=fancy>
<div class=nosearch>
<div class="fancy_title">
CREATE VIRTUAL TABLE
</div>
</div>





<p><b><a href="syntax/create-virtual-table-stmt.html">create-virtual-table-stmt:</a></b>
<button id='x1583' onclick='hideorshow("x1583","x1584")'>hide</button></p>
 <div id='x1584' class='imgcontainer'>
 <img alt="syntax diagram create-virtual-table-stmt" src="images/syntax/create-virtual-table-stmt.gif" />
</div>


<p>A <a href="vtab.html">virtual table</a> is an interface to an external storage or computation
engine that appears to be a table but does not actually store information
in the database file.</p>
121
122
123
124
125
126
127
128
129
to the <a href="vtab.html#xcreate">xCreate</a> and <a href="vtab.html#xconnect">xConnect</a> methods of the module implementation
without any interpretation.  It is the responsibility
of the module implementation to parse and interpret its own arguments.</p>

<p>A virtual table is destroyed using the ordinary
<a href="lang_droptable.html">DROP TABLE</a> statement.  There is no
DROP VIRTUAL TABLE statement.</p>










<
132
133
134
135
136
137
138
139

to the <a href="vtab.html#xcreate">xCreate</a> and <a href="vtab.html#xconnect">xConnect</a> methods of the module implementation
without any interpretation.  It is the responsibility
of the module implementation to parse and interpret its own arguments.</p>

<p>A virtual table is destroyed using the ordinary
<a href="lang_droptable.html">DROP TABLE</a> statement.  There is no
DROP VIRTUAL TABLE statement.</p>


Changes to Doc/Extra/Core/lang_datefunc.html.
1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>SQLite Query Language: Date And Time Functions</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>





|







1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>Date And Time Functions</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93

94


































95
96
97
98
99
100
101
102
103
104
105
106
107
108
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>

<div class=nosearch><h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>Date And Time Functions</h2></div>



































<p>
SQLite supports five date and time functions as follows:
</p>

<p>
<ol>
<li> <b>date(</b><i>timestring, modifier, modifier, ...</i><b>)</b> </li>
<li> <b>time(</b><i>timestring, modifier, modifier, ...</i><b>)</b> </li>
<li> <b>datetime(</b><i>timestring, modifier, modifier, ...</i><b>)</b> </li>
<li> <b>julianday(</b><i>timestring, modifier, modifier, ...</i><b>)</b> </li>
<li> <b>strftime(</b><i>format, timestring, modifier, modifier, ...</i><b>)</b> </li>
</ol>








|

















>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>






|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<div class=fancy>
<div class=nosearch>
<div class="fancy_title">
Date And Time Functions
</div>
<div class="fancy_toc">
<a onclick="toggle_toc()">
<span class="fancy_toc_mark" id="toc_mk">&#x25ba;</span>
Table Of Contents
</a>
<div id="toc_sub"><div class="fancy-toc1"><a href="#overview">1. Overview</a></div>
<div class="fancy-toc1"><a href="#time_strings">2. Time Strings</a></div>
<div class="fancy-toc1"><a href="#modifiers">3. Modifiers</a></div>
<div class="fancy-toc1"><a href="#examples">4. Examples</a></div>
<div class="fancy-toc1"><a href="#caveats_and_bugs">5. Caveats And Bugs</a></div>
</div>
</div>
<script>
function toggle_toc(){
var sub = document.getElementById("toc_sub")
var mk = document.getElementById("toc_mk")
if( sub.style.display!="block" ){
sub.style.display = "block";
mk.innerHTML = "&#x25bc;";
} else {
sub.style.display = "none";
mk.innerHTML = "&#x25ba;";
}
}
</script>
</div>




<h1 id="overview"><span>1. </span>Overview</h1>

<p>
SQLite supports five date and time functions as follows:
</p>

<p>
</p><ol>
<li> <b>date(</b><i>timestring, modifier, modifier, ...</i><b>)</b> </li>
<li> <b>time(</b><i>timestring, modifier, modifier, ...</i><b>)</b> </li>
<li> <b>datetime(</b><i>timestring, modifier, modifier, ...</i><b>)</b> </li>
<li> <b>julianday(</b><i>timestring, modifier, modifier, ...</i><b>)</b> </li>
<li> <b>strftime(</b><i>format, timestring, modifier, modifier, ...</i><b>)</b> </li>
</ol>

129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
<a href="http://opengroup.org/onlinepubs/007908799/xsh/strftime.html">strftime() function</a>
from the standard C library plus two new substitutions, %f and %J.
The following is a complete list of valid strftime() substitutions:
</p>

<blockquote>
<table border="0" cellpadding="0" cellspacing="0">
<tr><td><td width="10"><td></tr>

<tr><td> %d <td><td> day of month: 00
<tr><td> %f <td><td> fractional seconds: SS.SSS
<tr><td> %H <td><td> hour: 00-24 
<tr><td> %j <td><td> day of year: 001-366
<tr><td> %J <td><td> Julian day number
<tr><td> %m <td><td> month: 01-12
<tr><td> %M <td><td> minute: 00-59
<tr><td> %s <td><td> seconds since 1970-01-01
<tr><td> %S <td><td> seconds: 00-59
<tr><td> %w <td><td> day of week 0-6 with Sunday==0
<tr><td> %W <td><td> week of year: 00-53
<tr><td> %Y <td><td> year: 0000-9999
<tr><td> %% <td><td> %
</table>
</blockquote>

<p>
Notice that all other date and time functions can be expressed
in terms of strftime():
</p>

<blockquote>
<table border="0" cellpadding="0" cellspacing="0">
<tr><td><b>Function</b><td width="30"><td><b>Equivalent strftime()</b>
<tr><td>   date(...)      <td><td>  strftime('%Y-%m-%d', ...)
<tr><td>   time(...)      <td><td>  strftime('%H:%M:%S', ...)
<tr><td>   datetime(...)  <td><td>  strftime('%Y-%m-%d %H:%M:%S', ...)
<tr><td>   julianday(...) <td><td>  strftime('%J', ...)
</table>
</blockquote>

<p>
The only reasons for providing functions other than strftime() is
for convenience and for efficiency.
</p>

<h3>Time Strings</h3>

<p>A time string can be in any of the following formats:</p>

<ol>
<li> <i>YYYY-MM-DD</i>
<li> <i>YYYY-MM-DD HH:MM</i>
<li> <i>YYYY-MM-DD HH:MM:SS</i>
<li> <i>YYYY-MM-DD HH:MM:SS.SSS</i>
<li> <i>YYYY-MM-DD</i><b>T</b><i>HH:MM</i>
<li> <i>YYYY-MM-DD</i><b>T</b><i>HH:MM:SS</i>
<li> <i>YYYY-MM-DD</i><b>T</b><i>HH:MM:SS.SSS</i>
<li> <i>HH:MM</i>
<li> <i>HH:MM:SS</i>
<li> <i>HH:MM:SS.SSS</i>
<li> <b>now</b>
<li> <i>DDDDDDDDDD</i>
</ol>

<p>
In formats 5 through 7, the "T" is a literal character separating 
the date and the time, as required by 
<a href="http://www.w3c.org/TR/NOTE-datetime">ISO-8601</a>. 
Formats 8 through 10 that specify only a time assume a date of 
2000-01-01. Format 11, the string 'now', is converted into the 







|

|
|
|
|
|
|
|
|
|
|
|
|
|
|









|
|
|
|
|
|







|





|
|
|
|
|
|
|
|
|
|
|
|







164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
<a href="http://opengroup.org/onlinepubs/007908799/xsh/strftime.html">strftime() function</a>
from the standard C library plus two new substitutions, %f and %J.
The following is a complete list of valid strftime() substitutions:
</p>

<blockquote>
<table border="0" cellpadding="0" cellspacing="0">
<tr><td></td><td width="10"></td><td></td></tr>

<tr><td> %d </td><td></td><td> day of month: 00
</td></tr><tr><td> %f </td><td></td><td> fractional seconds: SS.SSS
</td></tr><tr><td> %H </td><td></td><td> hour: 00-24 
</td></tr><tr><td> %j </td><td></td><td> day of year: 001-366
</td></tr><tr><td> %J </td><td></td><td> Julian day number
</td></tr><tr><td> %m </td><td></td><td> month: 01-12
</td></tr><tr><td> %M </td><td></td><td> minute: 00-59
</td></tr><tr><td> %s </td><td></td><td> seconds since 1970-01-01
</td></tr><tr><td> %S </td><td></td><td> seconds: 00-59
</td></tr><tr><td> %w </td><td></td><td> day of week 0-6 with Sunday==0
</td></tr><tr><td> %W </td><td></td><td> week of year: 00-53
</td></tr><tr><td> %Y </td><td></td><td> year: 0000-9999
</td></tr><tr><td> %% </td><td></td><td> %
</td></tr></table>
</blockquote>

<p>
Notice that all other date and time functions can be expressed
in terms of strftime():
</p>

<blockquote>
<table border="0" cellpadding="0" cellspacing="0">
<tr><td><b>Function</b></td><td width="30"></td><td><b>Equivalent strftime()</b>
</td></tr><tr><td>   date(...)      </td><td></td><td>  strftime('%Y-%m-%d', ...)
</td></tr><tr><td>   time(...)      </td><td></td><td>  strftime('%H:%M:%S', ...)
</td></tr><tr><td>   datetime(...)  </td><td></td><td>  strftime('%Y-%m-%d %H:%M:%S', ...)
</td></tr><tr><td>   julianday(...) </td><td></td><td>  strftime('%J', ...)
</td></tr></table>
</blockquote>

<p>
The only reasons for providing functions other than strftime() is
for convenience and for efficiency.
</p>

<h1 id="time_strings"><span>2. </span>Time Strings</h1>

<p>A time string can be in any of the following formats:</p>

<ol>
<li> <i>YYYY-MM-DD</i>
</li><li> <i>YYYY-MM-DD HH:MM</i>
</li><li> <i>YYYY-MM-DD HH:MM:SS</i>
</li><li> <i>YYYY-MM-DD HH:MM:SS.SSS</i>
</li><li> <i>YYYY-MM-DD</i><b>T</b><i>HH:MM</i>
</li><li> <i>YYYY-MM-DD</i><b>T</b><i>HH:MM:SS</i>
</li><li> <i>YYYY-MM-DD</i><b>T</b><i>HH:MM:SS.SSS</i>
</li><li> <i>HH:MM</i>
</li><li> <i>HH:MM:SS</i>
</li><li> <i>HH:MM:SS.SSS</i>
</li><li> <b>now</b>
</li><li> <i>DDDDDDDDDD</i>
</li></ol>

<p>
In formats 5 through 7, the "T" is a literal character separating 
the date and the time, as required by 
<a href="http://www.w3c.org/TR/NOTE-datetime">ISO-8601</a>. 
Formats 8 through 10 that specify only a time assume a date of 
2000-01-01. Format 11, the string 'now', is converted into the 
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
to the result, but the input string can have fewer or more than three digits
and the date/time functions will still operate correctly.
Similarly, format 12 is shown with 10 significant digits, but the date/time
functions will really accept as many or as few digits as are necessary to
represent the Julian day number.
</p>

<h3>Modifiers</h3>

<p>The time string can be followed by zero or more modifiers that 
alter date and/or time. Each modifier
is a transformation that is applied to the time value to its left.
Modifiers are applied from left to right; order is important.
The available modifiers are as follows.</p>

<ol>
<li> NNN days
<li> NNN hours
<li> NNN minutes
<li> NNN.NNNN seconds
<li> NNN months
<li> NNN years
<li> start of month
<li> start of year
<li> start of day
<li> weekday N
<li> unixepoch
<li> localtime
<li> utc 
</ol>

<p>The first six modifiers (1 through 6) 
simply add the specified amount of time to the date and time 
specified by the preceding timestring and modifiers.
The 's' character at the end of the modifier names is optional.
Note that "&plusmn;NNN months" works by rendering the original date into
the YYYY-MM-DD format, adding the &plusmn;NNN to the MM month value, then







|









|
|
|
|
|
|
|
|
|
|
|
|
|







263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
to the result, but the input string can have fewer or more than three digits
and the date/time functions will still operate correctly.
Similarly, format 12 is shown with 10 significant digits, but the date/time
functions will really accept as many or as few digits as are necessary to
represent the Julian day number.
</p>

<h1 id="modifiers"><span>3. </span>Modifiers</h1>

<p>The time string can be followed by zero or more modifiers that 
alter date and/or time. Each modifier
is a transformation that is applied to the time value to its left.
Modifiers are applied from left to right; order is important.
The available modifiers are as follows.</p>

<ol>
<li> NNN days
</li><li> NNN hours
</li><li> NNN minutes
</li><li> NNN.NNNN seconds
</li><li> NNN months
</li><li> NNN years
</li><li> start of month
</li><li> start of year
</li><li> start of day
</li><li> weekday N
</li><li> unixepoch
</li><li> localtime
</li><li> utc 
</li></ol>

<p>The first six modifiers (1 through 6) 
simply add the specified amount of time to the date and time 
specified by the preceding timestring and modifiers.
The 's' character at the end of the modifier names is optional.
Note that "&plusmn;NNN months" works by rendering the original date into
the YYYY-MM-DD format, adding the &plusmn;NNN to the MM month value, then
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
follows a time that is not UTC, then the behavior is undefined.
The "utc" modifier is the opposite of "localtime".  
"utc" assumes that the string
to its left is in the local timezone and adjusts that string to be in UTC.
If the prior string is not in localtime, then the result of "utc" is
undefined.</p>

<h3>Examples</h3>

<p>Compute the current date.<p>

<blockquote>SELECT date('now');</blockquote>

<p>Compute the last day of the current month.</p>

<blockquote>SELECT date('now','start of month','+1 month','-1 day');
</blockquote>

<p>Compute the date and time given a unix timestamp 1092941466.</p>







|

|

|







335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
follows a time that is not UTC, then the behavior is undefined.
The "utc" modifier is the opposite of "localtime".  
"utc" assumes that the string
to its left is in the local timezone and adjusts that string to be in UTC.
If the prior string is not in localtime, then the result of "utc" is
undefined.</p>

<h1 id="examples"><span>4. </span>Examples</h1>

<p>Compute the current date.</p><p>

</p><blockquote>SELECT date('now');</blockquote>

<p>Compute the last day of the current month.</p>

<blockquote>SELECT date('now','start of month','+1 month','-1 day');
</blockquote>

<p>Compute the date and time given a unix timestamp 1092941466.</p>
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
<p>Compute the time since the unix epoch in seconds 
(like strftime('%s','now') except includes fractional part):</p>

<blockquote>
  SELECT (julianday('now') - 2440587.5)*86400.0;
</blockquote>

<h3>Caveats And Bugs</h3>

<p>The computation of local time depends heavily on the whim 
of politicians and is thus difficult to get correct for 
all locales. In this implementation, the standard C library 
function localtime_r() is used to assist in the calculation of 
local time.  The 
localtime_r() C function normally only works for years







|







394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
<p>Compute the time since the unix epoch in seconds 
(like strftime('%s','now') except includes fractional part):</p>

<blockquote>
  SELECT (julianday('now') - 2440587.5)*86400.0;
</blockquote>

<h1 id="caveats_and_bugs"><span>5. </span>Caveats And Bugs</h1>

<p>The computation of local time depends heavily on the whim 
of politicians and is thus difficult to get correct for 
all locales. In this implementation, the standard C library 
function localtime_r() is used to assist in the calculation of 
local time.  The 
localtime_r() C function normally only works for years
389
390
391
392
393
394
395
396
397
to all previous years as well. Vista does somewhat better
getting results correct back to 1986, when the rules were also changed.</p>

<p>All internal computations assume the 
<a href="http://en.wikipedia.org/wiki/Gregorian_calendar">Gregorian calendar</a>
system.  It is also assumed that every
day is exactly 86400 seconds in duration.</p>










<
424
425
426
427
428
429
430
431

to all previous years as well. Vista does somewhat better
getting results correct back to 1986, when the rules were also changed.</p>

<p>All internal computations assume the 
<a href="http://en.wikipedia.org/wiki/Gregorian_calendar">Gregorian calendar</a>
system.  It is also assumed that every
day is exactly 86400 seconds in duration.</p>


Changes to Doc/Extra/Core/lang_delete.html.
1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>SQLite Query Language: DELETE</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>





|







1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>DELETE</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93




































94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>




































<div class=nosearch><h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>DELETE</h2></div><p><b><a href="syntax/delete-stmt.html">delete-stmt:</a></b>
<button id='x1553' onclick='hideorshow("x1553","x1554")'>hide</button></p>
 <div id='x1554' class='imgcontainer'>
 <img alt="syntax diagram delete-stmt" src="images/syntax/delete-stmt.gif" />
<p><b><a href="syntax/expr.html">expr:</a></b>
<button id='x1555' onclick='hideorshow("x1555","x1556")'>show</button></p>
 <div id='x1556' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntax/filter-clause.html">filter-clause:</a></b>
<button id='x1557' onclick='hideorshow("x1557","x1558")'>show</button></p>
 <div id='x1558' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram filter-clause" src="images/syntax/filter-clause.gif" />
</div>
<p><b><a href="syntax/literal-value.html">literal-value:</a></b>
<button id='x1559' onclick='hideorshow("x1559","x1560")'>show</button></p>
 <div id='x1560' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</div>
<p><b><a href="syntax/over-clause.html">over-clause:</a></b>
<button id='x1561' onclick='hideorshow("x1561","x1562")'>show</button></p>
 <div id='x1562' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram over-clause" src="images/syntax/over-clause.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x1563' onclick='hideorshow("x1563","x1564")'>show</button></p>
 <div id='x1564' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
<button id='x1565' onclick='hideorshow("x1565","x1566")'>show</button></p>
 <div id='x1566' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</div>
</div>
<p><b><a href="syntax/raise-function.html">raise-function:</a></b>
<button id='x1567' onclick='hideorshow("x1567","x1568")'>show</button></p>
 <div id='x1568' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</div>
<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
<button id='x1569' onclick='hideorshow("x1569","x1570")'>show</button></p>
 <div id='x1570' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntax/common-table-expression.html">common-table-expression:</a></b>
<button id='x1571' onclick='hideorshow("x1571","x1572")'>show</button></p>
 <div id='x1572' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
</div>
<p><b><a href="syntax/compound-operator.html">compound-operator:</a></b>
<button id='x1573' onclick='hideorshow("x1573","x1574")'>show</button></p>
 <div id='x1574' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</div>
<p><b><a href="syntax/join-clause.html">join-clause:</a></b>
<button id='x1575' onclick='hideorshow("x1575","x1576")'>show</button></p>
 <div id='x1576' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
<button id='x1577' onclick='hideorshow("x1577","x1578")'>show</button></p>
 <div id='x1578' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</div>
<p><b><a href="syntax/join-operator.html">join-operator:</a></b>
<button id='x1579' onclick='hideorshow("x1579","x1580")'>show</button></p>
 <div id='x1580' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</div>
</div>
<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
<button id='x1581' onclick='hideorshow("x1581","x1582")'>show</button></p>
 <div id='x1582' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</div>
<p><b><a href="syntax/result-column.html">result-column:</a></b>
<button id='x1583' onclick='hideorshow("x1583","x1584")'>show</button></p>
 <div id='x1584' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</div>
<p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
<button id='x1585' onclick='hideorshow("x1585","x1586")'>show</button></p>
 <div id='x1586' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</div>
<p><b><a href="syntax/window-defn.html">window-defn:</a></b>
<button id='x1587' onclick='hideorshow("x1587","x1588")'>show</button></p>
 <div id='x1588' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram window-defn" src="images/syntax/window-defn.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x1589' onclick='hideorshow("x1589","x1590")'>show</button></p>
 <div id='x1590' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
</div>
</div>
<p><b><a href="syntax/type-name.html">type-name:</a></b>
<button id='x1591' onclick='hideorshow("x1591","x1592")'>show</button></p>
 <div id='x1592' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
<button id='x1593' onclick='hideorshow("x1593","x1594")'>show</button></p>
 <div id='x1594' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</div>
</div>
</div>
<p><b><a href="syntax/qualified-table-name.html">qualified-table-name:</a></b>
<button id='x1595' onclick='hideorshow("x1595","x1596")'>show</button></p>
 <div id='x1596' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram qualified-table-name" src="images/syntax/qualified-table-name.gif" />
</div>
<p><b><a href="syntax/with-clause.html">with-clause:</a></b>
<button id='x1597' onclick='hideorshow("x1597","x1598")'>show</button></p>
 <div id='x1598' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram with-clause" src="images/syntax/with-clause.gif" />
<p><b><a href="syntax/cte-table-name.html">cte-table-name:</a></b>
<button id='x1599' onclick='hideorshow("x1599","x1600")'>show</button></p>
 <div id='x1600' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram cte-table-name" src="images/syntax/cte-table-name.gif" />
</div>
<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
<button id='x1601' onclick='hideorshow("x1601","x1602")'>show</button></p>
 <div id='x1602' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntax/common-table-expression.html">common-table-expression:</a></b>
<button id='x1603' onclick='hideorshow("x1603","x1604")'>show</button></p>







|

















>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
|


|
|


|
|



|
|



|
|


|
|



|
|




<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
















































































164
165
166
167
168
169
170
171
172
173
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<div class=fancy>
<div class=nosearch>
<div class="fancy_title">
DELETE
</div>
<div class="fancy_toc">
<a onclick="toggle_toc()">
<span class="fancy_toc_mark" id="toc_mk">&#x25ba;</span>
Table Of Contents
</a>
<div id="toc_sub"><div class="fancy-toc1"><a href="#overview">1. Overview</a></div>
<div class="fancy-toc1"><a href="#restrictions_on_delete_statements_within_create_trigger">2. Restrictions on DELETE Statements Within CREATE TRIGGER</a></div>
<div class="fancy-toc1"><a href="#optional_limit_and_order_by_clauses">3. Optional LIMIT and ORDER BY clauses</a></div>
<div class="fancy-toc1"><a href="#the_truncate_optimization">4. The Truncate Optimization</a></div>
</div>
</div>
<script>
function toggle_toc(){
var sub = document.getElementById("toc_sub")
var mk = document.getElementById("toc_mk")
if( sub.style.display!="block" ){
sub.style.display = "block";
mk.innerHTML = "&#x25bc;";
} else {
sub.style.display = "none";
mk.innerHTML = "&#x25ba;";
}
}
</script>
</div>




<h1 id="overview"><span>1. </span>Overview</h1>

<p><b><a href="syntax/delete-stmt.html">delete-stmt:</a></b>
<button id='x1585' onclick='hideorshow("x1585","x1586")'>hide</button></p>
 <div id='x1586' class='imgcontainer'>
 <img alt="syntax diagram delete-stmt" src="images/syntax/delete-stmt.gif" />
<p><b><a href="syntax/expr.html">expr:</a></b>
<button id='x1587' onclick='hideorshow("x1587","x1588")'>show</button></p>
 <div id='x1588' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntax/filter-clause.html">filter-clause:</a></b>
<button id='x1589' onclick='hideorshow("x1589","x1590")'>show</button></p>
 <div id='x1590' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram filter-clause" src="images/syntax/filter-clause.gif" />
</div>
<p><b><a href="syntax/literal-value.html">literal-value:</a></b>
<button id='x1591' onclick='hideorshow("x1591","x1592")'>show</button></p>
 <div id='x1592' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</div>
<p><b><a href="syntax/over-clause.html">over-clause:</a></b>
<button id='x1593' onclick='hideorshow("x1593","x1594")'>show</button></p>
 <div id='x1594' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram over-clause" src="images/syntax/over-clause.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x1595' onclick='hideorshow("x1595","x1596")'>show</button></p>
 <div id='x1596' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
<button id='x1597' onclick='hideorshow("x1597","x1598")'>show</button></p>
 <div id='x1598' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</div>
</div>
<p><b><a href="syntax/raise-function.html">raise-function:</a></b>
















































































<button id='x1599' onclick='hideorshow("x1599","x1600")'>show</button></p>
 <div id='x1600' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</div>
<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
<button id='x1601' onclick='hideorshow("x1601","x1602")'>show</button></p>
 <div id='x1602' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntax/common-table-expression.html">common-table-expression:</a></b>
<button id='x1603' onclick='hideorshow("x1603","x1604")'>show</button></p>
260
261
262
263
264
265
266








267
268








































































269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x1621' onclick='hideorshow("x1621","x1622")'>show</button></p>
 <div id='x1622' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
</div>
</div>








</div>
</div>










































































<p>The DELETE command removes records from the table identified by the
   <a href="syntax/qualified-table-name.html">qualified-table-name</a>.

<p>If the WHERE clause is not present, all records in the table are deleted.
   If a WHERE clause is supplied, then only those rows for which the
   WHERE clause <a href="lang_expr.html#booleanexpr">boolean expression</a> is true are deleted.
   Rows for which the expression is false or NULL are retained.

<h3>Restrictions on DELETE Statements Within CREATE TRIGGER</h3>

<p>The following restrictions apply to DELETE statements that occur within the
   body of a <a href="lang_createtrigger.html">CREATE TRIGGER</a> statement:

<ul>
  <li><p>The <span class='yyterm'>table-name</span> specified as part of a 
    DELETE statement within
    a trigger body must be unqualified.  In other words, the
    <i>schema-name</i><b>.</b> prefix on the table name is not allowed 
    within triggers. If the table to which the trigger is attached is
    not in the temp database, then DELETE statements within the trigger
    body must operate on tables within the same database as it. If the table
    to which the trigger is attached is in the TEMP database, then the
    unqualified name of the table being deleted is resolved in the same way as
    it is for a top-level statement (by searching first the TEMP database, then
    the main database, then any other databases in the order they were
    attached).
    
  <li><p>The INDEXED BY and NOT INDEXED clauses are not allowed on DELETE
    statements within triggers.</p>

  <li><p>The LIMIT and ORDER BY clauses (described below) are unsupported for
    DELETE statements within triggers.</p>
</ul>

<h3>Optional LIMIT and ORDER BY clauses</h3>

<p>If SQLite is compiled with the <a href="compile.html#enable_update_delete_limit">SQLITE_ENABLE_UPDATE_DELETE_LIMIT</a>
compile-time option, then the syntax of the DELETE statement is
extended by the addition of optional ORDER BY and LIMIT clauses:</p>

<p><b><a href="syntax/delete-stmt-limited.html">delete-stmt-limited:</a></b></p><div class='imgcontainer'>
 <img alt="syntax diagram delete-stmt-limited" src="images/syntax/delete-stmt-limited.gif"></img>
 </div>


<p>If a DELETE statement has a LIMIT clause, the maximum number of rows that
will be deleted is found by evaluating the accompanying expression and casting
it to an integer value. If the result of the evaluating the LIMIT clause
cannot be losslessly converted to an integer value, it is an error. A 
negative LIMIT value is interpreted as "no limit". If the DELETE statement 
also has an OFFSET clause, then it is similarly evaluated and cast to an
integer value. Again, it is an error if the value cannot be losslessly
converted to an integer. If there is no OFFSET clause, or the calculated
integer value is negative, the effective OFFSET value is zero.

<p>If the DELETE statement has an ORDER BY clause, then all rows that would 
be deleted in the absence of the LIMIT clause are sorted according to the 
ORDER BY. The first <i>M</i> rows, where <i>M</i> is the value found by
evaluating the OFFSET clause expression, are skipped, and the following 
<i>N</i>, where <i>N</i> is the value of the LIMIT expression, are deleted.
If there are less than <i>N</i> rows remaining after taking the OFFSET clause
into account, or if the LIMIT clause evaluated to a negative value, then all
remaining rows are deleted.

<p>If the DELETE statement has no ORDER BY clause, then all rows that
would be deleted in the absence of the LIMIT clause are assembled in an
arbitrary order before applying the LIMIT and OFFSET clauses to determine 
the subset that are actually deleted.

<p>The ORDER BY clause on a DELETE statement is used only to determine which
rows fall within the LIMIT. The order in which rows are deleted is arbitrary
and is not influenced by the ORDER BY clause.

<a name="truncateopt"></a>

<h3>The Truncate Optimization</h3>

<p>When the WHERE is omitted from a DELETE statement and the table
being deleted has no triggers,
SQLite uses an optimization to erase the entire table content
without having to visit each row of the table individually.
This "truncate" optimization makes the delete run much faster.
Prior to SQLite <a href="releaselog/3_6_5.html">version 3.6.5</a> (2008-11-12), the truncate optimization
also meant that the <a href="c3ref/changes.html">sqlite3_changes()</a> and
<a href="c3ref/total_changes.html">sqlite3_total_changes()</a> interfaces
and the <a href="pragma.html#pragma_count_changes">count_changes pragma</a>
will not actually return the number of deleted rows.  
That problem has been fixed as of <a href="releaselog/3_6_5.html">version 3.6.5</a> (2008-11-12).

<p>The truncate optimization can be permanently disabled for all queries
by recompiling
SQLite with the <a href="compile.html#omit_truncate_optimization">SQLITE_OMIT_TRUNCATE_OPTIMIZATION</a> compile-time switch.</p>

<p>The truncate optimization can also be disabled at runtime using
the <a href="c3ref/set_authorizer.html">sqlite3_set_authorizer()</a> interface.  If an authorizer callback
returns <a href="c3ref/c_deny.html">SQLITE_IGNORE</a> for an <a href="c3ref/c_alter_table.html">SQLITE_DELETE</a> action code, then
the DELETE operation will proceed but the truncate optimization will
be bypassed and rows will be deleted one by one.</p>









>
>
>
>
>
>
>
>


>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>





|




|




|













|


|

|

|




















|








|




|





|













|









<
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405

<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x1621' onclick='hideorshow("x1621","x1622")'>show</button></p>
 <div id='x1622' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
</div>
</div>
<p><b><a href="syntax/type-name.html">type-name:</a></b>
<button id='x1623' onclick='hideorshow("x1623","x1624")'>show</button></p>
 <div id='x1624' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
<button id='x1625' onclick='hideorshow("x1625","x1626")'>show</button></p>
 <div id='x1626' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</div>
</div>
</div>
<p><b><a href="syntax/qualified-table-name.html">qualified-table-name:</a></b>
<button id='x1627' onclick='hideorshow("x1627","x1628")'>show</button></p>
 <div id='x1628' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram qualified-table-name" src="images/syntax/qualified-table-name.gif" />
</div>
<p><b><a href="syntax/with-clause.html">with-clause:</a></b>
<button id='x1629' onclick='hideorshow("x1629","x1630")'>show</button></p>
 <div id='x1630' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram with-clause" src="images/syntax/with-clause.gif" />
<p><b><a href="syntax/cte-table-name.html">cte-table-name:</a></b>
<button id='x1631' onclick='hideorshow("x1631","x1632")'>show</button></p>
 <div id='x1632' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram cte-table-name" src="images/syntax/cte-table-name.gif" />
</div>
<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
<button id='x1633' onclick='hideorshow("x1633","x1634")'>show</button></p>
 <div id='x1634' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntax/common-table-expression.html">common-table-expression:</a></b>
<button id='x1635' onclick='hideorshow("x1635","x1636")'>show</button></p>
 <div id='x1636' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
</div>
<p><b><a href="syntax/compound-operator.html">compound-operator:</a></b>
<button id='x1637' onclick='hideorshow("x1637","x1638")'>show</button></p>
 <div id='x1638' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</div>
<p><b><a href="syntax/join-clause.html">join-clause:</a></b>
<button id='x1639' onclick='hideorshow("x1639","x1640")'>show</button></p>
 <div id='x1640' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
<button id='x1641' onclick='hideorshow("x1641","x1642")'>show</button></p>
 <div id='x1642' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</div>
<p><b><a href="syntax/join-operator.html">join-operator:</a></b>
<button id='x1643' onclick='hideorshow("x1643","x1644")'>show</button></p>
 <div id='x1644' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</div>
</div>
<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
<button id='x1645' onclick='hideorshow("x1645","x1646")'>show</button></p>
 <div id='x1646' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</div>
<p><b><a href="syntax/result-column.html">result-column:</a></b>
<button id='x1647' onclick='hideorshow("x1647","x1648")'>show</button></p>
 <div id='x1648' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</div>
<p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
<button id='x1649' onclick='hideorshow("x1649","x1650")'>show</button></p>
 <div id='x1650' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</div>
<p><b><a href="syntax/window-defn.html">window-defn:</a></b>
<button id='x1651' onclick='hideorshow("x1651","x1652")'>show</button></p>
 <div id='x1652' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram window-defn" src="images/syntax/window-defn.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x1653' onclick='hideorshow("x1653","x1654")'>show</button></p>
 <div id='x1654' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
</div>
</div>
</div>
</div>


<p>The DELETE command removes records from the table identified by the
   <a href="syntax/qualified-table-name.html">qualified-table-name</a>.

</p><p>If the WHERE clause is not present, all records in the table are deleted.
   If a WHERE clause is supplied, then only those rows for which the
   WHERE clause <a href="lang_expr.html#booleanexpr">boolean expression</a> is true are deleted.
   Rows for which the expression is false or NULL are retained.

</p><h1 id="restrictions_on_delete_statements_within_create_trigger"><span>2. </span>Restrictions on DELETE Statements Within CREATE TRIGGER</h1>

<p>The following restrictions apply to DELETE statements that occur within the
   body of a <a href="lang_createtrigger.html">CREATE TRIGGER</a> statement:

</p><ul>
  <li><p>The <span class='yyterm'>table-name</span> specified as part of a 
    DELETE statement within
    a trigger body must be unqualified.  In other words, the
    <i>schema-name</i><b>.</b> prefix on the table name is not allowed 
    within triggers. If the table to which the trigger is attached is
    not in the temp database, then DELETE statements within the trigger
    body must operate on tables within the same database as it. If the table
    to which the trigger is attached is in the TEMP database, then the
    unqualified name of the table being deleted is resolved in the same way as
    it is for a top-level statement (by searching first the TEMP database, then
    the main database, then any other databases in the order they were
    attached).
    
  </p></li><li><p>The INDEXED BY and NOT INDEXED clauses are not allowed on DELETE
    statements within triggers.</p>

  </li><li><p>The LIMIT and ORDER BY clauses (described below) are unsupported for
    DELETE statements within triggers.</p>
</li></ul>

<h1 id="optional_limit_and_order_by_clauses"><span>3. </span>Optional LIMIT and ORDER BY clauses</h1>

<p>If SQLite is compiled with the <a href="compile.html#enable_update_delete_limit">SQLITE_ENABLE_UPDATE_DELETE_LIMIT</a>
compile-time option, then the syntax of the DELETE statement is
extended by the addition of optional ORDER BY and LIMIT clauses:</p>

<p><b><a href="syntax/delete-stmt-limited.html">delete-stmt-limited:</a></b></p><div class='imgcontainer'>
 <img alt="syntax diagram delete-stmt-limited" src="images/syntax/delete-stmt-limited.gif"></img>
 </div>


<p>If a DELETE statement has a LIMIT clause, the maximum number of rows that
will be deleted is found by evaluating the accompanying expression and casting
it to an integer value. If the result of the evaluating the LIMIT clause
cannot be losslessly converted to an integer value, it is an error. A 
negative LIMIT value is interpreted as "no limit". If the DELETE statement 
also has an OFFSET clause, then it is similarly evaluated and cast to an
integer value. Again, it is an error if the value cannot be losslessly
converted to an integer. If there is no OFFSET clause, or the calculated
integer value is negative, the effective OFFSET value is zero.

</p><p>If the DELETE statement has an ORDER BY clause, then all rows that would 
be deleted in the absence of the LIMIT clause are sorted according to the 
ORDER BY. The first <i>M</i> rows, where <i>M</i> is the value found by
evaluating the OFFSET clause expression, are skipped, and the following 
<i>N</i>, where <i>N</i> is the value of the LIMIT expression, are deleted.
If there are less than <i>N</i> rows remaining after taking the OFFSET clause
into account, or if the LIMIT clause evaluated to a negative value, then all
remaining rows are deleted.

</p><p>If the DELETE statement has no ORDER BY clause, then all rows that
would be deleted in the absence of the LIMIT clause are assembled in an
arbitrary order before applying the LIMIT and OFFSET clauses to determine 
the subset that are actually deleted.

</p><p>The ORDER BY clause on a DELETE statement is used only to determine which
rows fall within the LIMIT. The order in which rows are deleted is arbitrary
and is not influenced by the ORDER BY clause.

<a name="truncateopt"></a>

</p><h1 id="the_truncate_optimization"><span>4. </span>The Truncate Optimization</h1>

<p>When the WHERE is omitted from a DELETE statement and the table
being deleted has no triggers,
SQLite uses an optimization to erase the entire table content
without having to visit each row of the table individually.
This "truncate" optimization makes the delete run much faster.
Prior to SQLite <a href="releaselog/3_6_5.html">version 3.6.5</a> (2008-11-12), the truncate optimization
also meant that the <a href="c3ref/changes.html">sqlite3_changes()</a> and
<a href="c3ref/total_changes.html">sqlite3_total_changes()</a> interfaces
and the <a href="pragma.html#pragma_count_changes">count_changes pragma</a>
will not actually return the number of deleted rows.  
That problem has been fixed as of <a href="releaselog/3_6_5.html">version 3.6.5</a> (2008-11-12).

</p><p>The truncate optimization can be permanently disabled for all queries
by recompiling
SQLite with the <a href="compile.html#omit_truncate_optimization">SQLITE_OMIT_TRUNCATE_OPTIMIZATION</a> compile-time switch.</p>

<p>The truncate optimization can also be disabled at runtime using
the <a href="c3ref/set_authorizer.html">sqlite3_set_authorizer()</a> interface.  If an authorizer callback
returns <a href="c3ref/c_deny.html">SQLITE_IGNORE</a> for an <a href="c3ref/c_alter_table.html">SQLITE_DELETE</a> action code, then
the DELETE operation will proceed but the truncate optimization will
be bypassed and rows will be deleted one by one.</p>


Changes to Doc/Extra/Core/lang_detach.html.
1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>SQLite Query Language: DETACH DATABASE</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>





|







1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>DETACH</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93










94
95
96
97
98
99
100
101
102
103
104
105
106


107
108
109
110
111
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>










<div class=nosearch><h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>DETACH DATABASE</h2></div><p><b><a href="syntax/detach-stmt.html">detach-stmt:</a></b>
<button id='x1623' onclick='hideorshow("x1623","x1624")'>hide</button></p>
 <div id='x1624' class='imgcontainer'>
 <img alt="syntax diagram detach-stmt" src="images/syntax/detach-stmt.gif" />
</div>


<p>This statement detaches an additional database connection previously 
attached using the <a href="lang_attach.html">ATTACH</a> statement.  
When not in <a href="sharedcache.html">shared cache mode</a>, 
it is possible to have the same database file attached multiple times using 
different names, and detaching one connection to a file will leave the 
others intact.</p>


In <a href="sharedcache.html">shared cache mode</a>, attempting to attach the same database file more
than once results in an error.










|

















>
>
>
>
>
>
>
>
>
>
|
|
|










>
>


|
<
<
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121


}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<div class=fancy>
<div class=nosearch>
<div class="fancy_title">
DETACH
</div>
</div>




<p><b><a href="syntax/detach-stmt.html">detach-stmt:</a></b>
<button id='x1655' onclick='hideorshow("x1655","x1656")'>hide</button></p>
 <div id='x1656' class='imgcontainer'>
 <img alt="syntax diagram detach-stmt" src="images/syntax/detach-stmt.gif" />
</div>


<p>This statement detaches an additional database connection previously 
attached using the <a href="lang_attach.html">ATTACH</a> statement.  
When not in <a href="sharedcache.html">shared cache mode</a>, 
it is possible to have the same database file attached multiple times using 
different names, and detaching one connection to a file will leave the 
others intact.</p>

<p>
In <a href="sharedcache.html">shared cache mode</a>, attempting to attach the same database file more
than once results in an error.
</p>


Changes to Doc/Extra/Core/lang_dropindex.html.
1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>SQLite Query Language: DROP INDEX</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>





|







1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>DROP INDEX</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93










94
95
96
97
98
99
100
101
102
103
104
105
106
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>










<div class=nosearch><h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>DROP INDEX</h2></div><p><b><a href="syntax/drop-index-stmt.html">drop-index-stmt:</a></b>
<button id='x1625' onclick='hideorshow("x1625","x1626")'>hide</button></p>
 <div id='x1626' class='imgcontainer'>
 <img alt="syntax diagram drop-index-stmt" src="images/syntax/drop-index-stmt.gif" />
</div>


<p>The DROP INDEX statement removes an index added
with the <a href="lang_createindex.html">CREATE INDEX</a> statement.  The index is completely removed from
the disk.  The only way to recover the index is to reenter the
appropriate <a href="lang_createindex.html">CREATE INDEX</a> command.</p>









|

















>
>
>
>
>
>
>
>
>
>
|
|
|










69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<div class=fancy>
<div class=nosearch>
<div class="fancy_title">
DROP INDEX
</div>
</div>




<p><b><a href="syntax/drop-index-stmt.html">drop-index-stmt:</a></b>
<button id='x1657' onclick='hideorshow("x1657","x1658")'>hide</button></p>
 <div id='x1658' class='imgcontainer'>
 <img alt="syntax diagram drop-index-stmt" src="images/syntax/drop-index-stmt.gif" />
</div>


<p>The DROP INDEX statement removes an index added
with the <a href="lang_createindex.html">CREATE INDEX</a> statement.  The index is completely removed from
the disk.  The only way to recover the index is to reenter the
appropriate <a href="lang_createindex.html">CREATE INDEX</a> command.</p>


Changes to Doc/Extra/Core/lang_droptable.html.
1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>SQLite Query Language: DROP TABLE</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>





|







1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>DROP TABLE</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93










94
95
96
97
98
99
100
101
102
103
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>










<div class=nosearch><h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>DROP TABLE</h2></div><p><b><a href="syntax/drop-table-stmt.html">drop-table-stmt:</a></b>
<button id='x1627' onclick='hideorshow("x1627","x1628")'>hide</button></p>
 <div id='x1628' class='imgcontainer'>
 <img alt="syntax diagram drop-table-stmt" src="images/syntax/drop-table-stmt.gif" />
</div>


<p>The DROP TABLE statement removes a table added with the
<a href="lang_createtable.html">CREATE TABLE</a> statement.  The name specified is the
table name.  The dropped table is completely removed from the database 







|

















>
>
>
>
>
>
>
>
>
>
|
|
|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<div class=fancy>
<div class=nosearch>
<div class="fancy_title">
DROP TABLE
</div>
</div>




<p><b><a href="syntax/drop-table-stmt.html">drop-table-stmt:</a></b>
<button id='x1659' onclick='hideorshow("x1659","x1660")'>hide</button></p>
 <div id='x1660' class='imgcontainer'>
 <img alt="syntax diagram drop-table-stmt" src="images/syntax/drop-table-stmt.gif" />
</div>


<p>The DROP TABLE statement removes a table added with the
<a href="lang_createtable.html">CREATE TABLE</a> statement.  The name specified is the
table name.  The dropped table is completely removed from the database 
118
119
120
121
122
123
124
125
126
If the implicit DELETE FROM executed
as part of a DROP TABLE command violates any immediate foreign key constraints,
an error is returned and the table is not dropped. If 
the implicit DELETE FROM causes any 
deferred foreign key constraints to be violated, and the violations still
exist when the transaction is committed, an error is returned at the time
of commit.









|
<
128
129
130
131
132
133
134
135

If the implicit DELETE FROM executed
as part of a DROP TABLE command violates any immediate foreign key constraints,
an error is returned and the table is not dropped. If 
the implicit DELETE FROM causes any 
deferred foreign key constraints to be violated, and the violations still
exist when the transaction is committed, an error is returned at the time
of commit.
</p>

Changes to Doc/Extra/Core/lang_droptrigger.html.
1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>SQLite Query Language: DROP TRIGGER</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>





|







1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>DROP TRIGGER</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>



<div class=nosearch><h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>DROP TRIGGER</h2></div><p><b><a href="syntax/drop-trigger-stmt.html">drop-trigger-stmt:</a></b>
<button id='x1629' onclick='hideorshow("x1629","x1630")'>hide</button></p>
 <div id='x1630' class='imgcontainer'>
 <img alt="syntax diagram drop-trigger-stmt" src="images/syntax/drop-trigger-stmt.gif" />
</div>


<p>The DROP TRIGGER statement removes a trigger created by the 
<a href="lang_createtrigger.html">CREATE TRIGGER</a> statement. Once removed, the trigger definition is no
longer present in the sqlite_master (or sqlite_temp_master) table and is
not fired by any subsequent INSERT, UPDATE or DELETE statements.

<p>Note that triggers are automatically dropped when the associated table is
dropped.









|

















>
>
>
|
|
|












<
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111

}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>



<p><b><a href="syntax/drop-trigger-stmt.html">drop-trigger-stmt:</a></b>
<button id='x1661' onclick='hideorshow("x1661","x1662")'>hide</button></p>
 <div id='x1662' class='imgcontainer'>
 <img alt="syntax diagram drop-trigger-stmt" src="images/syntax/drop-trigger-stmt.gif" />
</div>


<p>The DROP TRIGGER statement removes a trigger created by the 
<a href="lang_createtrigger.html">CREATE TRIGGER</a> statement. Once removed, the trigger definition is no
longer present in the sqlite_master (or sqlite_temp_master) table and is
not fired by any subsequent INSERT, UPDATE or DELETE statements.

<p>Note that triggers are automatically dropped when the associated table is
dropped.


Changes to Doc/Extra/Core/lang_dropview.html.
1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>SQLite Query Language: DROP VIEW</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>





|







1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>DROP VIEW</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93










94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>










<div class=nosearch><h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>DROP VIEW</h2></div><p><b><a href="syntax/drop-view-stmt.html">drop-view-stmt:</a></b>
<button id='x1631' onclick='hideorshow("x1631","x1632")'>hide</button></p>
 <div id='x1632' class='imgcontainer'>
 <img alt="syntax diagram drop-view-stmt" src="images/syntax/drop-view-stmt.gif" />
</div>


<p>The DROP VIEW statement removes a view created by the <a href="lang_createview.html">CREATE VIEW</a> 
  statement. The view definition is removed from the database schema, but 
  no actual data in the underlying base tables is modified.

<p>The view to drop is identified by the view-name and optional 
  schema-name specified as part of the DROP VIEW statement. This 
  reference is resolved using the standard procedure for <a href="lang_naming.html">object resolution</a>.

<p>
  If the specified view cannot be found and the IF EXISTS clause is not 
  present, it is an error. If the specified view cannot be found and an IF
  EXISTS clause is present in the DROP VIEW statement, then the statement
  is a no-op.










|

















>
>
>
>
>
>
>
>
>
>
|
|
|








|



|






|
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<div class=fancy>
<div class=nosearch>
<div class="fancy_title">
DROP VIEW
</div>
</div>




<p><b><a href="syntax/drop-view-stmt.html">drop-view-stmt:</a></b>
<button id='x1663' onclick='hideorshow("x1663","x1664")'>hide</button></p>
 <div id='x1664' class='imgcontainer'>
 <img alt="syntax diagram drop-view-stmt" src="images/syntax/drop-view-stmt.gif" />
</div>


<p>The DROP VIEW statement removes a view created by the <a href="lang_createview.html">CREATE VIEW</a> 
  statement. The view definition is removed from the database schema, but 
  no actual data in the underlying base tables is modified.

</p><p>The view to drop is identified by the view-name and optional 
  schema-name specified as part of the DROP VIEW statement. This 
  reference is resolved using the standard procedure for <a href="lang_naming.html">object resolution</a>.

</p><p>
  If the specified view cannot be found and the IF EXISTS clause is not 
  present, it is an error. If the specified view cannot be found and an IF
  EXISTS clause is present in the DROP VIEW statement, then the statement
  is a no-op.


</p>
Changes to Doc/Extra/Core/lang_explain.html.
1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>SQLite Query Language: EXPLAIN</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>





|







1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>EXPLAIN</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93











94
95
96
97


98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>











<div class=nosearch><h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>EXPLAIN</h2></div><p><b><a href="syntax/sql-stmt.html">sql-stmt:</a></b></p><div class='imgcontainer'>
 <img alt="syntax diagram sql-stmt" src="images/syntax/sql-stmt.gif"></img>
 </div>




<p>An SQL statement can be preceded by the keyword "EXPLAIN" or
by the phrase "EXPLAIN QUERY PLAN".  Either modification causes the
SQL statement to behave as a query and to return information about
how the SQL statement would have operated if the EXPLAIN keyword or
phrase had been omitted.</p>

<p>The output from EXPLAIN and EXPLAIN QUERY PLAN is intended for
interactive analysis and troubleshooting only.  The details of the 
output format are subject to change from one release of SQLite to the next.
Applications should not use EXPLAIN or EXPLAIN QUERY PLAN since
their exact behavior is variable and only partially documented.</p>

<p>When the EXPLAIN keyword appears by itself it causes the statement
to behave as a query that returns the sequence of 
<a href="opcode.html">virtual machine instructions</a> it would have used to execute the command had
the EXPLAIN keyword not been present. When the EXPLAIN QUERY PLAN phrase
appears, the statement returns high-level information regarding the query
plan that would have been used.

<p>The EXPLAIN QUERY PLAN command is described in 
<a href="eqp.html">more detail here</a>.

<h3>EXPLAIN operates at run-time, not at prepare-time</h3>

<p>The EXPLAIN and EXPLAIN QUERY PLAN prefixes affect the behavior of
running a <a href="c3ref/stmt.html">prepared statement</a> using <a href="c3ref/step.html">sqlite3_step()</a>.  The process of
generating a new prepared statement using <a href="c3ref/prepare.html">sqlite3_prepare()</a> or similar
is (mostly) unaffected by EXPLAIN.  (The exception to the previous sentence
is that some special opcodes used by EXPLAIN QUERY PLAN are omitted when
building an EXPLAIN QUERY PLAN prepared statement, as a performance
optimization.)

<p>This means that actions that occur during sqlite3_prepare() are
unaffected by EXPLAIN.

<ul>
<li><p>
Some <a href="pragma.html#syntax">PRAGMA</a> statements do their work during sqlite3_prepare() rather
than during sqlite3_step().  Those PRAGMA statements are unaffected
by EXPLAIN.  They operate the same with or without the EXPLAIN prefix.
The set of PRAGMA statements that are unaffected by EXPLAIN can vary
from one release to the next.  Some PRAGMA statements operate during
sqlite3_prepare() depending on their arguments.  For consistent
results, avoid using EXPLAIN on PRAGMA statements.

<li><p>
The <a href="c3ref/set_authorizer.html">authorizer callback</a> is invoked regardless of the presence of
EXPLAIN or EXPLAIN QUERY PLAN.
</ul>








|

















>
>
>
>
>
>
>
>
>
>
>
|



>
>




















|


|









|


|









|


|

69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<div class=fancy>
<div class=nosearch>
<div class="fancy_title">
EXPLAIN
</div>
</div>




<h1 id="syntax"><span>1. </span>Syntax</h1>
<p><b><a href="syntax/sql-stmt.html">sql-stmt:</a></b></p><div class='imgcontainer'>
 <img alt="syntax diagram sql-stmt" src="images/syntax/sql-stmt.gif"></img>
 </div>


<h1 id="description"><span>2. </span>Description</h1>

<p>An SQL statement can be preceded by the keyword "EXPLAIN" or
by the phrase "EXPLAIN QUERY PLAN".  Either modification causes the
SQL statement to behave as a query and to return information about
how the SQL statement would have operated if the EXPLAIN keyword or
phrase had been omitted.</p>

<p>The output from EXPLAIN and EXPLAIN QUERY PLAN is intended for
interactive analysis and troubleshooting only.  The details of the 
output format are subject to change from one release of SQLite to the next.
Applications should not use EXPLAIN or EXPLAIN QUERY PLAN since
their exact behavior is variable and only partially documented.</p>

<p>When the EXPLAIN keyword appears by itself it causes the statement
to behave as a query that returns the sequence of 
<a href="opcode.html">virtual machine instructions</a> it would have used to execute the command had
the EXPLAIN keyword not been present. When the EXPLAIN QUERY PLAN phrase
appears, the statement returns high-level information regarding the query
plan that would have been used.

</p><p>The EXPLAIN QUERY PLAN command is described in 
<a href="eqp.html">more detail here</a>.

</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>

<p>The EXPLAIN and EXPLAIN QUERY PLAN prefixes affect the behavior of
running a <a href="c3ref/stmt.html">prepared statement</a> using <a href="c3ref/step.html">sqlite3_step()</a>.  The process of
generating a new prepared statement using <a href="c3ref/prepare.html">sqlite3_prepare()</a> or similar
is (mostly) unaffected by EXPLAIN.  (The exception to the previous sentence
is that some special opcodes used by EXPLAIN QUERY PLAN are omitted when
building an EXPLAIN QUERY PLAN prepared statement, as a performance
optimization.)

</p><p>This means that actions that occur during sqlite3_prepare() are
unaffected by EXPLAIN.

</p><ul>
<li><p>
Some <a href="pragma.html#syntax">PRAGMA</a> statements do their work during sqlite3_prepare() rather
than during sqlite3_step().  Those PRAGMA statements are unaffected
by EXPLAIN.  They operate the same with or without the EXPLAIN prefix.
The set of PRAGMA statements that are unaffected by EXPLAIN can vary
from one release to the next.  Some PRAGMA statements operate during
sqlite3_prepare() depending on their arguments.  For consistent
results, avoid using EXPLAIN on PRAGMA statements.

</p></li><li><p>
The <a href="c3ref/set_authorizer.html">authorizer callback</a> is invoked regardless of the presence of
EXPLAIN or EXPLAIN QUERY PLAN.
</p></li></ul>

Changes to Doc/Extra/Core/lang_expr.html.
1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>SQLite Query Language: expression</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>





|







1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>SQL Langauge Expressions</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93















































94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>















































<div class=nosearch><h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>expression</h2></div><p><b><a href="syntax/expr.html">expr:</a></b>
<button id='x1633' onclick='hideorshow("x1633","x1634")'>hide</button></p>
 <div id='x1634' class='imgcontainer'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntax/filter-clause.html">filter-clause:</a></b>
<button id='x1635' onclick='hideorshow("x1635","x1636")'>show</button></p>
 <div id='x1636' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram filter-clause" src="images/syntax/filter-clause.gif" />
</div>
<p><b><a href="syntax/literal-value.html">literal-value:</a></b>
<button id='x1637' onclick='hideorshow("x1637","x1638")'>show</button></p>
 <div id='x1638' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</div>
<p><b><a href="syntax/over-clause.html">over-clause:</a></b>
<button id='x1639' onclick='hideorshow("x1639","x1640")'>show</button></p>
 <div id='x1640' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram over-clause" src="images/syntax/over-clause.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x1641' onclick='hideorshow("x1641","x1642")'>show</button></p>
 <div id='x1642' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
<button id='x1643' onclick='hideorshow("x1643","x1644")'>show</button></p>
 <div id='x1644' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</div>
</div>
<p><b><a href="syntax/raise-function.html">raise-function:</a></b>
<button id='x1645' onclick='hideorshow("x1645","x1646")'>show</button></p>
 <div id='x1646' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</div>
<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
<button id='x1647' onclick='hideorshow("x1647","x1648")'>show</button></p>
 <div id='x1648' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntax/common-table-expression.html">common-table-expression:</a></b>
<button id='x1649' onclick='hideorshow("x1649","x1650")'>show</button></p>
 <div id='x1650' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
</div>
<p><b><a href="syntax/compound-operator.html">compound-operator:</a></b>
<button id='x1651' onclick='hideorshow("x1651","x1652")'>show</button></p>
 <div id='x1652' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</div>
<p><b><a href="syntax/join-clause.html">join-clause:</a></b>
<button id='x1653' onclick='hideorshow("x1653","x1654")'>show</button></p>
 <div id='x1654' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
<button id='x1655' onclick='hideorshow("x1655","x1656")'>show</button></p>
 <div id='x1656' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</div>
<p><b><a href="syntax/join-operator.html">join-operator:</a></b>
<button id='x1657' onclick='hideorshow("x1657","x1658")'>show</button></p>
 <div id='x1658' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</div>
</div>
<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
<button id='x1659' onclick='hideorshow("x1659","x1660")'>show</button></p>
 <div id='x1660' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</div>
<p><b><a href="syntax/result-column.html">result-column:</a></b>
<button id='x1661' onclick='hideorshow("x1661","x1662")'>show</button></p>
 <div id='x1662' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</div>
<p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
<button id='x1663' onclick='hideorshow("x1663","x1664")'>show</button></p>
 <div id='x1664' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</div>
<p><b><a href="syntax/window-defn.html">window-defn:</a></b>
<button id='x1665' onclick='hideorshow("x1665","x1666")'>show</button></p>
 <div id='x1666' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram window-defn" src="images/syntax/window-defn.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x1667' onclick='hideorshow("x1667","x1668")'>show</button></p>
 <div id='x1668' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
</div>
</div>
<p><b><a href="syntax/type-name.html">type-name:</a></b>
<button id='x1669' onclick='hideorshow("x1669","x1670")'>show</button></p>
 <div id='x1670' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
<button id='x1671' onclick='hideorshow("x1671","x1672")'>show</button></p>
 <div id='x1672' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</div>
</div>
</div>


<p>This section is different from the others.  Most other sections of
this document talks about a particular SQL command.  This section does
not talk about a standalone command but about "expressions" which are 
subcomponents of most other commands.</p>

<a name="binaryops"></a>

<h3>Operators</h3>
<p>SQLite understands the following binary operators, in order from
highest to lowest precedence:</p>

<blockquote><pre>
<font color="#2c2cf0"><big>||
*    /    %
+    -







|

















>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
|


|
|



|
|



|
|


|
|



|
|




|
|



|
|


|
|



|
|



|
|


|
|



|
|




|
|



|
|



|
|



|
|


|
|





|
|


|
|






<
<
<
<
<


|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242





243
244
245
246
247
248
249
250
251
252
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<div class=fancy>
<div class=nosearch>
<div class="fancy_title">
SQL Langauge Expressions
</div>
<div class="fancy_toc">
<a onclick="toggle_toc()">
<span class="fancy_toc_mark" id="toc_mk">&#x25ba;</span>
Table Of Contents
</a>
<div id="toc_sub"><div class="fancy-toc1"><a href="#syntax">1. Syntax</a></div>
<div class="fancy-toc1"><a href="#operators">2. Operators</a></div>
<div class="fancy-toc1"><a href="#literal_values_constants_">3. Literal Values (Constants)</a></div>
<div class="fancy-toc1"><a href="#parameters">4. Parameters</a></div>
<div class="fancy-toc1"><a href="#the_like_glob_regexp_and_match_operators">5. The LIKE, GLOB, REGEXP, and MATCH operators</a></div>
<div class="fancy-toc1"><a href="#the_between_operator">6. The BETWEEN operator</a></div>
<div class="fancy-toc1"><a href="#the_case_expression">7. The CASE expression</a></div>
<div class="fancy-toc1"><a href="#the_in_and_not_in_operators">8. The IN and NOT IN operators</a></div>
<div class="fancy-toc1"><a href="#table_column_names">9. Table Column Names</a></div>
<div class="fancy-toc1"><a href="#the_exists_operator">10. The EXISTS operator</a></div>
<div class="fancy-toc1"><a href="#subquery_expressions">11. Subquery Expressions</a></div>
<div class="fancy-toc1"><a href="#correlated_subqueries">12. Correlated Subqueries</a></div>
<div class="fancy-toc1"><a href="#cast_expressions">13. CAST expressions</a></div>
<div class="fancy-toc1"><a href="#boolean_expressions">14. Boolean Expressions</a></div>
<div class="fancy-toc1"><a href="#functions">15. Functions</a></div>
</div>
</div>
<script>
function toggle_toc(){
var sub = document.getElementById("toc_sub")
var mk = document.getElementById("toc_mk")
if( sub.style.display!="block" ){
sub.style.display = "block";
mk.innerHTML = "&#x25bc;";
} else {
sub.style.display = "none";
mk.innerHTML = "&#x25ba;";
}
}
</script>
</div>




<h1 id="syntax"><span>1. </span>Syntax</h1>

<p><b><a href="syntax/expr.html">expr:</a></b>
<button id='x1665' onclick='hideorshow("x1665","x1666")'>hide</button></p>
 <div id='x1666' class='imgcontainer'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntax/filter-clause.html">filter-clause:</a></b>
<button id='x1667' onclick='hideorshow("x1667","x1668")'>show</button></p>
 <div id='x1668' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram filter-clause" src="images/syntax/filter-clause.gif" />
</div>
<p><b><a href="syntax/literal-value.html">literal-value:</a></b>
<button id='x1669' onclick='hideorshow("x1669","x1670")'>show</button></p>
 <div id='x1670' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</div>
<p><b><a href="syntax/over-clause.html">over-clause:</a></b>
<button id='x1671' onclick='hideorshow("x1671","x1672")'>show</button></p>
 <div id='x1672' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram over-clause" src="images/syntax/over-clause.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x1673' onclick='hideorshow("x1673","x1674")'>show</button></p>
 <div id='x1674' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
<button id='x1675' onclick='hideorshow("x1675","x1676")'>show</button></p>
 <div id='x1676' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</div>
</div>
<p><b><a href="syntax/raise-function.html">raise-function:</a></b>
<button id='x1677' onclick='hideorshow("x1677","x1678")'>show</button></p>
 <div id='x1678' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</div>
<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
<button id='x1679' onclick='hideorshow("x1679","x1680")'>show</button></p>
 <div id='x1680' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntax/common-table-expression.html">common-table-expression:</a></b>
<button id='x1681' onclick='hideorshow("x1681","x1682")'>show</button></p>
 <div id='x1682' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
</div>
<p><b><a href="syntax/compound-operator.html">compound-operator:</a></b>
<button id='x1683' onclick='hideorshow("x1683","x1684")'>show</button></p>
 <div id='x1684' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</div>
<p><b><a href="syntax/join-clause.html">join-clause:</a></b>
<button id='x1685' onclick='hideorshow("x1685","x1686")'>show</button></p>
 <div id='x1686' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
<button id='x1687' onclick='hideorshow("x1687","x1688")'>show</button></p>
 <div id='x1688' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</div>
<p><b><a href="syntax/join-operator.html">join-operator:</a></b>
<button id='x1689' onclick='hideorshow("x1689","x1690")'>show</button></p>
 <div id='x1690' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</div>
</div>
<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
<button id='x1691' onclick='hideorshow("x1691","x1692")'>show</button></p>
 <div id='x1692' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</div>
<p><b><a href="syntax/result-column.html">result-column:</a></b>
<button id='x1693' onclick='hideorshow("x1693","x1694")'>show</button></p>
 <div id='x1694' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</div>
<p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
<button id='x1695' onclick='hideorshow("x1695","x1696")'>show</button></p>
 <div id='x1696' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</div>
<p><b><a href="syntax/window-defn.html">window-defn:</a></b>
<button id='x1697' onclick='hideorshow("x1697","x1698")'>show</button></p>
 <div id='x1698' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram window-defn" src="images/syntax/window-defn.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x1699' onclick='hideorshow("x1699","x1700")'>show</button></p>
 <div id='x1700' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
</div>
</div>
<p><b><a href="syntax/type-name.html">type-name:</a></b>
<button id='x1701' onclick='hideorshow("x1701","x1702")'>show</button></p>
 <div id='x1702' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
<button id='x1703' onclick='hideorshow("x1703","x1704")'>show</button></p>
 <div id='x1704' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</div>
</div>
</div>







<a name="binaryops"></a>

<h1 id="operators"><span>2. </span>Operators</h1>
<p>SQLite understands the following binary operators, in order from
highest to lowest precedence:</p>

<blockquote><pre>
<font color="#2c2cf0"><big>||
*    /    %
+    -
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
IS operator evaluates to 1 (true) and the IS NOT operator evaluates
to 0 (false). If one operand is NULL and the other is not, then the
IS operator evaluates to 0 (false) and the IS NOT operator is 1 (true).
It is not possible for an IS or IS NOT expression to evaluate to NULL.
Operators <font color="#2c2cf0"><big>IS</big></font> and <font color="#2c2cf0"><big>IS NOT</big></font> have the same 
precedence as <font color="#2c2cf0"><big>=</big></font>.<a name="litvalue"></a>

<h3>Literal Values (Constants)</h3>
<p>
A literal value represents a constant.
Literal values may be integers, floating point numbers, strings,
BLOBs, or NULLs.
<p>
The syntax for integer and floating point literals (collectively
"numeric literals") is shown by the following diagram:</p>

<p><b><a href="syntax/numeric-literal.html">numeric-literal:</a></b></p><div class='imgcontainer'>
 <img alt="syntax diagram numeric-literal" src="images/syntax/numeric-literal.gif"></img>
 </div>








|




|







304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
IS operator evaluates to 1 (true) and the IS NOT operator evaluates
to 0 (false). If one operand is NULL and the other is not, then the
IS operator evaluates to 0 (false) and the IS NOT operator is 1 (true).
It is not possible for an IS or IS NOT expression to evaluate to NULL.
Operators <font color="#2c2cf0"><big>IS</big></font> and <font color="#2c2cf0"><big>IS NOT</big></font> have the same 
precedence as <font color="#2c2cf0"><big>=</big></font>.<a name="litvalue"></a>

</p><h1 id="literal_values_constants_"><span>3. </span>Literal Values (Constants)</h1>
<p>
A literal value represents a constant.
Literal values may be integers, floating point numbers, strings,
BLOBs, or NULLs.
</p><p>
The syntax for integer and floating point literals (collectively
"numeric literals") is shown by the following diagram:</p>

<p><b><a href="syntax/numeric-literal.html">numeric-literal:</a></b></p><div class='imgcontainer'>
 <img alt="syntax diagram numeric-literal" src="images/syntax/numeric-literal.gif"></img>
 </div>

290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
The "." character is always used 
as the decimal point even if the locale setting specifies "," for
this role - the use of "," for the decimal point would result in
syntactic ambiguity.

<a name="hexint"></a>

<p>Hexadecimal integer literals follow the C-language notation of
"0x" or "0X" followed by hexadecimal digits.
For example, 0x1234 means the same as 4660
and 0x8000000000000000 means the same as -9223372036854775808.
 Hexadecimal integer literals are interpreted as 64-bit
two's-complement integers and are thus limited
to sixteen significant digits of precision.
Support for hexadecimal integers was added to SQLite







|







332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
The "." character is always used 
as the decimal point even if the locale setting specifies "," for
this role - the use of "," for the decimal point would result in
syntactic ambiguity.

<a name="hexint"></a>

</p><p>Hexadecimal integer literals follow the C-language notation of
"0x" or "0X" followed by hexadecimal digits.
For example, 0x1234 means the same as 4660
and 0x8000000000000000 means the same as -9223372036854775808.
 Hexadecimal integer literals are interpreted as 64-bit
two's-complement integers and are thus limited
to sixteen significant digits of precision.
Support for hexadecimal integers was added to SQLite
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
string value in the format of a hexadecimal integer into an integer
value, the conversion process stops when the 'x' character is seen
so the resulting integer value is always zero.
SQLite only understands the hexadecimal integer notation when it
appears in the SQL statement text, not when it appears as
part of the content of the database.

<p> A string constant is formed by enclosing the
string in single quotes (').  A single quote within the string can
be encoded by putting two single quotes in a row - as in Pascal.
C-style escapes using the backslash character are not supported because
they are not standard SQL.

<p> BLOB literals are string literals containing hexadecimal data and
preceded by a single "x" or "X" character.  Example: X'53514C697465'

<p>
A literal value can also be the token "NULL".
</p>

<a name="varparam"></a>

<h3>Parameters</h3>
<p>
A "variable" or "parameter" token
specifies a placeholder in the expression for a 
value that is filled in at runtime using the
<a href="c3ref/bind_blob.html">sqlite3_bind()</a> family of C/C++ interfaces.
Parameters can take several forms:
</p>







|





|


|





|







357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
string value in the format of a hexadecimal integer into an integer
value, the conversion process stops when the 'x' character is seen
so the resulting integer value is always zero.
SQLite only understands the hexadecimal integer notation when it
appears in the SQL statement text, not when it appears as
part of the content of the database.

</p><p> A string constant is formed by enclosing the
string in single quotes (').  A single quote within the string can
be encoded by putting two single quotes in a row - as in Pascal.
C-style escapes using the backslash character are not supported because
they are not standard SQL.

</p><p> BLOB literals are string literals containing hexadecimal data and
preceded by a single "x" or "X" character.  Example: X'53514C697465'

</p><p>
A literal value can also be the token "NULL".
</p>

<a name="varparam"></a>

<h1 id="parameters"><span>4. </span>Parameters</h1>
<p>
A "variable" or "parameter" token
specifies a placeholder in the expression for a 
value that is filled in at runtime using the
<a href="c3ref/bind_blob.html">sqlite3_bind()</a> family of C/C++ interfaces.
Parameters can take several forms:
</p>
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
the <a href="limits.html#max_variable_number">SQLITE_MAX_VARIABLE_NUMBER</a> macro.  An individual <a href="c3ref/sqlite3.html">database connection</a>
D can reduce its maximum parameter number below the compile-time maximum
using the <a href="c3ref/limit.html">sqlite3_limit</a>(D, <a href="c3ref/c_limit_attached.html#sqlitelimitvariablenumber">SQLITE_LIMIT_VARIABLE_NUMBER</a>,...) interface.
</p>

<a name="like"></a>

<h3>The LIKE, GLOB, REGEXP, and MATCH operators</h3>
<p>The LIKE operator does a pattern matching comparison. The operand
to the right of the LIKE operator contains the pattern and the left hand
operand contains the string to match against the pattern.

A percent symbol ("%") in the LIKE pattern matches any
sequence of zero or more characters in the string.  An underscore
("_") in the LIKE pattern matches any single character in the







|







442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
the <a href="limits.html#max_variable_number">SQLITE_MAX_VARIABLE_NUMBER</a> macro.  An individual <a href="c3ref/sqlite3.html">database connection</a>
D can reduce its maximum parameter number below the compile-time maximum
using the <a href="c3ref/limit.html">sqlite3_limit</a>(D, <a href="c3ref/c_limit_attached.html#sqlitelimitvariablenumber">SQLITE_LIMIT_VARIABLE_NUMBER</a>,...) interface.
</p>

<a name="like"></a>

<h1 id="the_like_glob_regexp_and_match_operators"><span>5. </span>The LIKE, GLOB, REGEXP, and MATCH operators</h1>
<p>The LIKE operator does a pattern matching comparison. The operand
to the right of the LIKE operator contains the pattern and the left hand
operand contains the string to match against the pattern.

A percent symbol ("%") in the LIKE pattern matches any
sequence of zero or more characters in the string.  An underscore
("_") in the LIKE pattern matches any single character in the
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
a single character. This character may be used in the LIKE pattern
to include literal percent or underscore characters. The escape
character followed by a percent symbol (%), underscore (_), or a second
instance of the escape character itself matches a
literal percent symbol, underscore, or a single escape character,
respectively.

<p>The infix LIKE operator is implemented by calling the
application-defined SQL functions <a href="lang_corefunc.html#like">like(<i>Y</i>,<i>X</i>)</a> or
<a href="lang_corefunc.html#like">like(<i>Y</i>,<i>X</i>,<i>Z</i>)</a></a>.</p>

<p>The LIKE operator can be made case sensitive using the
<a href="pragma.html#pragma_case_sensitive_like">case_sensitive_like pragma</a>.</p>

<a name="glob"></a>

<p>The GLOB operator is similar to LIKE but uses the Unix







|

|







471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
a single character. This character may be used in the LIKE pattern
to include literal percent or underscore characters. The escape
character followed by a percent symbol (%), underscore (_), or a second
instance of the escape character itself matches a
literal percent symbol, underscore, or a single escape character,
respectively.

</p><p>The infix LIKE operator is implemented by calling the
application-defined SQL functions <a href="lang_corefunc.html#like">like(<i>Y</i>,<i>X</i>)</a> or
<a href="lang_corefunc.html#like">like(<i>Y</i>,<i>X</i>,<i>Z</i>)</a>.</p>

<p>The LIKE operator can be made case sensitive using the
<a href="pragma.html#pragma_case_sensitive_like">case_sensitive_like pragma</a>.</p>

<a name="glob"></a>

<p>The GLOB operator is similar to LIKE but uses the Unix
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488

489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514


515
516
517
518
519
520
521
522
523
524
525
526
527
528






529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680

681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773

774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
application-defined function.  The default match() function implementation
raises an exception and is not really useful for anything.
But extensions can override the match() function with more
helpful logic.</p>

<a name="between"></a>

<h3>The BETWEEN operator</h3>
<p>The BETWEEN operator is logically equivalent to a pair of comparisons.
"<i>x</i> <b>BETWEEN</b> <i>y</i> <b>AND</b> <i>z</i>" is 
equivalent to 
"<i>x</i><b>&gt;=</b><i>y</i> <b>AND</b> <i>x</i><b>&lt;=</b><i>z</i>" except
that with BETWEEN, the <i>x</i> expression is only evaluated once.
The precedence of the BETWEEN operator is the same as the precedence
as operators <b>==</b> and <b>!=</b> and <b>LIKE</b> and groups left to right.

<a name="case"></a>

<h3>The CASE expression</h3>
<p>A CASE expression serves a role similar to IF-THEN-ELSE in other
programming languages.  

<p>The optional expression that occurs in between the CASE keyword and the
first WHEN keyword is called the "base" expression. There are two basic forms

of the CASE expression: those with a base expression and those without.

<p>In a CASE without a base expression, each WHEN expression is evaluated
and the result treated as a boolean, starting with the leftmost and continuing
to the right. The result of the CASE expression is the evaluation of the THEN
expression that corresponds to the first WHEN expression that evaluates to
true. Or, if none of the WHEN expressions evaluate to true, the result of
evaluating the ELSE expression, if any. If there is no ELSE expression and
none of the WHEN expressions are true, then the overall result is NULL.

<p>A NULL result is considered untrue when evaluating WHEN terms.

<p>In a CASE with a base expression, the base expression is evaluated just
once and the result is compared against the evaluation of each WHEN 
expression from left to right. The result of the CASE expression is the 
evaluation of the THEN expression that corresponds to the first WHEN
expression for which the comparison is true. Or, if none of the WHEN
expressions evaluate to a value equal to the base expression, the result
of evaluating the ELSE expression, if any. If there is no ELSE expression and
none of the WHEN expressions produce a result equal to the base expression,
the overall result is NULL.

<p>When comparing a base expression against a WHEN expression, the same
collating sequence, affinity, and NULL-handling rules apply as if the
base expression and WHEN expression are respectively the left- and
right-hand operands of an <big><b>=</b></big> operator.</p> If the base 


expression is NULL then the result of the CASE is always the result 
of evaluating the ELSE expression if it exists, or NULL if it does not.

<p>Both forms of the CASE expression use lazy, or short-circuit, 
evaluation.

<p>The only difference between the following two CASE expressions is that 
the <i>x</i> expression is evaluated exactly once in the first example but 
might be evaluated multiple times in the second:

<ul><pre>
<li>CASE x WHEN w1 THEN r1 WHEN w2 THEN r2 ELSE r3 END
<li>CASE WHEN x=w1 THEN r1 WHEN x=w2 THEN r2 ELSE r3 END
</pre></ul>








<a name="in_op"></a>

<h3>The IN and NOT IN operators</h3>
<p>The IN and NOT IN operators take an expression on the
left and a list of values or a subquery on the right.
When the right operand of an IN or NOT IN operator is a subquery, the
subquery must have the same number of columns as there are columns in
the <a href="rowvalue.html">row value</a> of the left operand.  The subquery on the
right of an IN or NOT IN operator must be a scalar subquery if the left
expression is not a <a href="rowvalue.html">row value</a> expression.
If the right operand of an IN or NOT IN operator is a list of values,
each of those values must be scalars and the left expression must also
be a scalar.
The right-hand side of an IN or NOT IN operator can be a
table <i>name</i> or <a href="vtab.html#tabfunc2">table-valued function</a> <i>name</i> in which 
case the right-hand side is understood to be subquery of
the form "(SELECT * FROM <i>name</i>)".
When the right operand is an empty set, the result of IN is false and the
result of NOT IN is true, regardless of the left operand and even if the
left operand is NULL.
<p>The result of an IN or NOT IN operator is determined by the following
matrix:

<center>
<table border=1>
<tr>
<th>Left operand <br>is NULL
<th>Right operand <br>contains NULL
<th>Right operand <br>is an empty set
<th>Left operand found <br>within right operand
<th>Result of <br>IN operator
<th>Result of <br>NOT IN operator
<tr>
<td align="center">no
<td align="center">no
<td align="center">no
<td align="center">no
<td align="center">false
<td align="center">true
<tr>
<td align="center">does not matter
<td align="center">no
<td align="center">yes
<td align="center">no
<td align="center">false
<td align="center">true
<tr>
<td align="center">no
<td align="center">does not matter
<td align="center">no
<td align="center">yes
<td align="center">true
<td align="center">false
<tr>
<td align="center">no
<td align="center">yes
<td align="center">no
<td align="center">no
<td align="center">NULL
<td align="center">NULL
<tr>
<td align="center">yes
<td align="center">does not matter
<td align="center">no
<td align="center">does not matter
<td align="center">NULL
<td align="center">NULL
</table>
</center>

<p>Note that SQLite allows the parenthesized list of scalar values on
the right-hand side of an IN or NOT IN operator to be an empty list but
most other SQL database database engines and the SQL92 standard require
the list to contain at least one element.</p>

<h3>Table Column Names</h3>

<p>A column name can be any of the names defined in the <a href="lang_createtable.html">CREATE TABLE</a>
statement or one of the following special identifiers: "<b>ROWID</b>",
"<b>OID</b>", or "<b>_ROWID_</b>".
The three special identifiers describe the
unique integer key (the <a href="lang_createtable.html#rowid">rowid</a>) associated with every 
row of every table and so are not available on <a href="withoutrowid.html">WITHOUT ROWID</a> tables.
The special identifiers only refer to the row key if the <a href="lang_createtable.html">CREATE TABLE</a>
statement does not define a real column with the same name.
The rowid can be used anywhere a regular
column can be used.</p>

<a name="exists_op"></a>

<h3>The EXISTS operator</h3>

<p>The EXISTS operator always evaluates to one of the integer values 0 
and 1. If executing the SELECT statement specified as the right-hand 
operand of the EXISTS operator would return one or more rows, then the
EXISTS operator evaluates to 1. If executing the SELECT would return
no rows at all, then the EXISTS operator evaluates to 0. 

<p>The number of columns in each row returned by the SELECT statement
(if any) and the specific values returned have no effect on the results
of the EXISTS operator. In particular, rows containing NULL values are
not handled any differently from rows without NULL values.

<a name="subq"></a>

<h3>Subquery Expressions</h3>

<p>A <a href="lang_select.html">SELECT</a> statement enclosed in parentheses is a subquery.
All types of SELECT statement, including
aggregate and compound SELECT queries (queries with keywords like
UNION or EXCEPT) are allowed as scalar subqueries.
The value of a subquery expression is the first row of the result
from the enclosed <a href="lang_select.html">SELECT</a> statement.
The value of a subquery expression is NULL if the enclosed
<a href="lang_select.html">SELECT</a> statement returns no rows.

<p>A subquery that returns a single column is a scalar subquery and can
be used most anywhere.
A subquery that returns two or more columns is a <a href="rowvalue.html">row value</a>
subquery and can only be used as the operand of a comparison operator.

<a name="cosub"></a>

<h3>Correlated Subqueries</h3>

<p>A <a href="lang_select.html">SELECT</a> statement used as either a scalar subquery or as the 
right-hand operand of an IN, NOT IN or EXISTS expression may contain 
references to columns in the outer query. Such a subquery is known as
a correlated subquery. A correlated subquery is reevaluated each time
its result is required. An uncorrelated subquery is evaluated only once
and the result reused as necessary.

<a name="castexpr"></a>

<h3>CAST expressions</h3>

<p>A CAST expression of the form "CAST(<i>expr</i> AS <i>type-name</i>)"
is used to convert the value of <i>expr</i> to 
a different <a href="datatype3.html#storageclasses">storage class</a> specified by <span class='yyterm'>type-name</span>.
A CAST conversion is similar to the conversion that takes
place when a <a href="datatype3.html#affinity">column affinity</a> is applied to a value except that with
the CAST operator the conversion always takes place even if the conversion
lossy and irreversible, whereas column affinity only changes the data type
of a value if the change is lossless and reversible.

<p>If the value of <i>expr</i> is NULL, then the result of the CAST
expression is also NULL. Otherwise, the storage class of the result
is determined by applying the <a href="datatype3.html#affname">rules for determining column affinity</a> to
the <span class='yyterm'>type-name</span>.


<table border=1>
<tr>
  <th> Affinity of <span class='yyterm'><nobr>type-name</nobr></span>
  <th> Conversion Processing
<tr>
  <td> NONE 
  <td> Casting a value to a <span class='yyterm'>type-name</span> with no affinity 
  causes the value to
  be converted into a BLOB.  Casting to a BLOB consists of first casting
  the value to TEXT in the <a href="pragma.html#pragma_encoding">encoding</a> of the database connection, then
  interpreting the resulting byte sequence as a BLOB instead of as TEXT.

<tr>
  <td> TEXT
  <td> To cast a BLOB value to TEXT, the sequence of bytes that make up the
  BLOB is interpreted as text encoded using the database encoding.
  <p>
   Casting an INTEGER or REAL value into TEXT renders the value as if via 
    <a href="c3ref/mprintf.html">sqlite3_snprintf()</a> except that the resulting TEXT uses the <a href="pragma.html#pragma_encoding">encoding</a> of
    the database connection.

<tr>
  <td> REAL
  <td> When casting a BLOB value to a REAL, the value is first converted to
        TEXT.
       <p>When casting a TEXT value to REAL, the longest possible prefix of
        the value that can be interpreted as a real number is extracted from
        the TEXT value and the remainder ignored. Any leading spaces in the
        TEXT value are ignored when converging from TEXT to REAL. If there is
        no prefix that can be interpreted as a real number, the result of the
        conversion is 0.0.

<tr>
  <td> INTEGER
  <td> When casting a BLOB value to INTEGER, the value is first converted to
        TEXT.
       <p>When casting a TEXT value to INTEGER, the longest possible prefix of
        the value that can be interpreted as an integer number is extracted from
        the TEXT value and the remainder ignored. Any leading spaces in the
        TEXT value when converting from TEXT to INTEGER are ignored. If there
        is no prefix that can be interpreted as an integer number, the result
        of the conversion is 0.  If the prefix integer is greater than
        +9223372036854775807 then the result of the cast is exactly
        +9223372036854775807.  Similarly, if the prefix integer is
        less than -9223372036854775808 then the result of the cast is
        exactly -9223372036854775808.

        <p>When casting to INTEGER, if the text looks like a floating point
        value with an exponent, the exponent will be ignored because it is
        no part of the integer prefix.  For example,
        "(CAST '123e+5' AS INTEGER)" results in 123, not in 12300000.

        <p> The CAST operator understands decimal
        integers only &mdash; conversion of <a href="lang_expr.html#hexint">hexadecimal integers</a> stops 
        at the "x" in the "0x" prefix of the hexadecimal integer string 
        and thus result of the CAST is always zero.

      <p>A cast of a REAL value into an INTEGER results in the integer
      between the REAL value and zero that is closest to the REAL value.
      If a REAL is greater than the greatest possible signed
      integer (+9223372036854775807) then the result is the greatest possible
      signed integer and if the REAL is less than the least possible signed
      integer (-9223372036854775808) then the result is the least possible
      signed integer.

      <p>Prior to SQLite version 3.8.2 (2013-12-06),
      casting a REAL value greater than
      +9223372036854775807.0 into an integer resulted in the most negative
      integer, -9223372036854775808.  This behavior was meant to emulate the
      behavior of x86/x64 hardware when doing the equivalent cast.

<tr>
  <td> NUMERIC
  <td> Casting a TEXT or BLOB value into NUMERIC yields either an INTEGER or
   a REAL result.
   If the input text looks like an integer (there is no decimal point nor
   exponent) and the value is small enough to fit in a 64-bit signed integer,
   then the result will be INTEGER.
   Input text that looks like floating point (there is a decimal point and/or
   an exponent) and the text describes a value that 
   can be losslessly converted back and forth between IEEE 754 64-bit float and a
   51-bit signed integer, then the result is INTEGER.
   (In the previous sentence, a 51-bit integer is specified since that is one
   bit less than the length of the mantissa of an IEEE 754 64-bit float and
   thus provides a 1-bit of margin for the text-to-float conversion operation.)
   Any text input that describes a value outside the range of a 64-bit
   signed integer yields a REAL result.
   <p> Casting a REAL or INTEGER value to NUMERIC is a no-op, even if a real
   value could be losslessly converted to an integer.

</tr>

</table>


<p>Note that the result from casting any non-BLOB value into a 
BLOB and the result from casting any BLOB value into a non-BLOB value
may be different depending on whether the database <a href="pragma.html#pragma_encoding">encoding</a> is UTF-8,
UTF-16be, or UTF-16le.


<a name="booleanexpr"></a>

<h3>Boolean Expressions</h3>

<p>The SQL language features several contexts where an expression is 
evaluated and the result converted to a boolean (true or false) value. These
contexts are:

  <ul>
    <li> the WHERE clause of a SELECT, UPDATE or DELETE statement,
    <li> the ON or USING clause of a join in a SELECT statement,
    <li> the HAVING clause of a SELECT statement,
    <li> the WHEN clause of an SQL trigger, and
    <li> the WHEN clause or clauses of some CASE expressions.
  </ul>

<p>To convert the results of an SQL expression to a boolean value, SQLite
first casts the result to a NUMERIC value in the same way as a 
<a href="lang_expr.html#castexpr">CAST expression</a>. A numeric zero value (integer value 0 or real 
value 0.0) is considered to be false.  A NULL value is still NULL.
All other values are considered true.

<p>For example, the values NULL, 0.0, 0, 'english' and '0' are all considered
to be false. Values 1, 1.0, 0.1, -0.1 and '1english' are considered to 
be true.

<p>Beginning with SQLite 3.23.0 (2018-04-02), SQLite recognizes the
identifiers "TRUE" and "FALSE" as boolean literals, if and only if those
identifiers are not already used for some other meaning.  If there already
exists columns or tables or other objects named TRUE or FALSE, then for
the sake of backwards compatibility, the TRUE and FALSE identifiers refer
to those other objects, not to the boolean values.

<p>The boolean identifiers TRUE and FALSE are usually just aliases for
the integer values 1 and 0, respectively.  However, if TRUE or FALSE
occur on the right-hand side of an IS operator, then they form new
unary postfix operators "IS TRUE" and "IS FALSE" which test the boolean
value of the operand on the left.

<h3>Functions</h3>
<p>SQLite supports many <a href="lang_corefunc.html">simple</a>, <a href="lang_aggfunc.html">aggregate</a>,
and <a href="windowfunctions.html">window</a>
SQL functions.  For presentation purposes, simple functions are further
subdivided into <a href="lang_corefunc.html">core functions</a>, <a href="lang_datefunc.html">date-time functions</a>,
and <a href="json1.html">JSON functions</a>.
Applications can add new functions, written in C/C++, using the
<a href="c3ref/create_function.html">sqlite3_create_function()</a> interface.







|










|



|
|
>


|







|

|









|


|
>
>



|


|



|

|
|
>
>
>
>
>
>




|

















|


|
|


|
|
|
|
|
|

|
|
|
|
|
|

|
|
|
|
|
|

|
|
|
|
|
|

|
|
|
|
|
|

|
|
|
|
|
|
|






|














|







|






|










|






|










|










|




>
|


|
|

|





|

|






|

|








|

|












|




|




|







|





|

|















<
|
<

>









|





|

|
|
|
|
|







|



|






|





|







507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821

822

823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
application-defined function.  The default match() function implementation
raises an exception and is not really useful for anything.
But extensions can override the match() function with more
helpful logic.</p>

<a name="between"></a>

<h1 id="the_between_operator"><span>6. </span>The BETWEEN operator</h1>
<p>The BETWEEN operator is logically equivalent to a pair of comparisons.
"<i>x</i> <b>BETWEEN</b> <i>y</i> <b>AND</b> <i>z</i>" is 
equivalent to 
"<i>x</i><b>&gt;=</b><i>y</i> <b>AND</b> <i>x</i><b>&lt;=</b><i>z</i>" except
that with BETWEEN, the <i>x</i> expression is only evaluated once.
The precedence of the BETWEEN operator is the same as the precedence
as operators <b>==</b> and <b>!=</b> and <b>LIKE</b> and groups left to right.

<a name="case"></a>

</p><h1 id="the_case_expression"><span>7. </span>The CASE expression</h1>
<p>A CASE expression serves a role similar to IF-THEN-ELSE in other
programming languages.  

</p><p>The optional expression that occurs in between the CASE keyword and the
first WHEN keyword is called the "base" expression. There are two
fundamental forms
of the CASE expression: those with a base expression and those without.

</p><p>In a CASE without a base expression, each WHEN expression is evaluated
and the result treated as a boolean, starting with the leftmost and continuing
to the right. The result of the CASE expression is the evaluation of the THEN
expression that corresponds to the first WHEN expression that evaluates to
true. Or, if none of the WHEN expressions evaluate to true, the result of
evaluating the ELSE expression, if any. If there is no ELSE expression and
none of the WHEN expressions are true, then the overall result is NULL.

</p><p>A NULL result is considered untrue when evaluating WHEN terms.

</p><p>In a CASE with a base expression, the base expression is evaluated just
once and the result is compared against the evaluation of each WHEN 
expression from left to right. The result of the CASE expression is the 
evaluation of the THEN expression that corresponds to the first WHEN
expression for which the comparison is true. Or, if none of the WHEN
expressions evaluate to a value equal to the base expression, the result
of evaluating the ELSE expression, if any. If there is no ELSE expression and
none of the WHEN expressions produce a result equal to the base expression,
the overall result is NULL.

</p><p>When comparing a base expression against a WHEN expression, the same
collating sequence, affinity, and NULL-handling rules apply as if the
base expression and WHEN expression are respectively the left- and
right-hand operands of an <big><b>=</b></big> operator.</p> 

<p>If the base 
expression is NULL then the result of the CASE is always the result 
of evaluating the ELSE expression if it exists, or NULL if it does not.

</p><p>Both forms of the CASE expression use lazy, or short-circuit, 
evaluation.

</p><p>The only difference between the following two CASE expressions is that 
the <i>x</i> expression is evaluated exactly once in the first example but 
might be evaluated multiple times in the second:

</p><ul><pre>
<li>CASE x WHEN w1 THEN r1 WHEN w2 THEN r2 ELSE r3 END
</li><li>CASE WHEN x=w1 THEN r1 WHEN x=w2 THEN r2 ELSE r3 END
</li></pre></ul>

<p>The built-in <a href="lang_corefunc.html#iif">iif(x,y,z) SQL function</a> is logically
equivalent to "CASE WHEN x THEN y ELSE z END".  The iif() function
is found in SQL Server and is included in SQLite for compatibility.
Some developers prefer the iif() function because it is more
concise.


<a name="in_op"></a>

</p><h1 id="the_in_and_not_in_operators"><span>8. </span>The IN and NOT IN operators</h1>
<p>The IN and NOT IN operators take an expression on the
left and a list of values or a subquery on the right.
When the right operand of an IN or NOT IN operator is a subquery, the
subquery must have the same number of columns as there are columns in
the <a href="rowvalue.html">row value</a> of the left operand.  The subquery on the
right of an IN or NOT IN operator must be a scalar subquery if the left
expression is not a <a href="rowvalue.html">row value</a> expression.
If the right operand of an IN or NOT IN operator is a list of values,
each of those values must be scalars and the left expression must also
be a scalar.
The right-hand side of an IN or NOT IN operator can be a
table <i>name</i> or <a href="vtab.html#tabfunc2">table-valued function</a> <i>name</i> in which 
case the right-hand side is understood to be subquery of
the form "(SELECT * FROM <i>name</i>)".
When the right operand is an empty set, the result of IN is false and the
result of NOT IN is true, regardless of the left operand and even if the
left operand is NULL.
</p><p>The result of an IN or NOT IN operator is determined by the following
matrix:

</p><blockquote>
<table border="1">
<tr>
<th>Left operand <br>is NULL
</th><th>Right operand <br>contains NULL
</th><th>Right operand <br>is an empty set
</th><th>Left operand found <br>within right operand
</th><th>Result of <br>IN operator
</th><th>Result of <br>NOT IN operator
</th></tr><tr>
<td align="center">no
</td><td align="center">no
</td><td align="center">no
</td><td align="center">no
</td><td align="center">false
</td><td align="center">true
</td></tr><tr>
<td align="center">does not matter
</td><td align="center">no
</td><td align="center">yes
</td><td align="center">no
</td><td align="center">false
</td><td align="center">true
</td></tr><tr>
<td align="center">no
</td><td align="center">does not matter
</td><td align="center">no
</td><td align="center">yes
</td><td align="center">true
</td><td align="center">false
</td></tr><tr>
<td align="center">no
</td><td align="center">yes
</td><td align="center">no
</td><td align="center">no
</td><td align="center">NULL
</td><td align="center">NULL
</td></tr><tr>
<td align="center">yes
</td><td align="center">does not matter
</td><td align="center">no
</td><td align="center">does not matter
</td><td align="center">NULL
</td><td align="center">NULL
</td></tr></table>
</blockquote>

<p>Note that SQLite allows the parenthesized list of scalar values on
the right-hand side of an IN or NOT IN operator to be an empty list but
most other SQL database database engines and the SQL92 standard require
the list to contain at least one element.</p>

<h1 id="table_column_names"><span>9. </span>Table Column Names</h1>

<p>A column name can be any of the names defined in the <a href="lang_createtable.html">CREATE TABLE</a>
statement or one of the following special identifiers: "<b>ROWID</b>",
"<b>OID</b>", or "<b>_ROWID_</b>".
The three special identifiers describe the
unique integer key (the <a href="lang_createtable.html#rowid">rowid</a>) associated with every 
row of every table and so are not available on <a href="withoutrowid.html">WITHOUT ROWID</a> tables.
The special identifiers only refer to the row key if the <a href="lang_createtable.html">CREATE TABLE</a>
statement does not define a real column with the same name.
The rowid can be used anywhere a regular
column can be used.</p>

<a name="exists_op"></a>

<h1 id="the_exists_operator"><span>10. </span>The EXISTS operator</h1>

<p>The EXISTS operator always evaluates to one of the integer values 0 
and 1. If executing the SELECT statement specified as the right-hand 
operand of the EXISTS operator would return one or more rows, then the
EXISTS operator evaluates to 1. If executing the SELECT would return
no rows at all, then the EXISTS operator evaluates to 0. 

</p><p>The number of columns in each row returned by the SELECT statement
(if any) and the specific values returned have no effect on the results
of the EXISTS operator. In particular, rows containing NULL values are
not handled any differently from rows without NULL values.

<a name="subq"></a>

</p><h1 id="subquery_expressions"><span>11. </span>Subquery Expressions</h1>

<p>A <a href="lang_select.html">SELECT</a> statement enclosed in parentheses is a subquery.
All types of SELECT statement, including
aggregate and compound SELECT queries (queries with keywords like
UNION or EXCEPT) are allowed as scalar subqueries.
The value of a subquery expression is the first row of the result
from the enclosed <a href="lang_select.html">SELECT</a> statement.
The value of a subquery expression is NULL if the enclosed
<a href="lang_select.html">SELECT</a> statement returns no rows.

</p><p>A subquery that returns a single column is a scalar subquery and can
be used most anywhere.
A subquery that returns two or more columns is a <a href="rowvalue.html">row value</a>
subquery and can only be used as the operand of a comparison operator.

<a name="cosub"></a>

</p><h1 id="correlated_subqueries"><span>12. </span>Correlated Subqueries</h1>

<p>A <a href="lang_select.html">SELECT</a> statement used as either a scalar subquery or as the 
right-hand operand of an IN, NOT IN or EXISTS expression may contain 
references to columns in the outer query. Such a subquery is known as
a correlated subquery. A correlated subquery is reevaluated each time
its result is required. An uncorrelated subquery is evaluated only once
and the result reused as necessary.

<a name="castexpr"></a>

</p><h1 id="cast_expressions"><span>13. </span>CAST expressions</h1>

<p>A CAST expression of the form "CAST(<i>expr</i> AS <i>type-name</i>)"
is used to convert the value of <i>expr</i> to 
a different <a href="datatype3.html#storageclasses">storage class</a> specified by <span class='yyterm'>type-name</span>.
A CAST conversion is similar to the conversion that takes
place when a <a href="datatype3.html#affinity">column affinity</a> is applied to a value except that with
the CAST operator the conversion always takes place even if the conversion
lossy and irreversible, whereas column affinity only changes the data type
of a value if the change is lossless and reversible.

</p><p>If the value of <i>expr</i> is NULL, then the result of the CAST
expression is also NULL. Otherwise, the storage class of the result
is determined by applying the <a href="datatype3.html#affname">rules for determining column affinity</a> to
the <span class='yyterm'>type-name</span>.

</p><blockquote>
<table border="1">
<tr>
  <th> Affinity of <span class='yyterm'><nobr>type-name</nobr></span>
  </th><th> Conversion Processing
</th></tr><tr>
  <td> NONE 
  </td><td> Casting a value to a <span class='yyterm'>type-name</span> with no affinity 
  causes the value to
  be converted into a BLOB.  Casting to a BLOB consists of first casting
  the value to TEXT in the <a href="pragma.html#pragma_encoding">encoding</a> of the database connection, then
  interpreting the resulting byte sequence as a BLOB instead of as TEXT.

</td></tr><tr>
  <td> TEXT
  </td><td> To cast a BLOB value to TEXT, the sequence of bytes that make up the
  BLOB is interpreted as text encoded using the database encoding.
  <p>
   Casting an INTEGER or REAL value into TEXT renders the value as if via 
    <a href="c3ref/mprintf.html">sqlite3_snprintf()</a> except that the resulting TEXT uses the <a href="pragma.html#pragma_encoding">encoding</a> of
    the database connection.

</p></td></tr><tr>
  <td> REAL
  </td><td> When casting a BLOB value to a REAL, the value is first converted to
        TEXT.
       <p>When casting a TEXT value to REAL, the longest possible prefix of
        the value that can be interpreted as a real number is extracted from
        the TEXT value and the remainder ignored. Any leading spaces in the
        TEXT value are ignored when converging from TEXT to REAL. If there is
        no prefix that can be interpreted as a real number, the result of the
        conversion is 0.0.

</p></td></tr><tr>
  <td> INTEGER
  </td><td> When casting a BLOB value to INTEGER, the value is first converted to
        TEXT.
       <p>When casting a TEXT value to INTEGER, the longest possible prefix of
        the value that can be interpreted as an integer number is extracted from
        the TEXT value and the remainder ignored. Any leading spaces in the
        TEXT value when converting from TEXT to INTEGER are ignored. If there
        is no prefix that can be interpreted as an integer number, the result
        of the conversion is 0.  If the prefix integer is greater than
        +9223372036854775807 then the result of the cast is exactly
        +9223372036854775807.  Similarly, if the prefix integer is
        less than -9223372036854775808 then the result of the cast is
        exactly -9223372036854775808.

        </p><p>When casting to INTEGER, if the text looks like a floating point
        value with an exponent, the exponent will be ignored because it is
        no part of the integer prefix.  For example,
        "(CAST '123e+5' AS INTEGER)" results in 123, not in 12300000.

        </p><p> The CAST operator understands decimal
        integers only &mdash; conversion of <a href="lang_expr.html#hexint">hexadecimal integers</a> stops 
        at the "x" in the "0x" prefix of the hexadecimal integer string 
        and thus result of the CAST is always zero.

      </p><p>A cast of a REAL value into an INTEGER results in the integer
      between the REAL value and zero that is closest to the REAL value.
      If a REAL is greater than the greatest possible signed
      integer (+9223372036854775807) then the result is the greatest possible
      signed integer and if the REAL is less than the least possible signed
      integer (-9223372036854775808) then the result is the least possible
      signed integer.

      </p><p>Prior to SQLite version 3.8.2 (2013-12-06),
      casting a REAL value greater than
      +9223372036854775807.0 into an integer resulted in the most negative
      integer, -9223372036854775808.  This behavior was meant to emulate the
      behavior of x86/x64 hardware when doing the equivalent cast.

</p></td></tr><tr>
  <td> NUMERIC
  </td><td> Casting a TEXT or BLOB value into NUMERIC yields either an INTEGER or
   a REAL result.
   If the input text looks like an integer (there is no decimal point nor
   exponent) and the value is small enough to fit in a 64-bit signed integer,
   then the result will be INTEGER.
   Input text that looks like floating point (there is a decimal point and/or
   an exponent) and the text describes a value that 
   can be losslessly converted back and forth between IEEE 754 64-bit float and a
   51-bit signed integer, then the result is INTEGER.
   (In the previous sentence, a 51-bit integer is specified since that is one
   bit less than the length of the mantissa of an IEEE 754 64-bit float and
   thus provides a 1-bit of margin for the text-to-float conversion operation.)
   Any text input that describes a value outside the range of a 64-bit
   signed integer yields a REAL result.
   <p> Casting a REAL or INTEGER value to NUMERIC is a no-op, even if a real
   value could be losslessly converted to an integer.

</p></td></tr>

</table>
</blockquote>

<p>Note that the result from casting any non-BLOB value into a 
BLOB and the result from casting any BLOB value into a non-BLOB value
may be different depending on whether the database <a href="pragma.html#pragma_encoding">encoding</a> is UTF-8,
UTF-16be, or UTF-16le.


<a name="booleanexpr"></a>

</p><h1 id="boolean_expressions"><span>14. </span>Boolean Expressions</h1>

<p>The SQL language features several contexts where an expression is 
evaluated and the result converted to a boolean (true or false) value. These
contexts are:

  </p><ul>
    <li> the WHERE clause of a SELECT, UPDATE or DELETE statement,
    </li><li> the ON or USING clause of a join in a SELECT statement,
    </li><li> the HAVING clause of a SELECT statement,
    </li><li> the WHEN clause of an SQL trigger, and
    </li><li> the WHEN clause or clauses of some CASE expressions.
  </li></ul>

<p>To convert the results of an SQL expression to a boolean value, SQLite
first casts the result to a NUMERIC value in the same way as a 
<a href="lang_expr.html#castexpr">CAST expression</a>. A numeric zero value (integer value 0 or real 
value 0.0) is considered to be false.  A NULL value is still NULL.
All other values are considered true.

</p><p>For example, the values NULL, 0.0, 0, 'english' and '0' are all considered
to be false. Values 1, 1.0, 0.1, -0.1 and '1english' are considered to 
be true.

</p><p>Beginning with SQLite 3.23.0 (2018-04-02), SQLite recognizes the
identifiers "TRUE" and "FALSE" as boolean literals, if and only if those
identifiers are not already used for some other meaning.  If there already
exists columns or tables or other objects named TRUE or FALSE, then for
the sake of backwards compatibility, the TRUE and FALSE identifiers refer
to those other objects, not to the boolean values.

</p><p>The boolean identifiers TRUE and FALSE are usually just aliases for
the integer values 1 and 0, respectively.  However, if TRUE or FALSE
occur on the right-hand side of an IS operator, then they form new
unary postfix operators "IS TRUE" and "IS FALSE" which test the boolean
value of the operand on the left.

</p><h1 id="functions"><span>15. </span>Functions</h1>
<p>SQLite supports many <a href="lang_corefunc.html">simple</a>, <a href="lang_aggfunc.html">aggregate</a>,
and <a href="windowfunctions.html">window</a>
SQL functions.  For presentation purposes, simple functions are further
subdivided into <a href="lang_corefunc.html">core functions</a>, <a href="lang_datefunc.html">date-time functions</a>,
and <a href="json1.html">JSON functions</a>.
Applications can add new functions, written in C/C++, using the
<a href="c3ref/create_function.html">sqlite3_create_function()</a> interface.
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
 <img alt="syntax diagram aggregate-function-invocation" src="images/syntax/aggregate-function-invocation.gif"></img>
 </div>
<p><b><a href="syntax/window-function-invocation.html">window-function-invocation:</a></b></p><div class='imgcontainer'>
 <img alt="syntax diagram window-function-invocation" src="images/syntax/window-function-invocation.gif"></img>
 </div>


<p>
The OVER clause is required for <a href="windowfunctions.html">window functions</a> and is prohibited
otherwise.  The DISTINCT keyword is only allowed in <a href="lang_aggfunc.html">aggregate functions</a>.
The FILTER clause may not appear on a <a href="lang_corefunc.html">simple function</a>.

<p>It is possible to have an aggregate function with the same name as a
simple function, as long as the number of arguments for the two forms of the
function are different.  For example, the <a href="lang_aggfunc.html#maxggunc">max()</a> function with a
single argument is an aggregate and the <a href="lang_corefunc.html#maxoreunc">max()</a> function with two or more
arguments is a simple function.  Aggregate functions can usually also
be used as window functions.









|




|





|
<
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910

 <img alt="syntax diagram aggregate-function-invocation" src="images/syntax/aggregate-function-invocation.gif"></img>
 </div>
<p><b><a href="syntax/window-function-invocation.html">window-function-invocation:</a></b></p><div class='imgcontainer'>
 <img alt="syntax diagram window-function-invocation" src="images/syntax/window-function-invocation.gif"></img>
 </div>


</p><p>
The OVER clause is required for <a href="windowfunctions.html">window functions</a> and is prohibited
otherwise.  The DISTINCT keyword is only allowed in <a href="lang_aggfunc.html">aggregate functions</a>.
The FILTER clause may not appear on a <a href="lang_corefunc.html">simple function</a>.

</p><p>It is possible to have an aggregate function with the same name as a
simple function, as long as the number of arguments for the two forms of the
function are different.  For example, the <a href="lang_aggfunc.html#maxggunc">max()</a> function with a
single argument is an aggregate and the <a href="lang_corefunc.html#maxoreunc">max()</a> function with two or more
arguments is a simple function.  Aggregate functions can usually also
be used as window functions.
</p>

Changes to Doc/Extra/Core/lang_indexedby.html.
1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>SQLite Query Language: INDEXED BY</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>





|







1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>The INDEXED BY Clause</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93

94










95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>

<div class=nosearch><h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>INDEXED BY</h2></div>










<p>The INDEXED BY phrase forces the <a href="optoverview.html">SQLite query planner</a> to use a
particular named index on a <a href="lang_delete.html">DELETE</a>, <a href="lang_select.html">SELECT</a>, or <a href="lang_update.html">UPDATE</a> statement.
The INDEXED BY phrase is an SQLite extension and
is not portable to other SQL database engines.</p>

<p><b><a href="syntax/qualified-table-name.html">qualified-table-name:</a></b>
<button id='x2205' onclick='hideorshow("x2205","x2206")'>hide</button></p>
 <div id='x2206' class='imgcontainer'>
 <img alt="syntax diagram qualified-table-name" src="images/syntax/qualified-table-name.gif" />
</div>


<p>The "INDEXED BY <span class='yyterm'>index-name</span>" phrase specifies 
that the named index
must be used in order to look up values on the preceding table.







|

















>
|
>
>
>
>
>
>
>
>
>
>






|
|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<div class=fancy>
<div class=nosearch>
<div class="fancy_title">
The INDEXED BY Clause
</div>
</div>




<h1 id="how_indexed_by_works"><span>1. </span>How INDEXED BY Works</h1>

<p>The INDEXED BY phrase forces the <a href="optoverview.html">SQLite query planner</a> to use a
particular named index on a <a href="lang_delete.html">DELETE</a>, <a href="lang_select.html">SELECT</a>, or <a href="lang_update.html">UPDATE</a> statement.
The INDEXED BY phrase is an SQLite extension and
is not portable to other SQL database engines.</p>

<p><b><a href="syntax/qualified-table-name.html">qualified-table-name:</a></b>
<button id='x1705' onclick='hideorshow("x1705","x1706")'>hide</button></p>
 <div id='x1706' class='imgcontainer'>
 <img alt="syntax diagram qualified-table-name" src="images/syntax/qualified-table-name.gif" />
</div>


<p>The "INDEXED BY <span class='yyterm'>index-name</span>" phrase specifies 
that the named index
must be used in order to look up values on the preceding table.
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
undesirable query plan changes during regression testing.
Application 
developers are admonished to omit all use of INDEXED BY during
application design, implementation, testing, and tuning.  If
INDEXED BY is to be used at all, it should be inserted at the very
end of the development process when "locking down" a design.</p>

<h3>See Also:</h3>

<ol>
<li><p>The <a href="queryplanner-ng.html#howtofix">query planner checklist</a> describes steps that application
developers should following to help resolve query planner problems.
Notice the that the use of INDEXED BY is a last resort, to be used only
when all other measures fail.</p>

<li><p><a href="optoverview.html#uplus">The unary "+" operator</a>
can be used to disqualify terms in the WHERE clause from use by indices.
Careful use of unary + can sometimes help prevent the query planner from
choosing a poor index without restricting it to using one specific index.
Careful placement of unary + operators is a better method for controlling 
which indices are used by a query.</p>

<li><p>The <a href="c3ref/stmt_status.html">sqlite3_stmt_status()</a> C/C++ interface together with the
<a href="c3ref/c_stmtstatus_counter.html#sqlitestmtstatusfullscanstep">SQLITE_STMTSTATUS_FULLSCAN_STEP</a> and <a href="c3ref/c_stmtstatus_counter.html#sqlitestmtstatussort">SQLITE_STMTSTATUS_SORT</a> verbs
can be used to detect at run-time when an SQL statement is not
making effective use of indices.  Many applications may prefer to
use the <a href="c3ref/stmt_status.html">sqlite3_stmt_status()</a> interface to detect index misuse
rather than the INDEXED BY phrase described here.</p>
</ol>

<DIV class="pdf_section">







|







|






|





|

<
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171

undesirable query plan changes during regression testing.
Application 
developers are admonished to omit all use of INDEXED BY during
application design, implementation, testing, and tuning.  If
INDEXED BY is to be used at all, it should be inserted at the very
end of the development process when "locking down" a design.</p>

<h1 id="see_also"><span>2. </span>See Also</h1>

<ol>
<li><p>The <a href="queryplanner-ng.html#howtofix">query planner checklist</a> describes steps that application
developers should following to help resolve query planner problems.
Notice the that the use of INDEXED BY is a last resort, to be used only
when all other measures fail.</p>

</li><li><p><a href="optoverview.html#uplus">The unary "+" operator</a>
can be used to disqualify terms in the WHERE clause from use by indices.
Careful use of unary + can sometimes help prevent the query planner from
choosing a poor index without restricting it to using one specific index.
Careful placement of unary + operators is a better method for controlling 
which indices are used by a query.</p>

</li><li><p>The <a href="c3ref/stmt_status.html">sqlite3_stmt_status()</a> C/C++ interface together with the
<a href="c3ref/c_stmtstatus_counter.html#sqlitestmtstatusfullscanstep">SQLITE_STMTSTATUS_FULLSCAN_STEP</a> and <a href="c3ref/c_stmtstatus_counter.html#sqlitestmtstatussort">SQLITE_STMTSTATUS_SORT</a> verbs
can be used to detect at run-time when an SQL statement is not
making effective use of indices.  Many applications may prefer to
use the <a href="c3ref/stmt_status.html">sqlite3_stmt_status()</a> interface to detect index misuse
rather than the INDEXED BY phrase described here.</p>
</li></ol>


Changes to Doc/Extra/Core/lang_insert.html.
1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>SQLite Query Language: INSERT</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>





|







1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>INSERT</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93











94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>











<div class=nosearch><h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>INSERT</h2></div><p><b><a href="syntax/insert-stmt.html">insert-stmt:</a></b>
<button id='x1715' onclick='hideorshow("x1715","x1716")'>hide</button></p>
 <div id='x1716' class='imgcontainer'>
 <img alt="syntax diagram insert-stmt" src="images/syntax/insert-stmt.gif" />
<p><b><a href="syntax/expr.html">expr:</a></b>
<button id='x1717' onclick='hideorshow("x1717","x1718")'>show</button></p>
 <div id='x1718' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntax/filter-clause.html">filter-clause:</a></b>
<button id='x1719' onclick='hideorshow("x1719","x1720")'>show</button></p>
 <div id='x1720' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram filter-clause" src="images/syntax/filter-clause.gif" />
</div>
<p><b><a href="syntax/literal-value.html">literal-value:</a></b>
<button id='x1721' onclick='hideorshow("x1721","x1722")'>show</button></p>
 <div id='x1722' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</div>
<p><b><a href="syntax/over-clause.html">over-clause:</a></b>
<button id='x1723' onclick='hideorshow("x1723","x1724")'>show</button></p>
 <div id='x1724' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram over-clause" src="images/syntax/over-clause.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x1725' onclick='hideorshow("x1725","x1726")'>show</button></p>
 <div id='x1726' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
<button id='x1727' onclick='hideorshow("x1727","x1728")'>show</button></p>
 <div id='x1728' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</div>
</div>
<p><b><a href="syntax/raise-function.html">raise-function:</a></b>
<button id='x1729' onclick='hideorshow("x1729","x1730")'>show</button></p>
 <div id='x1730' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</div>
<p><b><a href="syntax/type-name.html">type-name:</a></b>
<button id='x1731' onclick='hideorshow("x1731","x1732")'>show</button></p>
 <div id='x1732' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
<button id='x1733' onclick='hideorshow("x1733","x1734")'>show</button></p>
 <div id='x1734' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</div>
</div>
</div>
<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
<button id='x1735' onclick='hideorshow("x1735","x1736")'>show</button></p>
 <div id='x1736' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntax/common-table-expression.html">common-table-expression:</a></b>
<button id='x1737' onclick='hideorshow("x1737","x1738")'>show</button></p>
 <div id='x1738' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
</div>
<p><b><a href="syntax/compound-operator.html">compound-operator:</a></b>
<button id='x1739' onclick='hideorshow("x1739","x1740")'>show</button></p>
 <div id='x1740' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</div>
<p><b><a href="syntax/join-clause.html">join-clause:</a></b>
<button id='x1741' onclick='hideorshow("x1741","x1742")'>show</button></p>
 <div id='x1742' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
<button id='x1743' onclick='hideorshow("x1743","x1744")'>show</button></p>
 <div id='x1744' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</div>
<p><b><a href="syntax/join-operator.html">join-operator:</a></b>
<button id='x1745' onclick='hideorshow("x1745","x1746")'>show</button></p>
 <div id='x1746' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</div>
</div>
<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
<button id='x1747' onclick='hideorshow("x1747","x1748")'>show</button></p>
 <div id='x1748' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</div>
<p><b><a href="syntax/result-column.html">result-column:</a></b>
<button id='x1749' onclick='hideorshow("x1749","x1750")'>show</button></p>
 <div id='x1750' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</div>
<p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
<button id='x1751' onclick='hideorshow("x1751","x1752")'>show</button></p>
 <div id='x1752' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</div>
<p><b><a href="syntax/window-defn.html">window-defn:</a></b>
<button id='x1753' onclick='hideorshow("x1753","x1754")'>show</button></p>
 <div id='x1754' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram window-defn" src="images/syntax/window-defn.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x1755' onclick='hideorshow("x1755","x1756")'>show</button></p>
 <div id='x1756' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
</div>
</div>
<p><b><a href="syntax/upsert-clause.html">upsert-clause:</a></b>
<button id='x1757' onclick='hideorshow("x1757","x1758")'>show</button></p>
 <div id='x1758' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram upsert-clause" src="images/syntax/upsert-clause.gif" />
<p><b><a href="syntax/column-name-list.html">column-name-list:</a></b>
<button id='x1759' onclick='hideorshow("x1759","x1760")'>show</button></p>
 <div id='x1760' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram column-name-list" src="images/syntax/column-name-list.gif" />
</div>
<p><b><a href="syntax/indexed-column.html">indexed-column:</a></b>
<button id='x1761' onclick='hideorshow("x1761","x1762")'>show</button></p>
 <div id='x1762' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram indexed-column" src="images/syntax/indexed-column.gif" />
</div>
</div>
<p><b><a href="syntax/with-clause.html">with-clause:</a></b>
<button id='x1763' onclick='hideorshow("x1763","x1764")'>show</button></p>
 <div id='x1764' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram with-clause" src="images/syntax/with-clause.gif" />
<p><b><a href="syntax/cte-table-name.html">cte-table-name:</a></b>
<button id='x1765' onclick='hideorshow("x1765","x1766")'>show</button></p>
 <div id='x1766' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram cte-table-name" src="images/syntax/cte-table-name.gif" />
</div>
</div>
</div>


<p>The INSERT statement comes in three basic forms.  
<ol>
<li><p><b>INSERT INTO </b><i>table</i><b> VALUES(...);</b>
<p>The first form (with the "VALUES" keyword) creates one or more
new rows in
an existing table. If the <span class='yyterm'>column-name</span> list after
<span class='yyterm'>table-name</span> is omitted then the number
of values inserted into each row
must be the same as the number of columns in the table. In this case
the result of evaluating the left-most expression from each term of
the VALUES list is inserted into the left-most column of each new row,
and so forth for each subsequent expression. If a <span class='yyterm'>column-name</span>
list is specified, then the number of values in each term of the
VALUE list must match the number of
specified columns. Each of the named columns of the new row is populated
with the results of evaluating the corresponding VALUES expression. Table
columns that do not appear in the column list are populated with the 
<a href="lang_createtable.html#dfltval">default column value</a> (specified as part of the <a href="lang_createtable.html">CREATE TABLE</a> statement), or
with NULL if no <a href="lang_createtable.html#dfltval">default value</a> is specified.

<li><p><b>INSERT INTO </b><i>table</i><b> SELECT ...;</b>
<p>The second form of the INSERT statement contains a <a href="lang_select.html">SELECT</a> statement
instead of a VALUES clause. A new entry is inserted into the table for each
row of data returned by executing the SELECT statement. If a column-list is
specified, the number of columns in the result of the SELECT must be the same
as the number of items in the column-list. Otherwise, if no column-list is
specified, the number of columns in the result of the SELECT must be the same
as the number of columns in the table. Any SELECT statement, including
<a href="lang_select.html#compound">compound SELECTs</a> and SELECT statements with <a href="lang_select.html#orderby">ORDER BY</a> and/or <a href="lang_select.html#limitoffset">LIMIT</a> clauses, 
may be used in an INSERT statement of this form.

<p>To avoid a parsing ambiguity, the SELECT statement should always
contain a WHERE clause, even if that clause is simply "WHERE true",
if the <a href="syntax/upsert-clause.html">upsert-clause</a> is present.  Without the WHERE clause, the
parser does not know if the token "ON" is part of a join constraint
on the SELECT, or the beginning of the <a href="syntax/upsert-clause.html">upsert-clause</a>.

<li><p><b>INSERT INTO </b><i>table</i><b> DEFAULT VALUES;</b>
<p>The third form of an INSERT statement is with DEFAULT VALUES.
The INSERT ... DEFAULT VALUES statement inserts a single new row into the
named table. Each column of the new row is populated with its 
<a href="lang_createtable.html#dfltval">default value</a>, or with a NULL if no default value is specified 
as part of the column definition in the <a href="lang_createtable.html">CREATE TABLE</a> statement.
The <a href="syntax/upsert-clause.html">upsert-clause</a> is not supported after DEFAULT VALUES.

</ol>

<p>
The initial "INSERT" keyword can be replaced by
"REPLACE" or "INSERT OR <i>action</i>" to specify an alternative
constraint <a href="lang_conflict.html">conflict resolution algorithm</a> to use during 
that one INSERT command.
For compatibility with MySQL, the parser allows the use of the
single keyword <a href="lang_replace.html">REPLACE</a> as an 
alias for "INSERT OR REPLACE".

<p>The optional "<i>schema-name</i><b>.</b>" prefix on the 
<span class='yyterm'>table-name</span>
is supported for top-level INSERT statements only.  The table name must be
unqualified for INSERT statements that occur within <a href="lang_createtrigger.html">CREATE TRIGGER</a> statements.
Similarly, the "DEFAULT VALUES" form of the INSERT statement is supported for
top-level INSERT statements only and not for INSERT statements within
triggers.
<p>

<p>The optional "AS <span class='yyterm'>alias</span>" phrase provides an alternative
name for the table into which content is being inserted.  The alias name
can be used within WHERE and SET clauses of the <a href="lang_UPSERT.html">UPSERT</a>.  If there is no
<a href="syntax/upsert-clause.html">upsert-clause</a>, then the <span class='yyterm'>alias</span> is pointless, but also
harmless.

<p>See the separate <a href="lang_UPSERT.html">UPSERT</a> documentation for the additional trailing
syntax that can cause an INSERT to behave as an UPDATE if the INSERT would
otherwise violate a uniqueness constraint.  The <a href="lang_UPSERT.html">upsert clause</a> is not
allowed on an "INSERT ... DEFAULT VALUES".










|

















>
>
>
>
>
>
>
>
>
>
>
|
|
|


|
|


|
|



|
|



|
|


|
|



|
|




|
|



|
|


|
|





|
|


|
|



|
|



|
|


|
|



|
|




|
|



|
|



|
|



|
|


|
|





|
|


|
|



|
|




|
|


|
|







|

|
















|
|









|





|
|






|










|






|

|

|



|

|

|
<
<
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312


}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<div class=fancy>
<div class=nosearch>
<div class="fancy_title">
INSERT
</div>
</div>





<p><b><a href="syntax/insert-stmt.html">insert-stmt:</a></b>
<button id='x1707' onclick='hideorshow("x1707","x1708")'>hide</button></p>
 <div id='x1708' class='imgcontainer'>
 <img alt="syntax diagram insert-stmt" src="images/syntax/insert-stmt.gif" />
<p><b><a href="syntax/expr.html">expr:</a></b>
<button id='x1709' onclick='hideorshow("x1709","x1710")'>show</button></p>
 <div id='x1710' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntax/filter-clause.html">filter-clause:</a></b>
<button id='x1711' onclick='hideorshow("x1711","x1712")'>show</button></p>
 <div id='x1712' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram filter-clause" src="images/syntax/filter-clause.gif" />
</div>
<p><b><a href="syntax/literal-value.html">literal-value:</a></b>
<button id='x1713' onclick='hideorshow("x1713","x1714")'>show</button></p>
 <div id='x1714' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</div>
<p><b><a href="syntax/over-clause.html">over-clause:</a></b>
<button id='x1715' onclick='hideorshow("x1715","x1716")'>show</button></p>
 <div id='x1716' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram over-clause" src="images/syntax/over-clause.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x1717' onclick='hideorshow("x1717","x1718")'>show</button></p>
 <div id='x1718' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
<button id='x1719' onclick='hideorshow("x1719","x1720")'>show</button></p>
 <div id='x1720' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</div>
</div>
<p><b><a href="syntax/raise-function.html">raise-function:</a></b>
<button id='x1721' onclick='hideorshow("x1721","x1722")'>show</button></p>
 <div id='x1722' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</div>
<p><b><a href="syntax/type-name.html">type-name:</a></b>
<button id='x1723' onclick='hideorshow("x1723","x1724")'>show</button></p>
 <div id='x1724' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
<button id='x1725' onclick='hideorshow("x1725","x1726")'>show</button></p>
 <div id='x1726' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</div>
</div>
</div>
<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
<button id='x1727' onclick='hideorshow("x1727","x1728")'>show</button></p>
 <div id='x1728' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntax/common-table-expression.html">common-table-expression:</a></b>
<button id='x1729' onclick='hideorshow("x1729","x1730")'>show</button></p>
 <div id='x1730' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
</div>
<p><b><a href="syntax/compound-operator.html">compound-operator:</a></b>
<button id='x1731' onclick='hideorshow("x1731","x1732")'>show</button></p>
 <div id='x1732' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</div>
<p><b><a href="syntax/join-clause.html">join-clause:</a></b>
<button id='x1733' onclick='hideorshow("x1733","x1734")'>show</button></p>
 <div id='x1734' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
<button id='x1735' onclick='hideorshow("x1735","x1736")'>show</button></p>
 <div id='x1736' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</div>
<p><b><a href="syntax/join-operator.html">join-operator:</a></b>
<button id='x1737' onclick='hideorshow("x1737","x1738")'>show</button></p>
 <div id='x1738' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</div>
</div>
<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
<button id='x1739' onclick='hideorshow("x1739","x1740")'>show</button></p>
 <div id='x1740' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</div>
<p><b><a href="syntax/result-column.html">result-column:</a></b>
<button id='x1741' onclick='hideorshow("x1741","x1742")'>show</button></p>
 <div id='x1742' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</div>
<p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
<button id='x1743' onclick='hideorshow("x1743","x1744")'>show</button></p>
 <div id='x1744' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</div>
<p><b><a href="syntax/window-defn.html">window-defn:</a></b>
<button id='x1745' onclick='hideorshow("x1745","x1746")'>show</button></p>
 <div id='x1746' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram window-defn" src="images/syntax/window-defn.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x1747' onclick='hideorshow("x1747","x1748")'>show</button></p>
 <div id='x1748' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
</div>
</div>
<p><b><a href="syntax/upsert-clause.html">upsert-clause:</a></b>
<button id='x1749' onclick='hideorshow("x1749","x1750")'>show</button></p>
 <div id='x1750' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram upsert-clause" src="images/syntax/upsert-clause.gif" />
<p><b><a href="syntax/column-name-list.html">column-name-list:</a></b>
<button id='x1751' onclick='hideorshow("x1751","x1752")'>show</button></p>
 <div id='x1752' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram column-name-list" src="images/syntax/column-name-list.gif" />
</div>
<p><b><a href="syntax/indexed-column.html">indexed-column:</a></b>
<button id='x1753' onclick='hideorshow("x1753","x1754")'>show</button></p>
 <div id='x1754' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram indexed-column" src="images/syntax/indexed-column.gif" />
</div>
</div>
<p><b><a href="syntax/with-clause.html">with-clause:</a></b>
<button id='x1755' onclick='hideorshow("x1755","x1756")'>show</button></p>
 <div id='x1756' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram with-clause" src="images/syntax/with-clause.gif" />
<p><b><a href="syntax/cte-table-name.html">cte-table-name:</a></b>
<button id='x1757' onclick='hideorshow("x1757","x1758")'>show</button></p>
 <div id='x1758' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram cte-table-name" src="images/syntax/cte-table-name.gif" />
</div>
</div>
</div>


<p>The INSERT statement comes in three basic forms.  
</p><ol>
<li><p><b>INSERT INTO </b><i>table</i><b> VALUES(...);</b>
</p><p>The first form (with the "VALUES" keyword) creates one or more
new rows in
an existing table. If the <span class='yyterm'>column-name</span> list after
<span class='yyterm'>table-name</span> is omitted then the number
of values inserted into each row
must be the same as the number of columns in the table. In this case
the result of evaluating the left-most expression from each term of
the VALUES list is inserted into the left-most column of each new row,
and so forth for each subsequent expression. If a <span class='yyterm'>column-name</span>
list is specified, then the number of values in each term of the
VALUE list must match the number of
specified columns. Each of the named columns of the new row is populated
with the results of evaluating the corresponding VALUES expression. Table
columns that do not appear in the column list are populated with the 
<a href="lang_createtable.html#dfltval">default column value</a> (specified as part of the <a href="lang_createtable.html">CREATE TABLE</a> statement), or
with NULL if no <a href="lang_createtable.html#dfltval">default value</a> is specified.

</p></li><li><p><b>INSERT INTO </b><i>table</i><b> SELECT ...;</b>
</p><p>The second form of the INSERT statement contains a <a href="lang_select.html">SELECT</a> statement
instead of a VALUES clause. A new entry is inserted into the table for each
row of data returned by executing the SELECT statement. If a column-list is
specified, the number of columns in the result of the SELECT must be the same
as the number of items in the column-list. Otherwise, if no column-list is
specified, the number of columns in the result of the SELECT must be the same
as the number of columns in the table. Any SELECT statement, including
<a href="lang_select.html#compound">compound SELECTs</a> and SELECT statements with <a href="lang_select.html#orderby">ORDER BY</a> and/or <a href="lang_select.html#limitoffset">LIMIT</a> clauses, 
may be used in an INSERT statement of this form.

</p><p>To avoid a parsing ambiguity, the SELECT statement should always
contain a WHERE clause, even if that clause is simply "WHERE true",
if the <a href="syntax/upsert-clause.html">upsert-clause</a> is present.  Without the WHERE clause, the
parser does not know if the token "ON" is part of a join constraint
on the SELECT, or the beginning of the <a href="syntax/upsert-clause.html">upsert-clause</a>.

</p></li><li><p><b>INSERT INTO </b><i>table</i><b> DEFAULT VALUES;</b>
</p><p>The third form of an INSERT statement is with DEFAULT VALUES.
The INSERT ... DEFAULT VALUES statement inserts a single new row into the
named table. Each column of the new row is populated with its 
<a href="lang_createtable.html#dfltval">default value</a>, or with a NULL if no default value is specified 
as part of the column definition in the <a href="lang_createtable.html">CREATE TABLE</a> statement.
The <a href="syntax/upsert-clause.html">upsert-clause</a> is not supported after DEFAULT VALUES.

</p></li></ol>

<p>
The initial "INSERT" keyword can be replaced by
"REPLACE" or "INSERT OR <i>action</i>" to specify an alternative
constraint <a href="lang_conflict.html">conflict resolution algorithm</a> to use during 
that one INSERT command.
For compatibility with MySQL, the parser allows the use of the
single keyword <a href="lang_replace.html">REPLACE</a> as an 
alias for "INSERT OR REPLACE".

</p><p>The optional "<i>schema-name</i><b>.</b>" prefix on the 
<span class='yyterm'>table-name</span>
is supported for top-level INSERT statements only.  The table name must be
unqualified for INSERT statements that occur within <a href="lang_createtrigger.html">CREATE TRIGGER</a> statements.
Similarly, the "DEFAULT VALUES" form of the INSERT statement is supported for
top-level INSERT statements only and not for INSERT statements within
triggers.
</p><p>

</p><p>The optional "AS <span class='yyterm'>alias</span>" phrase provides an alternative
name for the table into which content is being inserted.  The alias name
can be used within WHERE and SET clauses of the <a href="lang_upsert.html">UPSERT</a>.  If there is no
<a href="syntax/upsert-clause.html">upsert-clause</a>, then the <span class='yyterm'>alias</span> is pointless, but also
harmless.

</p><p>See the separate <a href="lang_upsert.html">UPSERT</a> documentation for the additional trailing
syntax that can cause an INSERT to behave as an UPDATE if the INSERT would
otherwise violate a uniqueness constraint.  The <a href="lang_upsert.html">upsert clause</a> is not
allowed on an "INSERT ... DEFAULT VALUES".
</p>


Changes to Doc/Extra/Core/lang_keywords.html.
1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>SQLite Query Language: SQLite Keywords</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>





|







1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>SQLite Keywords</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93

94








95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>

<div class=nosearch><h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>SQLite Keywords</h2></div></DIV>









<p>The SQL standard specifies a large number of keywords which may not
be used as the names of tables, indices, columns, databases, user-defined
functions, collations, virtual table modules, or any other named object.
The list of keywords is so long that few people can remember them all.
For most SQL code, your safest bet is to never use any English language
word as the name of a user-defined object.</p>

<p>If you want to use a keyword as a name, you need to quote it.  There
are four ways of quoting keywords in SQLite:</p>

<p>
<blockquote>
<table>
<tr>	<td valign="top"><b>'keyword'</b></td><td width="20"></td>
	<td>A keyword in single quotes is a string literal.</td></tr>

<tr>	<td valign="top"><b>"keyword"</b></td><td></td>
	<td>A keyword in double-quotes is an identifier.</td></tr>

<tr>	<td valign="top"><b>&#91;keyword&#93;</b></td><td></td>
	<td>A keyword enclosed in square brackets is 
        an identifier.  This is not standard SQL.  This quoting mechanism
        is used by MS Access and SQL Server and is included in SQLite for
        compatibility.</td></tr>

<tr>	<td valign="top"><b>&#96;keyword&#96;</b></td><td></td>
	<td>A keyword enclosed in grave accents (ASCII code 96) is 
        an identifier.  This is not standard SQL.  This quoting mechanism
        is used by MySQL and is included in SQLite for
        compatibility.</td></tr>
</table>
</blockquote>
</p>

<p>For resilience when confronted with historical SQL statements, SQLite
will sometimes bend the quoting rules above:</p>

<ul>
<li><p>If a keyword in single
quotes (ex: <b>'key'</b> or <b>'glob'</b>) is used in a context where







|

















>
|
>
>
>
>
>
>
>
>












|




















|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<div class=fancy>
<div class=nosearch>
<div class="fancy_title">
SQLite Keywords
</div>
</div>





<p>The SQL standard specifies a large number of keywords which may not
be used as the names of tables, indices, columns, databases, user-defined
functions, collations, virtual table modules, or any other named object.
The list of keywords is so long that few people can remember them all.
For most SQL code, your safest bet is to never use any English language
word as the name of a user-defined object.</p>

<p>If you want to use a keyword as a name, you need to quote it.  There
are four ways of quoting keywords in SQLite:</p>

<p>
</p><blockquote>
<table>
<tr>	<td valign="top"><b>'keyword'</b></td><td width="20"></td>
	<td>A keyword in single quotes is a string literal.</td></tr>

<tr>	<td valign="top"><b>"keyword"</b></td><td></td>
	<td>A keyword in double-quotes is an identifier.</td></tr>

<tr>	<td valign="top"><b>&#91;keyword&#93;</b></td><td></td>
	<td>A keyword enclosed in square brackets is 
        an identifier.  This is not standard SQL.  This quoting mechanism
        is used by MS Access and SQL Server and is included in SQLite for
        compatibility.</td></tr>

<tr>	<td valign="top"><b>&#96;keyword&#96;</b></td><td></td>
	<td>A keyword enclosed in grave accents (ASCII code 96) is 
        an identifier.  This is not standard SQL.  This quoting mechanism
        is used by MySQL and is included in SQLite for
        compatibility.</td></tr>
</table>
</blockquote>


<p>For resilience when confronted with historical SQL statements, SQLite
will sometimes bend the quoting rules above:</p>

<ul>
<li><p>If a keyword in single
quotes (ex: <b>'key'</b> or <b>'glob'</b>) is used in a context where
168
169
170
171
172
173
174
175

176
177
178
179
180
181
182
<a href="c3ref/keyword_check.html">sqlite3_keyword_check()</a> interfaces to determine the keywords
recognized by SQLite at run-time.
Regardless of the compile-time configuration, any identifier that is not on
the following 145 element
list is not a keyword to the SQL parser in SQLite:
</p>

<ol>

<li>ABORT</li>
<li>ACTION</li>
<li>ADD</li>
<li>AFTER</li>
<li>ALL</li>
<li>ALTER</li>
<li>ALWAYS</li>







|
>







177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
<a href="c3ref/keyword_check.html">sqlite3_keyword_check()</a> interfaces to determine the keywords
recognized by SQLite at run-time.
Regardless of the compile-time configuration, any identifier that is not on
the following 145 element
list is not a keyword to the SQL parser in SQLite:
</p>

<div class="columns" style="columns:11em auto;">
<ul style="padding-top:0;">
<li>ABORT</li>
<li>ACTION</li>
<li>ADD</li>
<li>AFTER</li>
<li>ALL</li>
<li>ALTER</li>
<li>ALWAYS</li>
314
315
316
317
318
319
320
321
322
323
<li>VIEW</li>
<li>VIRTUAL</li>
<li>WHEN</li>
<li>WHERE</li>
<li>WINDOW</li>
<li>WITH</li>
<li>WITHOUT</li>
</ol>









|

|
324
325
326
327
328
329
330
331
332
333
<li>VIEW</li>
<li>VIRTUAL</li>
<li>WHEN</li>
<li>WHERE</li>
<li>WINDOW</li>
<li>WITH</li>
<li>WITHOUT</li>
</ul></div>

</ul></div>
Changes to Doc/Extra/Core/lang_naming.html.
1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>SQLite Query Language: Database Object Name Resolution</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>





|







1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>Database Object Name Resolution</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94

95
96
97
98
99
100
101
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<div class=nosearch><h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>Database Object Name Resolution</h2></div>


<p>
  In SQLite, a database object (a table, index, trigger or view) is identified
  by the name of the object and the name of the database that it resides in. 
  Database objects may reside in the main database, the temp database, or in
  an <a href="lang_attach.html">attached database</a>.








|

















|
>







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>



<p>
  In SQLite, a database object (a table, index, trigger or view) is identified
  by the name of the object and the name of the database that it resides in. 
  Database objects may reside in the main database, the temp database, or in
  an <a href="lang_attach.html">attached database</a>.

133
134
135
136
137
138
139
140
141
  Most object references may only resolve to a specific type of object (for
  example a reference that is part of a DROP TABLE statement may only resolve
  to a table object, not an index, trigger or view). However in some contexts 
  (e.g. <a href="lang_reindex.html">REINDEX</a>) an object reference may be resolve to more than one type
  of object. When searching database schemas for a named object, objects of
  types that cannot be used in the context of the reference are always 
  ignored.










<
134
135
136
137
138
139
140
141

  Most object references may only resolve to a specific type of object (for
  example a reference that is part of a DROP TABLE statement may only resolve
  to a table object, not an index, trigger or view). However in some contexts 
  (e.g. <a href="lang_reindex.html">REINDEX</a>) an object reference may be resolve to more than one type
  of object. When searching database schemas for a named object, objects of
  types that cannot be used in the context of the reference are always 
  ignored.


Changes to Doc/Extra/Core/lang_reindex.html.
1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>SQLite Query Language: REINDEX</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>





|







1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>REINDEX</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93










94
95
96
97
98
99
100
101
102


103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>










<div class=nosearch><h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>REINDEX</h2></div><p><b><a href="syntax/reindex-stmt.html">reindex-stmt:</a></b>
<button id='x1815' onclick='hideorshow("x1815","x1816")'>hide</button></p>
 <div id='x1816' class='imgcontainer'>
 <img alt="syntax diagram reindex-stmt" src="images/syntax/reindex-stmt.gif" />
</div>


<p>The REINDEX command is used to delete and recreate indices from scratch.
This is useful when the definition of a collation sequence has changed.


</p>

<p>If the REINDEX keyword is not followed by a collation-sequence or database 
object identifier, then all indices in all attached databases are rebuilt.

<p>If the REINDEX keyword is followed by a collation-sequence name, then
all indices in all attached databases that use the named collation sequences
are recreated. 

<p>Or, if the argument attached to the REINDEX identifies a specific 
database table, then all indices attached to the database table are rebuilt. 
If it identifies a specific database index, then just that index is recreated.

<p>For a command of the form "REINDEX <i>name</i>", a match
against <span class='yyterm'>collation-name</span> takes precedence over a match
against <span class='yyterm'>index-name</span> or <span class='yyterm'>table-name</span>.
This ambiguity in the syntax may be avoided by always specifying a
<span class='yyterm'>schema-name</span> when reindexing a specific table or index.









|

















>
>
>
>
>
>
>
>
>
>
|
|
|





|
>
>





|



|



|




|
<
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133

}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<div class=fancy>
<div class=nosearch>
<div class="fancy_title">
REINDEX
</div>
</div>




<p><b><a href="syntax/reindex-stmt.html">reindex-stmt:</a></b>
<button id='x1759' onclick='hideorshow("x1759","x1760")'>hide</button></p>
 <div id='x1760' class='imgcontainer'>
 <img alt="syntax diagram reindex-stmt" src="images/syntax/reindex-stmt.gif" />
</div>


<p>The REINDEX command is used to delete and recreate indices from scratch.
This is useful when the definition of a collation sequence has changed, or
when there are <a href="expridx.html">indexes on expressions</a> involving a function whose definition
has changed.
</p>

<p>If the REINDEX keyword is not followed by a collation-sequence or database 
object identifier, then all indices in all attached databases are rebuilt.

</p><p>If the REINDEX keyword is followed by a collation-sequence name, then
all indices in all attached databases that use the named collation sequences
are recreated. 

</p><p>Or, if the argument attached to the REINDEX identifies a specific 
database table, then all indices attached to the database table are rebuilt. 
If it identifies a specific database index, then just that index is recreated.

</p><p>For a command of the form "REINDEX <i>name</i>", a match
against <span class='yyterm'>collation-name</span> takes precedence over a match
against <span class='yyterm'>index-name</span> or <span class='yyterm'>table-name</span>.
This ambiguity in the syntax may be avoided by always specifying a
<span class='yyterm'>schema-name</span> when reindexing a specific table or index.
</p>

Changes to Doc/Extra/Core/lang_replace.html.
1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>SQLite Query Language: REPLACE</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>





|







1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>REPLACE</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93

94







95
96
97
98
99
100
101
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>

<div class=nosearch><h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>REPLACE</h2></div>








<p>The REPLACE command is an alias for the "<a href="lang_conflict.html">INSERT OR REPLACE</a>"
variant of the <a href="lang_insert.html">INSERT</a> command.  
This alias is provided for compatibility other SQL database engines.  See the 
<a href="lang_insert.html">INSERT</a> command documentation for additional information.</p>  









|

















>
|
>
>
>
>
>
>
>




|

<
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108

}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<div class=fancy>
<div class=nosearch>
<div class="fancy_title">
REPLACE
</div>
</div>




<p>The REPLACE command is an alias for the "<a href="lang_conflict.html">INSERT OR REPLACE</a>"
variant of the <a href="lang_insert.html">INSERT</a> command.  
This alias is provided for compatibility other SQL database engines.  See the 
<a href="lang_insert.html">INSERT</a> command documentation for additional information.</p>


Changes to Doc/Extra/Core/lang_savepoint.html.
1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>SQLite Query Language: SAVEPOINT</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>





|







1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>Savepoints</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93












94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109


110
111
112
113
114
115
116
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>












<div class=nosearch><h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>SAVEPOINT</h2></div><p><b><a href="syntax/savepoint-stmt.html">savepoint-stmt:</a></b>
<button id='x1293' onclick='hideorshow("x1293","x1294")'>hide</button></p>
 <div id='x1294' class='imgcontainer'>
 <img alt="syntax diagram savepoint-stmt" src="images/syntax/savepoint-stmt.gif" />
</div>
<p><b><a href="syntax/release-stmt.html">release-stmt:</a></b>
<button id='x1295' onclick='hideorshow("x1295","x1296")'>hide</button></p>
 <div id='x1296' class='imgcontainer'>
 <img alt="syntax diagram release-stmt" src="images/syntax/release-stmt.gif" />
</div>
<p><b><a href="syntax/rollback-stmt.html">rollback-stmt:</a></b>
<button id='x1297' onclick='hideorshow("x1297","x1298")'>hide</button></p>
 <div id='x1298' class='imgcontainer'>
 <img alt="syntax diagram rollback-stmt" src="images/syntax/rollback-stmt.gif" />
</div>




<p> SAVEPOINTs are a method of creating transactions, similar to
<a href="lang_transaction.html">BEGIN</a> and <a href="lang_transaction.html">COMMIT</a>, except that the SAVEPOINT and RELEASE commands
are named and may be nested.</p>

<p> The SAVEPOINT command starts a new transaction with a name.
The transaction names need not be unique.







|

















>
>
>
>
>
>
>
>
>
>
>
>
|
|
|



|
|



|
|



>
>







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<div class=fancy>
<div class=nosearch>
<div class="fancy_title">
Savepoints
</div>
</div>




<h1 id="syntax"><span>1. </span>Syntax</h1>

<p><b><a href="syntax/savepoint-stmt.html">savepoint-stmt:</a></b>
<button id='x1761' onclick='hideorshow("x1761","x1762")'>hide</button></p>
 <div id='x1762' class='imgcontainer'>
 <img alt="syntax diagram savepoint-stmt" src="images/syntax/savepoint-stmt.gif" />
</div>
<p><b><a href="syntax/release-stmt.html">release-stmt:</a></b>
<button id='x1763' onclick='hideorshow("x1763","x1764")'>hide</button></p>
 <div id='x1764' class='imgcontainer'>
 <img alt="syntax diagram release-stmt" src="images/syntax/release-stmt.gif" />
</div>
<p><b><a href="syntax/rollback-stmt.html">rollback-stmt:</a></b>
<button id='x1765' onclick='hideorshow("x1765","x1766")'>hide</button></p>
 <div id='x1766' class='imgcontainer'>
 <img alt="syntax diagram rollback-stmt" src="images/syntax/rollback-stmt.gif" />
</div>


<h1 id="savepoints"><span>2. </span>Savepoints</h1>

<p> SAVEPOINTs are a method of creating transactions, similar to
<a href="lang_transaction.html">BEGIN</a> and <a href="lang_transaction.html">COMMIT</a>, except that the SAVEPOINT and RELEASE commands
are named and may be nested.</p>

<p> The SAVEPOINT command starts a new transaction with a name.
The transaction names need not be unique.
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
erases marks from the timeline without actually making any
changes to the database.
</p></li>
</ul>



<h3>Transaction Nesting Rules</h3>

<p>The last transaction started will be the first
transaction committed or rolled back.</p>

<p>The <a href="lang_transaction.html">BEGIN</a> command only works if the transaction stack is empty, or
in other words if there are no pending transactions.  If the transaction
stack is not empty when the <a href="lang_transaction.html">BEGIN</a> command is invoked, then the command







|







191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
erases marks from the timeline without actually making any
changes to the database.
</p></li>
</ul>



<h1 id="transaction_nesting_rules"><span>3. </span>Transaction Nesting Rules</h1>

<p>The last transaction started will be the first
transaction committed or rolled back.</p>

<p>The <a href="lang_transaction.html">BEGIN</a> command only works if the transaction stack is empty, or
in other words if there are no pending transactions.  If the transaction
stack is not empty when the <a href="lang_transaction.html">BEGIN</a> command is invoked, then the command
209
210
211
212
213
214
215
216
217
<p>The ROLLBACK command with a TO clause rolls back transactions going
backwards in time back to the most recent SAVEPOINT with a matching name.
The SAVEPOINT with the matching name remains on the transaction stack,
but all database changes that occurred after that SAVEPOINT was created
are rolled back.  If the savepoint-name in a ROLLBACK TO command does not
match any SAVEPOINT on the stack, then the ROLLBACK command fails with an
error and leaves the state of the database unchanged.</p>










<
223
224
225
226
227
228
229
230

<p>The ROLLBACK command with a TO clause rolls back transactions going
backwards in time back to the most recent SAVEPOINT with a matching name.
The SAVEPOINT with the matching name remains on the transaction stack,
but all database changes that occurred after that SAVEPOINT was created
are rolled back.  If the savepoint-name in a ROLLBACK TO command does not
match any SAVEPOINT on the stack, then the ROLLBACK command fails with an
error and leaves the state of the database unchanged.</p>


Changes to Doc/Extra/Core/lang_select.html.
1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>SQLite Query Language: SELECT</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>





|







1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>SELECT</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93







































94
95
96
97
98









































































































99
100




101












102




























103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122









































































































123
124
125
126
127
128
129
130
131


132





























133
134
135
136
137
138
139
140
141
142
143
144




145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>







































<div class=nosearch><h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>SELECT</h2></div><p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
<button id='x1863' onclick='hideorshow("x1863","x1864")'>hide</button></p>
 <div id='x1864' class='imgcontainer'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntax/common-table-expression.html">common-table-expression:</a></b>









































































































<button id='x1865' onclick='hideorshow("x1865","x1866")'>show</button></p>
 <div id='x1866' style='display:none;' class='imgcontainer'>




 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />












</div>




























<p><b><a href="syntax/compound-operator.html">compound-operator:</a></b>
<button id='x1867' onclick='hideorshow("x1867","x1868")'>show</button></p>
 <div id='x1868' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</div>
<p><b><a href="syntax/expr.html">expr:</a></b>
<button id='x1869' onclick='hideorshow("x1869","x1870")'>show</button></p>
 <div id='x1870' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntax/filter-clause.html">filter-clause:</a></b>
<button id='x1871' onclick='hideorshow("x1871","x1872")'>show</button></p>
 <div id='x1872' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram filter-clause" src="images/syntax/filter-clause.gif" />
</div>
<p><b><a href="syntax/literal-value.html">literal-value:</a></b>
<button id='x1873' onclick='hideorshow("x1873","x1874")'>show</button></p>
 <div id='x1874' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</div>
<p><b><a href="syntax/over-clause.html">over-clause:</a></b>









































































































<button id='x1875' onclick='hideorshow("x1875","x1876")'>show</button></p>
 <div id='x1876' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram over-clause" src="images/syntax/over-clause.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x1877' onclick='hideorshow("x1877","x1878")'>show</button></p>
 <div id='x1878' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
</div>


<p><b><a href="syntax/raise-function.html">raise-function:</a></b>





























<button id='x1879' onclick='hideorshow("x1879","x1880")'>show</button></p>
 <div id='x1880' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</div>
<p><b><a href="syntax/type-name.html">type-name:</a></b>
<button id='x1881' onclick='hideorshow("x1881","x1882")'>show</button></p>
 <div id='x1882' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
<button id='x1883' onclick='hideorshow("x1883","x1884")'>show</button></p>
 <div id='x1884' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />




</div>
</div>
</div>
<p><b><a href="syntax/join-clause.html">join-clause:</a></b>
<button id='x1885' onclick='hideorshow("x1885","x1886")'>show</button></p>
 <div id='x1886' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
<button id='x1887' onclick='hideorshow("x1887","x1888")'>show</button></p>
 <div id='x1888' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</div>
<p><b><a href="syntax/join-operator.html">join-operator:</a></b>
<button id='x1889' onclick='hideorshow("x1889","x1890")'>show</button></p>
 <div id='x1890' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</div>
</div>
<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
<button id='x1891' onclick='hideorshow("x1891","x1892")'>show</button></p>
 <div id='x1892' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</div>
<p><b><a href="syntax/result-column.html">result-column:</a></b>
<button id='x1893' onclick='hideorshow("x1893","x1894")'>show</button></p>
 <div id='x1894' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</div>
<p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
<button id='x1895' onclick='hideorshow("x1895","x1896")'>show</button></p>







|

















>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
|


>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
>
>
>
>

>
>
>
>
>
>
>
>
>
>
>
>

>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

|
|



|
|


|
|



|
|



>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>


|






>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
|
<
|


|
|


|
>
>
>
>

<
<

|
|


|
|



|
|



<
<
<
<
<







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459

460
461
462
463
464
465
466
467
468
469
470
471
472


473
474
475
476
477
478
479
480
481
482
483
484
485
486
487





488
489
490
491
492
493
494
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<div class=fancy>
<div class=nosearch>
<div class="fancy_title">
SELECT
</div>
<div class="fancy_toc">
<a onclick="toggle_toc()">
<span class="fancy_toc_mark" id="toc_mk">&#x25ba;</span>
Table Of Contents
</a>
<div id="toc_sub"><div class="fancy-toc1"><a href="#overview">1. Overview</a></div>
<div class="fancy-toc1"><a href="#simple_select_processing">2. Simple Select Processing</a></div>
<div class="fancy-toc1"><a href="#compound_select_statements">3. Compound Select Statements</a></div>
<div class="fancy-toc1"><a href="#the_order_by_clause">4. The ORDER BY clause</a></div>
<div class="fancy-toc1"><a href="#the_limit_clause">5. The LIMIT clause</a></div>
<div class="fancy-toc1"><a href="#the_values_clause">6. The VALUES clause</a></div>
<div class="fancy-toc1"><a href="#the_with_clause">7. The WITH Clause</a></div>
<div class="fancy-toc1"><a href="#table_valued_functions_in_the_from_clause">8. Table-valued Functions In The FROM Clause</a></div>
</div>
</div>
<script>
function toggle_toc(){
var sub = document.getElementById("toc_sub")
var mk = document.getElementById("toc_mk")
if( sub.style.display!="block" ){
sub.style.display = "block";
mk.innerHTML = "&#x25bc;";
} else {
sub.style.display = "none";
mk.innerHTML = "&#x25ba;";
}
}
</script>
</div>




<h1 id="overview"><span>1. </span>Overview</h1>
<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
<button id='x1767' onclick='hideorshow("x1767","x1768")'>hide</button></p>
 <div id='x1768' class='imgcontainer'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntax/common-table-expression.html">common-table-expression:</a></b>
<button id='x1769' onclick='hideorshow("x1769","x1770")'>show</button></p>
 <div id='x1770' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
</div>
<p><b><a href="syntax/compound-operator.html">compound-operator:</a></b>
<button id='x1771' onclick='hideorshow("x1771","x1772")'>show</button></p>
 <div id='x1772' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</div>
<p><b><a href="syntax/expr.html">expr:</a></b>
<button id='x1773' onclick='hideorshow("x1773","x1774")'>show</button></p>
 <div id='x1774' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntax/filter-clause.html">filter-clause:</a></b>
<button id='x1775' onclick='hideorshow("x1775","x1776")'>show</button></p>
 <div id='x1776' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram filter-clause" src="images/syntax/filter-clause.gif" />
</div>
<p><b><a href="syntax/literal-value.html">literal-value:</a></b>
<button id='x1777' onclick='hideorshow("x1777","x1778")'>show</button></p>
 <div id='x1778' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</div>
<p><b><a href="syntax/over-clause.html">over-clause:</a></b>
<button id='x1779' onclick='hideorshow("x1779","x1780")'>show</button></p>
 <div id='x1780' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram over-clause" src="images/syntax/over-clause.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x1781' onclick='hideorshow("x1781","x1782")'>show</button></p>
 <div id='x1782' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
</div>
<p><b><a href="syntax/raise-function.html">raise-function:</a></b>
<button id='x1783' onclick='hideorshow("x1783","x1784")'>show</button></p>
 <div id='x1784' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</div>
<p><b><a href="syntax/type-name.html">type-name:</a></b>
<button id='x1785' onclick='hideorshow("x1785","x1786")'>show</button></p>
 <div id='x1786' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
<button id='x1787' onclick='hideorshow("x1787","x1788")'>show</button></p>
 <div id='x1788' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</div>
</div>
</div>
<p><b><a href="syntax/join-clause.html">join-clause:</a></b>
<button id='x1789' onclick='hideorshow("x1789","x1790")'>show</button></p>
 <div id='x1790' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
<button id='x1791' onclick='hideorshow("x1791","x1792")'>show</button></p>
 <div id='x1792' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</div>
<p><b><a href="syntax/join-operator.html">join-operator:</a></b>
<button id='x1793' onclick='hideorshow("x1793","x1794")'>show</button></p>
 <div id='x1794' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</div>
</div>
<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
<button id='x1795' onclick='hideorshow("x1795","x1796")'>show</button></p>
 <div id='x1796' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</div>
<p><b><a href="syntax/result-column.html">result-column:</a></b>
<button id='x1797' onclick='hideorshow("x1797","x1798")'>show</button></p>
 <div id='x1798' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</div>
<p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
<button id='x1799' onclick='hideorshow("x1799","x1800")'>show</button></p>
 <div id='x1800' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</div>
<p><b><a href="syntax/window-defn.html">window-defn:</a></b>
<button id='x1801' onclick='hideorshow("x1801","x1802")'>show</button></p>
 <div id='x1802' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram window-defn" src="images/syntax/window-defn.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x1803' onclick='hideorshow("x1803","x1804")'>show</button></p>
 <div id='x1804' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
</div>
</div>



<p>The SELECT statement is used to query the database.  The
result of a SELECT is zero or more rows of data where each row
has a fixed number of columns.  A SELECT statement does not make
any changes to the database.

</p><p>The "<a href="syntax/select-stmt.html">select-stmt</a>" syntax diagram above attempts to show as much of the
SELECT statement syntax as possible in a single diagram, because some readers
find that helpful.  The following "<a href="syntax/factored-select-stmt.html">factored-select-stmt</a>" is an alternative
syntax diagrams that expresses the same syntax but tries to break the syntax 
down into smaller chunks.

<p><b><a href="syntax/factored-select-stmt.html">factored-select-stmt:</a></b>
<button id='x1805' onclick='hideorshow("x1805","x1806")'>show</button></p>
 <div id='x1806' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram factored-select-stmt" src="images/syntax/factored-select-stmt.gif" />
<p><b><a href="syntax/common-table-expression.html">common-table-expression:</a></b>
<button id='x1807' onclick='hideorshow("x1807","x1808")'>show</button></p>
 <div id='x1808' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
<button id='x1809' onclick='hideorshow("x1809","x1810")'>show</button></p>
 <div id='x1810' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntax/join-clause.html">join-clause:</a></b>
<button id='x1811' onclick='hideorshow("x1811","x1812")'>show</button></p>
 <div id='x1812' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
<button id='x1813' onclick='hideorshow("x1813","x1814")'>show</button></p>
 <div id='x1814' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</div>
<p><b><a href="syntax/join-operator.html">join-operator:</a></b>
<button id='x1815' onclick='hideorshow("x1815","x1816")'>show</button></p>
 <div id='x1816' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</div>
</div>
<p><b><a href="syntax/result-column.html">result-column:</a></b>
<button id='x1817' onclick='hideorshow("x1817","x1818")'>show</button></p>
 <div id='x1818' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</div>
<p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
<button id='x1819' onclick='hideorshow("x1819","x1820")'>show</button></p>
 <div id='x1820' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</div>
<p><b><a href="syntax/window-defn.html">window-defn:</a></b>
<button id='x1821' onclick='hideorshow("x1821","x1822")'>show</button></p>
 <div id='x1822' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram window-defn" src="images/syntax/window-defn.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x1823' onclick='hideorshow("x1823","x1824")'>show</button></p>
 <div id='x1824' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
</div>
</div>
</div>
<p><b><a href="syntax/compound-operator.html">compound-operator:</a></b>
<button id='x1825' onclick='hideorshow("x1825","x1826")'>show</button></p>
 <div id='x1826' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</div>
<p><b><a href="syntax/expr.html">expr:</a></b>
<button id='x1827' onclick='hideorshow("x1827","x1828")'>show</button></p>
 <div id='x1828' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntax/filter-clause.html">filter-clause:</a></b>
<button id='x1829' onclick='hideorshow("x1829","x1830")'>show</button></p>
 <div id='x1830' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram filter-clause" src="images/syntax/filter-clause.gif" />
</div>
<p><b><a href="syntax/literal-value.html">literal-value:</a></b>
<button id='x1831' onclick='hideorshow("x1831","x1832")'>show</button></p>
 <div id='x1832' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</div>
<p><b><a href="syntax/over-clause.html">over-clause:</a></b>
<button id='x1833' onclick='hideorshow("x1833","x1834")'>show</button></p>
 <div id='x1834' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram over-clause" src="images/syntax/over-clause.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x1835' onclick='hideorshow("x1835","x1836")'>show</button></p>
 <div id='x1836' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
</div>
<p><b><a href="syntax/raise-function.html">raise-function:</a></b>
<button id='x1837' onclick='hideorshow("x1837","x1838")'>show</button></p>
 <div id='x1838' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</div>
<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
<button id='x1839' onclick='hideorshow("x1839","x1840")'>show</button></p>
 <div id='x1840' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntax/join-clause.html">join-clause:</a></b>
<button id='x1841' onclick='hideorshow("x1841","x1842")'>show</button></p>
 <div id='x1842' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
<button id='x1843' onclick='hideorshow("x1843","x1844")'>show</button></p>
 <div id='x1844' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</div>
<p><b><a href="syntax/join-operator.html">join-operator:</a></b>
<button id='x1845' onclick='hideorshow("x1845","x1846")'>show</button></p>
 <div id='x1846' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</div>
</div>
<p><b><a href="syntax/result-column.html">result-column:</a></b>
<button id='x1847' onclick='hideorshow("x1847","x1848")'>show</button></p>
 <div id='x1848' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</div>
<p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
<button id='x1849' onclick='hideorshow("x1849","x1850")'>show</button></p>
 <div id='x1850' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</div>
<p><b><a href="syntax/window-defn.html">window-defn:</a></b>
<button id='x1851' onclick='hideorshow("x1851","x1852")'>show</button></p>
 <div id='x1852' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram window-defn" src="images/syntax/window-defn.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x1853' onclick='hideorshow("x1853","x1854")'>show</button></p>
 <div id='x1854' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
</div>
</div>
<p><b><a href="syntax/type-name.html">type-name:</a></b>
<button id='x1855' onclick='hideorshow("x1855","x1856")'>show</button></p>
 <div id='x1856' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
<button id='x1857' onclick='hideorshow("x1857","x1858")'>show</button></p>
 <div id='x1858' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</div>
</div>
</div>
<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
<button id='x1859' onclick='hideorshow("x1859","x1860")'>show</button></p>
 <div id='x1860' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</div>
<p><b><a href="syntax/select-core.html">select-core:</a></b>
<button id='x1861' onclick='hideorshow("x1861","x1862")'>show</button></p>
 <div id='x1862' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram select-core" src="images/syntax/select-core.gif" />
<p><b><a href="syntax/join-clause.html">join-clause:</a></b>
<button id='x1863' onclick='hideorshow("x1863","x1864")'>show</button></p>
 <div id='x1864' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
<button id='x1865' onclick='hideorshow("x1865","x1866")'>show</button></p>
 <div id='x1866' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</div>
<p><b><a href="syntax/join-operator.html">join-operator:</a></b>
<button id='x1867' onclick='hideorshow("x1867","x1868")'>show</button></p>
 <div id='x1868' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</div>
</div>
<p><b><a href="syntax/result-column.html">result-column:</a></b>
<button id='x1869' onclick='hideorshow("x1869","x1870")'>show</button></p>
 <div id='x1870' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</div>
<p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
<button id='x1871' onclick='hideorshow("x1871","x1872")'>show</button></p>
 <div id='x1872' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
<button id='x1873' onclick='hideorshow("x1873","x1874")'>show</button></p>
 <div id='x1874' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
</div>
</div>
<p><b><a href="syntax/window-defn.html">window-defn:</a></b>
<button id='x1875' onclick='hideorshow("x1875","x1876")'>show</button></p>
 <div id='x1876' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram window-defn" src="images/syntax/window-defn.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x1877' onclick='hideorshow("x1877","x1878")'>show</button></p>
 <div id='x1878' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
</div>
</div>
</div>


</p><p>Note that there are paths through the syntax diagrams that
are not allowed in practice.  Some examples:
</p><ul>
<li>A <a href="lang_select.html#values">VALUES</a> clause can be the first element in a <a href="lang_select.html#compound">compound SELECT</a>
    that uses a <a href="lang_with.html">WITH</a> clause, but a <a href="lang_select.html#simpleselect">simple SELECT</a> that consists of
    just a <a href="lang_select.html#values">VALUES</a> clause cannot be preceded by a <a href="lang_with.html">WITH</a> clause.
</li><li>The <a href="lang_with.html">WITH</a> clause must occur on the first SELECT of a <a href="lang_select.html#compound">compound SELECT</a>.
    It cannot follow a <a href="syntax/compound-operator.html">compound-operator</a>.
</li></ul>

<p>These and other similar syntax restrictions are described in the text.

</p><p>The SELECT statement is the most complicated command in the SQL language.
To make the description easier to follow, some of the passages below describe
the way the data returned by a SELECT statement is determined as a series of
steps. It is important to keep in mind that this is purely illustrative -
in practice neither SQLite nor any other SQL engine is required to follow 
this or any other specific process.

<a name="simpleselect"></a>

</p><h1 id="simple_select_processing"><span>2. </span>Simple Select Processing</h1>

<p>The core of a SELECT statement is a "simple SELECT" shown by the
<a href="syntax/select-core.html">select-core</a> and <a href="syntax/simple-select-stmt.html">simple-select-stmt</a> syntax diagrams below.  
In practice, most SELECT statements are simple SELECT statements.

<p><b><a href="syntax/simple-select-stmt.html">simple-select-stmt:</a></b>
<button id='x1879' onclick='hideorshow("x1879","x1880")'>hide</button></p>
 <div id='x1880' class='imgcontainer'>
 <img alt="syntax diagram simple-select-stmt" src="images/syntax/simple-select-stmt.gif" />

<p><b><a href="syntax/common-table-expression.html">common-table-expression:</a></b>
<button id='x1881' onclick='hideorshow("x1881","x1882")'>show</button></p>
 <div id='x1882' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
<button id='x1883' onclick='hideorshow("x1883","x1884")'>show</button></p>
 <div id='x1884' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntax/compound-operator.html">compound-operator:</a></b>
<button id='x1885' onclick='hideorshow("x1885","x1886")'>show</button></p>
 <div id='x1886' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</div>


<p><b><a href="syntax/join-clause.html">join-clause:</a></b>
<button id='x1887' onclick='hideorshow("x1887","x1888")'>show</button></p>
 <div id='x1888' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
<button id='x1889' onclick='hideorshow("x1889","x1890")'>show</button></p>
 <div id='x1890' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</div>
<p><b><a href="syntax/join-operator.html">join-operator:</a></b>
<button id='x1891' onclick='hideorshow("x1891","x1892")'>show</button></p>
 <div id='x1892' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</div>
</div>





<p><b><a href="syntax/result-column.html">result-column:</a></b>
<button id='x1893' onclick='hideorshow("x1893","x1894")'>show</button></p>
 <div id='x1894' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</div>
<p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
<button id='x1895' onclick='hideorshow("x1895","x1896")'>show</button></p>
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210

211
212
213
214

215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373





374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885

886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x1899' onclick='hideorshow("x1899","x1900")'>show</button></p>
 <div id='x1900' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
</div>
</div>



<p>The SELECT statement is used to query the database.  The
result of a SELECT is zero or more rows of data where each row
has a fixed number of columns.  A SELECT statement does not make
any changes to the database.

<p>The "<a href="syntax/select-stmt.html">select-stmt</a>" syntax diagram above attempts to show as much of the
SELECT statement syntax as possible in a single diagram, because some readers
find that helpful.  The following "<a href="syntax/factored-select-stmt.html">factored-select-stmt</a>" is an alternative
syntax diagrams that expresses the same syntax but tries to break the syntax 
down into smaller chunks.

<p><b><a href="syntax/factored-select-stmt.html">factored-select-stmt:</a></b>
<button id='x1901' onclick='hideorshow("x1901","x1902")'>show</button></p>
 <div id='x1902' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram factored-select-stmt" src="images/syntax/factored-select-stmt.gif" />
<p><b><a href="syntax/common-table-expression.html">common-table-expression:</a></b>
<button id='x1903' onclick='hideorshow("x1903","x1904")'>show</button></p>
 <div id='x1904' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />

<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
<button id='x1905' onclick='hideorshow("x1905","x1906")'>show</button></p>
 <div id='x1906' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />

<p><b><a href="syntax/join-clause.html">join-clause:</a></b>
<button id='x1907' onclick='hideorshow("x1907","x1908")'>show</button></p>
 <div id='x1908' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
<button id='x1909' onclick='hideorshow("x1909","x1910")'>show</button></p>
 <div id='x1910' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</div>
<p><b><a href="syntax/join-operator.html">join-operator:</a></b>
<button id='x1911' onclick='hideorshow("x1911","x1912")'>show</button></p>
 <div id='x1912' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</div>
</div>
<p><b><a href="syntax/result-column.html">result-column:</a></b>
<button id='x1913' onclick='hideorshow("x1913","x1914")'>show</button></p>
 <div id='x1914' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</div>
<p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
<button id='x1915' onclick='hideorshow("x1915","x1916")'>show</button></p>
 <div id='x1916' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</div>
<p><b><a href="syntax/window-defn.html">window-defn:</a></b>
<button id='x1917' onclick='hideorshow("x1917","x1918")'>show</button></p>
 <div id='x1918' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram window-defn" src="images/syntax/window-defn.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x1919' onclick='hideorshow("x1919","x1920")'>show</button></p>
 <div id='x1920' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
</div>
</div>
</div>
<p><b><a href="syntax/compound-operator.html">compound-operator:</a></b>
<button id='x1921' onclick='hideorshow("x1921","x1922")'>show</button></p>
 <div id='x1922' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</div>
<p><b><a href="syntax/expr.html">expr:</a></b>
<button id='x1923' onclick='hideorshow("x1923","x1924")'>show</button></p>
 <div id='x1924' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntax/filter-clause.html">filter-clause:</a></b>
<button id='x1925' onclick='hideorshow("x1925","x1926")'>show</button></p>
 <div id='x1926' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram filter-clause" src="images/syntax/filter-clause.gif" />
</div>
<p><b><a href="syntax/literal-value.html">literal-value:</a></b>
<button id='x1927' onclick='hideorshow("x1927","x1928")'>show</button></p>
 <div id='x1928' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</div>
<p><b><a href="syntax/over-clause.html">over-clause:</a></b>
<button id='x1929' onclick='hideorshow("x1929","x1930")'>show</button></p>
 <div id='x1930' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram over-clause" src="images/syntax/over-clause.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x1931' onclick='hideorshow("x1931","x1932")'>show</button></p>
 <div id='x1932' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
</div>
<p><b><a href="syntax/raise-function.html">raise-function:</a></b>
<button id='x1933' onclick='hideorshow("x1933","x1934")'>show</button></p>
 <div id='x1934' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</div>
<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
<button id='x1935' onclick='hideorshow("x1935","x1936")'>show</button></p>
 <div id='x1936' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntax/join-clause.html">join-clause:</a></b>
<button id='x1937' onclick='hideorshow("x1937","x1938")'>show</button></p>
 <div id='x1938' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
<button id='x1939' onclick='hideorshow("x1939","x1940")'>show</button></p>
 <div id='x1940' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</div>
<p><b><a href="syntax/join-operator.html">join-operator:</a></b>
<button id='x1941' onclick='hideorshow("x1941","x1942")'>show</button></p>
 <div id='x1942' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</div>
</div>
<p><b><a href="syntax/result-column.html">result-column:</a></b>
<button id='x1943' onclick='hideorshow("x1943","x1944")'>show</button></p>
 <div id='x1944' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</div>
<p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
<button id='x1945' onclick='hideorshow("x1945","x1946")'>show</button></p>
 <div id='x1946' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</div>
<p><b><a href="syntax/window-defn.html">window-defn:</a></b>
<button id='x1947' onclick='hideorshow("x1947","x1948")'>show</button></p>
 <div id='x1948' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram window-defn" src="images/syntax/window-defn.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x1949' onclick='hideorshow("x1949","x1950")'>show</button></p>
 <div id='x1950' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
</div>
</div>
<p><b><a href="syntax/type-name.html">type-name:</a></b>
<button id='x1951' onclick='hideorshow("x1951","x1952")'>show</button></p>
 <div id='x1952' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
<button id='x1953' onclick='hideorshow("x1953","x1954")'>show</button></p>
 <div id='x1954' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</div>
</div>
</div>
<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
<button id='x1955' onclick='hideorshow("x1955","x1956")'>show</button></p>
 <div id='x1956' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</div>
<p><b><a href="syntax/select-core.html">select-core:</a></b>
<button id='x1957' onclick='hideorshow("x1957","x1958")'>show</button></p>
 <div id='x1958' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram select-core" src="images/syntax/select-core.gif" />
<p><b><a href="syntax/join-clause.html">join-clause:</a></b>
<button id='x1959' onclick='hideorshow("x1959","x1960")'>show</button></p>
 <div id='x1960' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
<button id='x1961' onclick='hideorshow("x1961","x1962")'>show</button></p>
 <div id='x1962' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</div>
<p><b><a href="syntax/join-operator.html">join-operator:</a></b>
<button id='x1963' onclick='hideorshow("x1963","x1964")'>show</button></p>
 <div id='x1964' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</div>
</div>
<p><b><a href="syntax/result-column.html">result-column:</a></b>
<button id='x1965' onclick='hideorshow("x1965","x1966")'>show</button></p>
 <div id='x1966' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</div>
<p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
<button id='x1967' onclick='hideorshow("x1967","x1968")'>show</button></p>
 <div id='x1968' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
<button id='x1969' onclick='hideorshow("x1969","x1970")'>show</button></p>
 <div id='x1970' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />





</div>
</div>
<p><b><a href="syntax/window-defn.html">window-defn:</a></b>
<button id='x1971' onclick='hideorshow("x1971","x1972")'>show</button></p>
 <div id='x1972' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram window-defn" src="images/syntax/window-defn.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x1973' onclick='hideorshow("x1973","x1974")'>show</button></p>
 <div id='x1974' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
</div>
</div>
</div>


<p>Note that there are paths through the syntax diagrams that
are not allowed in practice.  Some examples:
<ul>
<li>A <a href="lang_select.html#values">VALUES</a> clause can be the first element in a <a href="lang_select.html#compound">compound SELECT</a>
    that uses a <a href="lang_with.html">WITH</a> clause, but a <a href="lang_select.html#simpleselect">simple SELECT</a> that consists of
    just a <a href="lang_select.html#values">VALUES</a> clause cannot be preceded by a <a href="lang_with.html">WITH</a> clause.
<li>The <a href="lang_with.html">WITH</a> clause must occur on the first SELECT of a <a href="lang_select.html#compound">compound SELECT</a>.
    It cannot follow a <a href="syntax/compound-operator.html">compound-operator</a>.
</ul>
These and other similar syntax restrictions are described in the text.

<p>The SELECT statement is the most complicated command in the SQL language.
To make the description easier to follow, some of the passages below describe
the way the data returned by a SELECT statement is determined as a series of
steps. It is important to keep in mind that this is purely illustrative -
in practice neither SQLite nor any other SQL engine is required to follow 
this or any other specific process.

<a name="simpleselect"></a>

<h3>Simple Select Processing</h3>

<p>The core of a SELECT statement is a "simple SELECT" shown by the
<a href="syntax/select-core.html">select-core</a> and <a href="syntax/simple-select-stmt.html">simple-select-stmt</a> syntax diagrams below.  
In practice, most SELECT statements are simple SELECT statements.

<p><b><a href="syntax/simple-select-stmt.html">simple-select-stmt:</a></b>
<button id='x1975' onclick='hideorshow("x1975","x1976")'>hide</button></p>
 <div id='x1976' class='imgcontainer'>
 <img alt="syntax diagram simple-select-stmt" src="images/syntax/simple-select-stmt.gif" />
<p><b><a href="syntax/common-table-expression.html">common-table-expression:</a></b>
<button id='x1977' onclick='hideorshow("x1977","x1978")'>show</button></p>
 <div id='x1978' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
<button id='x1979' onclick='hideorshow("x1979","x1980")'>show</button></p>
 <div id='x1980' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntax/compound-operator.html">compound-operator:</a></b>
<button id='x1981' onclick='hideorshow("x1981","x1982")'>show</button></p>
 <div id='x1982' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</div>
<p><b><a href="syntax/join-clause.html">join-clause:</a></b>
<button id='x1983' onclick='hideorshow("x1983","x1984")'>show</button></p>
 <div id='x1984' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
<button id='x1985' onclick='hideorshow("x1985","x1986")'>show</button></p>
 <div id='x1986' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</div>
<p><b><a href="syntax/join-operator.html">join-operator:</a></b>
<button id='x1987' onclick='hideorshow("x1987","x1988")'>show</button></p>
 <div id='x1988' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</div>
</div>
<p><b><a href="syntax/result-column.html">result-column:</a></b>
<button id='x1989' onclick='hideorshow("x1989","x1990")'>show</button></p>
 <div id='x1990' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</div>
<p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
<button id='x1991' onclick='hideorshow("x1991","x1992")'>show</button></p>
 <div id='x1992' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</div>
<p><b><a href="syntax/window-defn.html">window-defn:</a></b>
<button id='x1993' onclick='hideorshow("x1993","x1994")'>show</button></p>
 <div id='x1994' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram window-defn" src="images/syntax/window-defn.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x1995' onclick='hideorshow("x1995","x1996")'>show</button></p>
 <div id='x1996' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
</div>
</div>
</div>
<p><b><a href="syntax/expr.html">expr:</a></b>
<button id='x1997' onclick='hideorshow("x1997","x1998")'>show</button></p>
 <div id='x1998' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntax/filter-clause.html">filter-clause:</a></b>
<button id='x1999' onclick='hideorshow("x1999","x2000")'>show</button></p>
 <div id='x2000' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram filter-clause" src="images/syntax/filter-clause.gif" />
</div>
<p><b><a href="syntax/literal-value.html">literal-value:</a></b>
<button id='x2001' onclick='hideorshow("x2001","x2002")'>show</button></p>
 <div id='x2002' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</div>
<p><b><a href="syntax/over-clause.html">over-clause:</a></b>
<button id='x2003' onclick='hideorshow("x2003","x2004")'>show</button></p>
 <div id='x2004' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram over-clause" src="images/syntax/over-clause.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x2005' onclick='hideorshow("x2005","x2006")'>show</button></p>
 <div id='x2006' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
</div>
<p><b><a href="syntax/raise-function.html">raise-function:</a></b>
<button id='x2007' onclick='hideorshow("x2007","x2008")'>show</button></p>
 <div id='x2008' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</div>
<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
<button id='x2009' onclick='hideorshow("x2009","x2010")'>show</button></p>
 <div id='x2010' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntax/compound-operator.html">compound-operator:</a></b>
<button id='x2011' onclick='hideorshow("x2011","x2012")'>show</button></p>
 <div id='x2012' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</div>
<p><b><a href="syntax/join-clause.html">join-clause:</a></b>
<button id='x2013' onclick='hideorshow("x2013","x2014")'>show</button></p>
 <div id='x2014' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
<button id='x2015' onclick='hideorshow("x2015","x2016")'>show</button></p>
 <div id='x2016' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</div>
<p><b><a href="syntax/join-operator.html">join-operator:</a></b>
<button id='x2017' onclick='hideorshow("x2017","x2018")'>show</button></p>
 <div id='x2018' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</div>
</div>
<p><b><a href="syntax/result-column.html">result-column:</a></b>
<button id='x2019' onclick='hideorshow("x2019","x2020")'>show</button></p>
 <div id='x2020' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</div>
<p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
<button id='x2021' onclick='hideorshow("x2021","x2022")'>show</button></p>
 <div id='x2022' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</div>
<p><b><a href="syntax/window-defn.html">window-defn:</a></b>
<button id='x2023' onclick='hideorshow("x2023","x2024")'>show</button></p>
 <div id='x2024' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram window-defn" src="images/syntax/window-defn.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x2025' onclick='hideorshow("x2025","x2026")'>show</button></p>
 <div id='x2026' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
</div>
</div>
<p><b><a href="syntax/type-name.html">type-name:</a></b>
<button id='x2027' onclick='hideorshow("x2027","x2028")'>show</button></p>
 <div id='x2028' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
<button id='x2029' onclick='hideorshow("x2029","x2030")'>show</button></p>
 <div id='x2030' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</div>
</div>
</div>
<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
<button id='x2031' onclick='hideorshow("x2031","x2032")'>show</button></p>
 <div id='x2032' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</div>
<p><b><a href="syntax/select-core.html">select-core:</a></b>
<button id='x2033' onclick='hideorshow("x2033","x2034")'>hide</button></p>
 <div id='x2034' class='imgcontainer'>
 <img alt="syntax diagram select-core" src="images/syntax/select-core.gif" />
<p><b><a href="syntax/join-clause.html">join-clause:</a></b>
<button id='x2035' onclick='hideorshow("x2035","x2036")'>show</button></p>
 <div id='x2036' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
<button id='x2037' onclick='hideorshow("x2037","x2038")'>show</button></p>
 <div id='x2038' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</div>
<p><b><a href="syntax/join-operator.html">join-operator:</a></b>
<button id='x2039' onclick='hideorshow("x2039","x2040")'>show</button></p>
 <div id='x2040' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</div>
</div>
<p><b><a href="syntax/result-column.html">result-column:</a></b>
<button id='x2041' onclick='hideorshow("x2041","x2042")'>show</button></p>
 <div id='x2042' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</div>
<p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
<button id='x2043' onclick='hideorshow("x2043","x2044")'>show</button></p>
 <div id='x2044' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
<button id='x2045' onclick='hideorshow("x2045","x2046")'>show</button></p>
 <div id='x2046' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntax/compound-operator.html">compound-operator:</a></b>
<button id='x2047' onclick='hideorshow("x2047","x2048")'>show</button></p>
 <div id='x2048' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</div>
</div>
</div>
<p><b><a href="syntax/window-defn.html">window-defn:</a></b>
<button id='x2049' onclick='hideorshow("x2049","x2050")'>show</button></p>
 <div id='x2050' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram window-defn" src="images/syntax/window-defn.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x2051' onclick='hideorshow("x2051","x2052")'>show</button></p>
 <div id='x2052' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
</div>
</div>
</div>


<p>Generating the results of a simple SELECT
statement is presented as a four step process in the description below:

<ol>
  <li> <p><a href="lang_select.html#fromclause">FROM clause</a> processing: The input data for the simple SELECT is
       determined. The input data is either implicitly a single row with 0
       columns (if there is no FROM clause) or is determined by the FROM
       clause.
  <li> <p><a href="lang_select.html#whereclause">WHERE clause</a> processing: The input data is filtered using the WHERE
       clause expression.  
  <li> <p><a href="lang_select.html#resultset">GROUP BY, HAVING and result-column expression</a> processing: 
       The set of result rows is computed by aggregating the data according to
       any GROUP BY clause and calculating the result-set expressions for the
       rows of the filtered input dataset.  
  <li> <p><a href="lang_select.html#distinct">DISTINCT/ALL keyword</a> processing: If the query is a "SELECT
       DISTINCT" query, duplicate rows are removed from the set of result rows.
</ol>

<p>There are two types of simple SELECT statement - aggregate and 
non-aggregate queries. A simple SELECT statement is an aggregate query if
it contains either a GROUP BY clause or one or more aggregate functions
in the result-set. Otherwise, if a simple SELECT contains no aggregate
functions or a GROUP BY clause, it is a non-aggregate query.

<p><b>1. Determination of input data (FROM clause processing).</b>
<a name="fromclause"></a>



<p>The input data used by a simple SELECT query is a set of <i>N</i> rows 
each <i>M</i> columns wide.

<p>If the FROM clause is omitted from a simple SELECT statement, then the 
input data is implicitly a single row zero columns wide (i.e. <i>N</i>=1 and
<i>M</i>=0).

<p>If a FROM clause is specified, the data on which a simple SELECT query
operates comes from the one or more tables or subqueries (SELECT statements
in parentheses) specified following the FROM keyword. A subquery specified
in the <span class='yyterm'>table-or-subquery</span> following the FROM clause in a 
simple SELECT statement is
handled as if it was a table containing the data returned by executing the
subquery statement. Each column of the subquery has the
<a href="datatype3.html#collation">collation sequence</a> and <a href="datatype3.html#affinity">affinity</a> of the corresponding expression
in the subquery statement.

<p>If there is only a single table or subquery in the FROM
clause, then the input data used by the SELECT statement is the contents of the
named table. If there is more than one table or subquery in FROM clause
then the contents of all tables and/or subqueries
are joined into a single dataset for the simple SELECT statement to operate on.
Exactly how the data is combined depends on the specific <a href="syntax/join-operator.html">join-operator</a> and
<a href="syntax/join-constraint.html">join-constraint</a> used to connect the tables or subqueries together.

<p>All joins in SQLite are based on the cartesian product of the left and
right-hand datasets. The columns of the cartesian product dataset are, in 
order, all the columns of the left-hand dataset followed by all the columns
of the right-hand dataset. There is a row in the cartesian product dataset
formed by combining each unique combination of a row from the left-hand 
and right-hand datasets. In other words, if the left-hand dataset consists of
<i>N<sub><small>left</small></sub></i> rows of 
<i>M<sub><small>left</small></sub></i> columns, and the right-hand dataset of
<i>N<sub><small>right</small></sub></i> rows of
<i>M<sub><small>right</small></sub></i> columns, then the cartesian product is a
dataset of 
<i>N<sub><small>left</small></sub>&times;N<sub><small>right</small></sub></i>
rows, each containing 
<i>M<sub><small>left</small></sub>+M<sub><small>right</small></sub></i> columns.

<p>If the join-operator is "CROSS JOIN", "INNER JOIN", "JOIN" or a comma
(",") and there is no ON or USING clause, then the result of the join is
simply the cartesian product of the left and right-hand datasets. 
If join-operator does have ON or USING clauses, those are handled according to
the following bullet points:

<ul>
  <li> <p>If there is an ON clause then the ON expression is
       evaluated for each row of the cartesian product as a 
       <a href="lang_expr.html#booleanexpr">boolean expression</a>. Only rows for which the expression evaluates to 
       true are included from the dataset.

  <li> <p>If there is a USING clause
       then each of the column names specified must exist in the datasets to 
       both the left and right of the join-operator. For each pair of named
       columns, the expression "lhs.X = rhs.X" is evaluated for each row of
       the cartesian product as a <a href="lang_expr.html#booleanexpr">boolean expression</a>. Only rows for which
       all such expressions evaluates to true are included from the
       result set. When comparing values as a result of a USING clause, the
       normal rules for handling affinities, collation sequences and NULL
       values in comparisons apply. The column from the dataset on the
       left-hand side of the join-operator is considered to be on the left-hand
       side of the comparison operator (=) for the purposes of collation 
       sequence and affinity precedence.

       <p>For each pair of columns identified by a USING clause, the column
       from the right-hand dataset is omitted from the joined dataset. This 
       is the only difference between a USING clause and its equivalent ON
       constraint.

  <li> <p>If the NATURAL keyword is in the join-operator then an
       implicit USING clause is added to the join-constraints. The implicit
       USING clause contains each of the column names that appear in both
       the left and right-hand input datasets. If the left and right-hand
       input datasets feature no common column names, then the NATURAL keyword
       has no effect on the results of the join. A USING or ON clause may
       not be added to a join that specifies the NATURAL keyword.

  <li> <p>If the join-operator is a "LEFT JOIN" or "LEFT OUTER JOIN", then
       after
       the ON or USING filtering clauses have been applied, an extra row is 
       added to the output for each row in the original left-hand input 
       dataset that corresponds to no rows at all in the composite
       dataset (if any). The added rows contain NULL values in the columns
       that would normally contain values copied from the right-hand input
       dataset.  
</ul>

<p>When more than two tables are joined together as part of a FROM clause,
the join operations are processed in order from left to right. In other 
words, the FROM clause (A join-op-1 B join-op-2 C) is computed as 
((A join-op-1 B) join-op-2 C).

<a name="crossjoin"></a>

<p><b>Side note: Special handling of CROSS JOIN.</b>
There is no difference between the "INNER JOIN", "JOIN" and "," join
operators. They are completely interchangeable in SQLite.
The "CROSS JOIN" join operator produces the same result as the 
"INNER JOIN", "JOIN" and "," operators, but is 
<a href="optoverview.html#crossjoin">handled differently by the query optimizer</a>
in that it prevents the query optimizer from reordering
the tables in the join.  An application programmer can use the CROSS JOIN 
operator to directly influence the algorithm that is chosen to implement
the SELECT statement.  Avoid using CROSS JOIN except in specific situations 
where manual control of the query optimizer is desired.  Avoid using
CROSS JOIN early in the development of an application as doing so is
a <a href="http://c2.com/cgi/wiki?PrematureOptimization">premature
optimization</a>.  The special handling of CROSS JOIN is an SQLite-specific
feature and is not a part of standard SQL.
       

<a name="whereclause"></a>


<p><b>2. WHERE clause filtering.</b>

<p>If a WHERE clause is specified, the WHERE expression is evaluated for 
each row in the input data as a <a href="lang_expr.html#booleanexpr">boolean expression</a>. Only rows for which the
WHERE clause expression evaluates to true are included from the dataset before
continuing.  Rows are excluded from the result if the WHERE clause
evaluates to either false or NULL.

<p>For a JOIN or INNER JOIN or CROSS JOIN, there is no difference between 
a constraint expression in the WHERE clause and one in the ON clause.  However,
for a LEFT JOIN or LEFT OUTER JOIN, the difference is very important.  
In a LEFT JOIN,
the extra NULL row for the right-hand table is added after ON clause processing
but before WHERE clause processing.  A constraint of the form "left.x=right.y"
in an ON clause will therefore allow through the added all-NULL rows of the
right table.  But if that same constraint is in the WHERE clause a NULL in
"right.y" will prevent the expression "left.x=right.y" from being true, and
thus exclude that row from the output.

<p><b>3. Generation of the set of result rows.</b>
<a name="resultset"></a>



<p>Once the input data from the FROM clause has been filtered by the
WHERE clause expression (if any), the set of result rows for the simple 
SELECT are calculated. Exactly how this is done depends on whether the simple 
SELECT is an aggregate or non-aggregate query, and whether or not a GROUP
BY clause was specified.

<p> The list of expressions between the SELECT and FROM keywords is known as
the result expression list.  If a result expression is the special expression
"*" then all columns in the input data are substituted for that one expression.
If the expression is the alias of a table or subquery in the FROM clause
followed by ".*" then all columns from the named table or subquery are
substituted for the single expression. It is an error to use a "*" or
"alias.*" expression in any context other than a result expression list.
It is also an error to use a "*" or "alias.*" expression in a simple SELECT
query that does not have a FROM clause.

<p> The number of columns in the rows returned by a simple SELECT statement
is equal to the number of expressions in the result expression list after
substitution of * and alias.* expressions. Each result row is calculated by
evaluating the expressions in the result expression list with respect to a
single row of input data or, for aggregate queries, with respect to a group
of rows.

<ul>
  <li><p>If the SELECT statement is <b>a non-aggregate query</b>, then 
    each expression in the result expression list is evaluated for each row in
    the dataset filtered by the WHERE clause.

  <li><p>If the SELECT statement is <b>an aggregate query without a GROUP
    BY</b> clause, then each aggregate expression in the result-set is 
    evaluated once across the entire dataset. Each non-aggregate expression
    in the result-set is evaluated once for an arbitrarily selected row of
    the dataset. The same arbitrarily selected row is used for each
    non-aggregate expression. Or, if the dataset contains zero rows, then 
    each non-aggregate expression is evaluated against a row consisting
    entirely of NULL values.

   <p>The single row of result-set data created by evaluating the aggregate
    and non-aggregate expressions in the result-set forms the result of an
    aggregate query without a GROUP BY clause. An aggregate query without a
    GROUP BY clause always returns exactly one row of data, even if there are
    zero rows of input data.

  <li><p>If the SELECT statement is <b>an aggregate query with a GROUP
    BY</b> clause, then each of the expressions specified as part of the
    GROUP BY clause is evaluated for each row of the dataset. Each row
    is then assigned to a "group" based on the results; rows for which
    the results of evaluating the GROUP BY expressions are the same get
    assigned to the same group. For the purposes of grouping rows, NULL 
    values are considered equal. The usual rules for <a href="datatype3.html#collation">selecting a
    collation sequence</a> with which to compare text values apply when evaluating
    expressions in a GROUP BY clause.  The expressions in the GROUP BY clause
    do <em>not</em> have to be expressions that appear in the result. The
    expressions in a GROUP BY clause may not be aggregate expressions.

    <p>If a HAVING clause is specified, it is evaluated once for each group 
    of rows as a <a href="lang_expr.html#booleanexpr">boolean expression</a>. If the result of evaluating the
    HAVING clause is false, the group is discarded. If the HAVING clause is
    an aggregate expression, it is evaluated across all rows in the group. If
    a HAVING clause is a non-aggregate expression, it is evaluated with respect
    to an arbitrarily selected row from the group.  The HAVING expression may
    refer to values, even aggregate functions, that are not in the result.</p>

    <p>Each expression in the result-set is then evaluated once for each
    group of rows. If the expression is an aggregate expression, it is 
    evaluated across all rows in the group. Otherwise, it is evaluated against
    a single arbitrarily chosen row from within the group. If there is more
    than one non-aggregate expression in the result-set, then all such
    expressions are evaluated for the same row.

    <p>Each group of input dataset rows contributes a single row to the 
    set of result rows. Subject to filtering associated with the DISTINCT
    keyword, the number of rows returned by an aggregate query with a GROUP
    BY clause is the same as the number of groups of rows produced by applying
    the GROUP BY and HAVING clauses to the filtered input dataset.
</ul>

<a name="bareagg"></a>

<p><b>Side note: Bare columns in an aggregate queries.</b>
The usual case is that all column names in an aggregate query are either
arguments to <a href="lang_aggfunc.html">aggregate functions</a> or else appear in the GROUP BY clause.
A result column which contains a column name that is not within an
aggregate function and that does not appear in the GROUP BY clause (if
one exists) is called a "bare" column.
Example:
<blockquote><pre>
SELECT a, b, sum(c) FROM tab1 GROUP BY a;
</pre></blockquote>
<p>In the query above, the "a" column is part of the GROUP BY clause
and so each row of the output contains one of the distinct values for
"a".  The "c" column is contained within the <a href="lang_aggfunc.html#sumunc">sum()</a> aggregate function
and so that output column is the sum of all "c" values in rows that
have the same value for "a".  But what is the result of the bare 
column "b"? The answer is that the "b" result will be the
value for "b" in one of the input rows that form the aggregate.
The problem is that you usually do not know which input row is used
to compute "b", and so in many cases the value for "b" is undefined.
</p>
<p>
Special processing occurs when the aggregate function is 
either <a href="lang_aggfunc.html#maxggunc">min()</a> or <a href="lang_aggfunc.html#minggunc">max()</a>.  Example:
<blockquote><pre>
SELECT a, b, max(c) FROM tab1 GROUP BY a;
</pre></blockquote>

When the <a href="lang_aggfunc.html#maxggunc">min()</a> or <a href="lang_aggfunc.html#minggunc">max()</a> aggregate functions 
are used in an aggregate query, all bare columns in the result set 
take values from the input
row which also contains the minimum or maximum.  So in the query
above, the value of the "b" column in the output will be the value of
the "b" column in the input row that has the largest "c" value.
There is still an ambiguity if two or more of the input rows have the
same minimum or maximum value or if the query contains more than one
min() and/or max() aggregate function. Only the built-in <a href="lang_aggfunc.html#minggunc">min()</a> 
and <a href="lang_aggfunc.html#maxggunc">max()</a> functions work this way.
</p>

<p><b>4. Removal of duplicate rows (DISTINCT processing).</b>
<a name="distinct"></a>



<p>One of the ALL or DISTINCT keywords may follow the SELECT keyword in a 
simple SELECT statement. If the simple SELECT is a SELECT ALL, then the
entire set of result rows are returned by the SELECT. If neither ALL or
DISTINCT are present, then the behavior is as if ALL were specified. 
If the simple SELECT is a SELECT DISTINCT, then duplicate rows are removed
from the set of result rows before it is returned. For the purposes of
detecting duplicate rows, two NULL values are considered to be equal. The
<a href="datatype3.html#colrules">usual rules</a> apply for selecting a collation
sequence to compare text values.

<a name="compound"></a>

<h3>Compound Select Statements</h3>

<p>Two or more <a href="lang_select.html#simpleselect">simple SELECT</a> statements may be connected together to form
a compound SELECT using the UNION, UNION ALL, INTERSECT or EXCEPT operator,
as shown by the following diagram:

<p><b><a href="syntax/compound-select-stmt.html">compound-select-stmt:</a></b>
<button id='x2053' onclick='hideorshow("x2053","x2054")'>hide</button></p>
 <div id='x2054' class='imgcontainer'>
 <img alt="syntax diagram compound-select-stmt" src="images/syntax/compound-select-stmt.gif" />
<p><b><a href="syntax/common-table-expression.html">common-table-expression:</a></b>
<button id='x2055' onclick='hideorshow("x2055","x2056")'>show</button></p>
 <div id='x2056' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
<button id='x2057' onclick='hideorshow("x2057","x2058")'>show</button></p>
 <div id='x2058' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntax/compound-operator.html">compound-operator:</a></b>
<button id='x2059' onclick='hideorshow("x2059","x2060")'>show</button></p>
 <div id='x2060' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</div>
<p><b><a href="syntax/join-clause.html">join-clause:</a></b>
<button id='x2061' onclick='hideorshow("x2061","x2062")'>show</button></p>
 <div id='x2062' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
<button id='x2063' onclick='hideorshow("x2063","x2064")'>show</button></p>
 <div id='x2064' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</div>
<p><b><a href="syntax/join-operator.html">join-operator:</a></b>
<button id='x2065' onclick='hideorshow("x2065","x2066")'>show</button></p>
 <div id='x2066' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</div>
</div>
<p><b><a href="syntax/result-column.html">result-column:</a></b>
<button id='x2067' onclick='hideorshow("x2067","x2068")'>show</button></p>
 <div id='x2068' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</div>
<p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
<button id='x2069' onclick='hideorshow("x2069","x2070")'>show</button></p>
 <div id='x2070' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</div>
<p><b><a href="syntax/window-defn.html">window-defn:</a></b>
<button id='x2071' onclick='hideorshow("x2071","x2072")'>show</button></p>
 <div id='x2072' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram window-defn" src="images/syntax/window-defn.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x2073' onclick='hideorshow("x2073","x2074")'>show</button></p>
 <div id='x2074' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
</div>
</div>
</div>
<p><b><a href="syntax/expr.html">expr:</a></b>
<button id='x2075' onclick='hideorshow("x2075","x2076")'>show</button></p>
 <div id='x2076' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntax/filter-clause.html">filter-clause:</a></b>
<button id='x2077' onclick='hideorshow("x2077","x2078")'>show</button></p>
 <div id='x2078' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram filter-clause" src="images/syntax/filter-clause.gif" />
</div>
<p><b><a href="syntax/literal-value.html">literal-value:</a></b>
<button id='x2079' onclick='hideorshow("x2079","x2080")'>show</button></p>
 <div id='x2080' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</div>
<p><b><a href="syntax/over-clause.html">over-clause:</a></b>
<button id='x2081' onclick='hideorshow("x2081","x2082")'>show</button></p>
 <div id='x2082' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram over-clause" src="images/syntax/over-clause.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x2083' onclick='hideorshow("x2083","x2084")'>show</button></p>
 <div id='x2084' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
</div>
<p><b><a href="syntax/raise-function.html">raise-function:</a></b>
<button id='x2085' onclick='hideorshow("x2085","x2086")'>show</button></p>
 <div id='x2086' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</div>
<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
<button id='x2087' onclick='hideorshow("x2087","x2088")'>show</button></p>
 <div id='x2088' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntax/compound-operator.html">compound-operator:</a></b>
<button id='x2089' onclick='hideorshow("x2089","x2090")'>show</button></p>
 <div id='x2090' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</div>
<p><b><a href="syntax/join-clause.html">join-clause:</a></b>
<button id='x2091' onclick='hideorshow("x2091","x2092")'>show</button></p>
 <div id='x2092' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
<button id='x2093' onclick='hideorshow("x2093","x2094")'>show</button></p>
 <div id='x2094' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</div>
<p><b><a href="syntax/join-operator.html">join-operator:</a></b>
<button id='x2095' onclick='hideorshow("x2095","x2096")'>show</button></p>
 <div id='x2096' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</div>
</div>
<p><b><a href="syntax/result-column.html">result-column:</a></b>
<button id='x2097' onclick='hideorshow("x2097","x2098")'>show</button></p>
 <div id='x2098' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</div>
<p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
<button id='x2099' onclick='hideorshow("x2099","x2100")'>show</button></p>
 <div id='x2100' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</div>
<p><b><a href="syntax/window-defn.html">window-defn:</a></b>
<button id='x2101' onclick='hideorshow("x2101","x2102")'>show</button></p>
 <div id='x2102' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram window-defn" src="images/syntax/window-defn.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x2103' onclick='hideorshow("x2103","x2104")'>show</button></p>
 <div id='x2104' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
</div>
</div>
<p><b><a href="syntax/type-name.html">type-name:</a></b>
<button id='x2105' onclick='hideorshow("x2105","x2106")'>show</button></p>
 <div id='x2106' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
<button id='x2107' onclick='hideorshow("x2107","x2108")'>show</button></p>
 <div id='x2108' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</div>
</div>
</div>
<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
<button id='x2109' onclick='hideorshow("x2109","x2110")'>show</button></p>
 <div id='x2110' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</div>
<p><b><a href="syntax/select-core.html">select-core:</a></b>
<button id='x2111' onclick='hideorshow("x2111","x2112")'>show</button></p>
 <div id='x2112' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram select-core" src="images/syntax/select-core.gif" />
<p><b><a href="syntax/join-clause.html">join-clause:</a></b>
<button id='x2113' onclick='hideorshow("x2113","x2114")'>show</button></p>
 <div id='x2114' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
<button id='x2115' onclick='hideorshow("x2115","x2116")'>show</button></p>
 <div id='x2116' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</div>
<p><b><a href="syntax/join-operator.html">join-operator:</a></b>
<button id='x2117' onclick='hideorshow("x2117","x2118")'>show</button></p>
 <div id='x2118' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</div>
</div>
<p><b><a href="syntax/result-column.html">result-column:</a></b>
<button id='x2119' onclick='hideorshow("x2119","x2120")'>show</button></p>
 <div id='x2120' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</div>
<p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
<button id='x2121' onclick='hideorshow("x2121","x2122")'>show</button></p>
 <div id='x2122' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
<button id='x2123' onclick='hideorshow("x2123","x2124")'>show</button></p>
 <div id='x2124' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntax/compound-operator.html">compound-operator:</a></b>
<button id='x2125' onclick='hideorshow("x2125","x2126")'>show</button></p>
 <div id='x2126' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</div>
</div>
</div>
<p><b><a href="syntax/window-defn.html">window-defn:</a></b>
<button id='x2127' onclick='hideorshow("x2127","x2128")'>show</button></p>
 <div id='x2128' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram window-defn" src="images/syntax/window-defn.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x2129' onclick='hideorshow("x2129","x2130")'>show</button></p>
 <div id='x2130' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
</div>
</div>
</div>


<p>In a compound SELECT, all the constituent SELECTs must return the same 
number of result columns. As the components of a compound SELECT must
be simple SELECT statements, they may not contain <a href="lang_select.html#orderby">ORDER BY</a> or <a href="lang_select.html#limitoffset">LIMIT</a> clauses.
<a href="lang_select.html#orderby">ORDER BY</a> and <a href="lang_select.html#limitoffset">LIMIT</a> clauses may only occur at the end of the entire compound
SELECT, and then only if the final element of the compound is not a <a href="lang_select.html#values">VALUES</a> clause.

<p>A compound SELECT created using UNION ALL operator returns all the rows
from the SELECT to the left of the UNION ALL operator, and all the rows
from the SELECT to the right of it. The UNION operator works the same way as
UNION ALL, except that duplicate rows are removed from the final result set.
The INTERSECT operator returns the intersection of the results of the left and
right SELECTs.  The EXCEPT operator returns the subset of rows returned by the
left SELECT that are not also returned by the right-hand SELECT. Duplicate
rows are removed from the results of INTERSECT and EXCEPT operators before the
result set is returned.

<p>For the purposes of determining duplicate rows for the results of compound
SELECT operators, NULL values are considered equal to other NULL values and
distinct from all non-NULL values. The collation sequence used to compare 
two text values is determined as if the columns of the left and right-hand
SELECT statements were the left and right-hand operands of the equals (=)
operator, except that greater precedence is not assigned to a collation 
sequence specified with the postfix COLLATE operator. No affinity
transformations are applied to any values when comparing rows as part of a
compound SELECT. 

<p>When three or more simple SELECTs are connected into a compound SELECT,
they group from left to right. In other words, if "A", "B" and "C" are all
simple SELECT statements, (A op B op C) is processed as ((A op B) op C).

</p>

<a name="orderby"></a>

<h3>The ORDER BY clause</h3>

<p>If a SELECT statement that returns more than one row does not have an
ORDER BY clause, the order in which the rows are returned is undefined.
Or, if a SELECT statement does have an ORDER BY clause, then the list of
expressions attached to the ORDER BY determine the order in which rows
are returned to the user.

<p>
In a <a href="lang_select.html#compound">compound SELECT</a> statement, only the last or right-most <a href="lang_select.html#simpleselect">simple SELECT</a>
may have an ORDER BY clause. That ORDER BY clause will apply across all elements of
the compound. If the right-most element of a <a href="lang_select.html#compound">compound SELECT</a> is a <a href="lang_select.html#values">VALUES</a> clause,
then no ORDER BY clause is allowed on that statement.


<p>Rows are first sorted based on the results of
evaluating the left-most expression in the ORDER BY list, then ties are broken
by evaluating the second left-most expression and so on. The order in which
two rows for which all ORDER BY expressions evaluate to equal values are
returned is undefined. Each ORDER BY expression may be optionally followed
by one of the keywords ASC (smaller values are returned first) or DESC (larger
values are returned first). If neither ASC or DESC are specified, rows
are sorted in ascending (smaller values first) order by default.

<a name="nullslast"></a>

<p>SQLite considers NULL values to be smaller than any other values
for sorting purposes.  Hence, NULLs naturally appear at the beginning
of an ASC order-by and at the end of a DESC order-by.  This can be changed
using the "ASC NULLS LAST" or "DESC NULLS FIRST" syntax.

<p>Each ORDER BY expression is processed as follows:</p>

<ol>
<li><p>If the ORDER BY expression is a constant integer K then the
expression is considered an alias for the K-th column of the result set
(columns are numbered from left to right starting with 1).

<li><p>If the ORDER BY expression is an identifier that corresponds to
the alias of one of the output columns, then the expression is considered
an alias for that column.

<li><p>Otherwise, if the ORDER BY expression is any other expression, it 
is evaluated and the returned value used to order the output rows. If
the SELECT statement is a simple SELECT, then an ORDER BY may contain any
arbitrary expressions. However, if the SELECT is a compound SELECT, then
ORDER BY expressions that are not aliases to output columns must be exactly
the same as an expression used as an output column.
</ol>

<p>For the purposes of sorting rows, values are compared in the same way
as for <a href="datatype3.html#comparisons">comparison expressions</a>. The collation sequence used to compare
two text values is determined as follows:

<ol>
  <li><p>If the ORDER BY expression is assigned a collation sequence using
  the postfix <a href="lang_expr.html#collateop">COLLATE operator</a>, then the specified collation sequence is
  used.
  <li><p>Otherwise, if the ORDER BY expression is an alias to an expression
  that has been assigned a collation sequence using the postfix 
  <a href="lang_expr.html#collateop">COLLATE operator</a>, then the collation sequence assigned to the aliased
  expression is used.
  <li><p>Otherwise, if the ORDER BY expression is a column or an alias of
  an expression that is a column, then the default collation sequence for
  the column is used. 
  <li><p>Otherwise, the <a href="datatype3.html#collation">BINARY</a> collation sequence is used.
</ol>

<p>In a <a href="lang_select.html#compound">compound SELECT</a> statement, all ORDER BY expressions are handled
as aliases for one of the result columns of the compound.
If an ORDER BY expression is not an integer alias, then SQLite searches
the left-most SELECT in the compound for a result column that matches either
the second or third rules above. If a match is found, the search stops and
the expression is handled as an alias for the result column that it has been
matched against. Otherwise, the next SELECT to the right is tried, and so on.
If no matching expression can be found in the result columns of any
constituent SELECT, it is an error. Each term of the ORDER BY clause is
processed separately and may be matched against result columns from different
SELECT statements in the compound.</p>

<a name="limitoffset"></a>

<h3>The LIMIT clause</h3>

<p>The LIMIT clause is used to place an upper bound on the number of rows
returned by the entire SELECT statement.

<p>In a <a href="lang_select.html#compound">compound SELECT</a>, only the
last or right-most <a href="lang_select.html#simpleselect">simple SELECT</a> may contain a LIMIT clause.  
In a <a href="lang_select.html#compound">compound SELECT</a>, 
the LIMIT clause applies to the entire compound, not just the final SELECT.
If the right-most <a href="lang_select.html#simpleselect">simple SELECT</a> is a <a href="lang_select.html#values">VALUES clause</a> then no LIMIT clause
is allowed.

<p>Any scalar expression may be used in the 
LIMIT clause, so long as it evaluates to an integer or a value that can be
losslessly converted to an integer. If the expression evaluates to a NULL 
value or any other value that cannot be losslessly converted to an integer, an
error is returned. If the LIMIT expression evaluates to a negative value,
then there is no upper bound on the number of rows returned. Otherwise, the
SELECT returns the first N rows of its result set only, where N is the value
that the LIMIT expression evaluates to. Or, if the SELECT statement would
return less than N rows without a LIMIT clause, then the entire result set is
returned. 

<p>The expression attached to the optional OFFSET clause that may follow a
LIMIT clause must also evaluate to an integer, or a value that can be
losslessly converted to an integer. If an expression has an OFFSET clause,
then the first M rows are omitted from the result set returned by the SELECT
statement and the next N rows are returned, where M and N are the values that
the OFFSET and LIMIT clauses evaluate to, respectively. Or, if the SELECT
would return less than M+N rows if it did not have a LIMIT clause, then the
first M rows are skipped and the remaining rows (if any) are returned. If the
OFFSET clause evaluates to a negative value, the results are the same as if it
had evaluated to zero.

<p>Instead of a separate OFFSET clause, the LIMIT clause may specify two
scalar expressions separated by a comma. In this case, the first expression
is used as the OFFSET expression and the second as the LIMIT expression.
This is counter-intuitive, as when using the OFFSET clause the second of
the two expressions is the OFFSET and the first the LIMIT. 
This reversal of the offset and limit is intentional
- it maximizes compatibility with other SQL database systems.
However, to avoid confusion, programmers are strongly encouraged to use
the form of the LIMIT clause that uses the "OFFSET" keyword and avoid
using a LIMIT clause with a comma-separated offset.

<a name="values"></a>

<h3>The VALUES clause</h3>

<p>The phrase "VALUES(<i>expr-list</i>)" means the same thing
as "SELECT <i>expr-list</i>".  The phrase
"VALUES(<i>expr-list-1</i>),...,(<i>expr-list-N</i>)" means the same
thing as "SELECT <i>expr-list-1</i> UNION ALL ... UNION ALL
SELECT <i>expr-list-N</i>".  Both forms are the same, except that
the number of SELECT statements in a compound is limited by
<a href="c3ref/c_limit_attached.html#sqlitelimitcompoundselect">SQLITE_LIMIT_COMPOUND_SELECT</a> whereas the number of rows in a
VALUES clause has no arbitrary limit.

<p>There are some restrictions on the use of a VALUES clause that are
not shown on the syntax diagrams:

<ul>
<li><p>
A VALUES clause cannot be followed by <a href="lang_select.html#orderby">ORDER BY</a>.

<li><p>
A VALUES clause cannot be followed by <a href="lang_select.html#limitoffset">LIMIT</a>.
</ul>


<h3>The WITH Clause</h3>

<p>SELECT statements may be optionally preceded by a single
<a href="lang_with.html">WITH clause</a> that defines one or more <a href="lang_with.html">common table expressions</a>
for use within the SELECT statement.

<a name="tabfunc1"></a>

<h3>Table-valued Functions In The FROM Clause</h3>

<p>A <a href="vtab.html">virtual table</a> that contains <a href="vtab.html#hiddencol">hidden columns</a> can be used like
a <a href="vtab.html#tabfunc2">table-valued function</a> in the FROM clause.  The arguments to the
table-valued function become constraints on the HIDDEN columns of
the virtual table.  Additional information can be found in the
<a href="vtab.html#tabfunc2">virtual table documentation</a>.









|
<
<
<
<
<
<
<
<
<
<
<
<
<
|


|
|


|
>
|


|
>
|


<
<
<
<
|
<
|
|
|
|


|
|
|
|

<
<
<
<
<
<
<
<
<
|
|
|
|
<
<
<
<

|
|


|
|
|
|
|
|
|
|

<
<
<
<
<
|
|
|
|
<
<
<
<


|
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|



|
|



|
|


|
|





|
|


|
|





|
|



|
|


|
|


|
|



|
|




|
|



|
|


|
|

>
>
>
>
>



|
|


|
|







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|


|




|

|



|

|







|




|


|



|









|







|














|





|





|












|




|







|







|








|



















|

|





|










|




|





|









|






|




|








|





|











|














|




|










|















|


>
|
















|











|






|
|


|
|


|
|


|
|



|
|


|
|



|
|




|
|



|
|



|
|


|
|






|
|


|
|



|
|



|
|


|
|




|
|



|
|


|
|



|
|


|
|



|
|




|
|



|
|



|
|


|
|





|
|


|
|





|
|



|
|


|
|


|
|



|
|




|
|



|
|


|
|


|
|





|
|


|
|







|





|









|









|







|







|






|










|




|






|



|





|





|



|



|


|
|















|




|






|










|










|












|










|


|



|

|


|







|






|
<
502
503
504
505
506
507
508
509













510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526




527

528
529
530
531
532
533
534
535
536
537
538









539
540
541
542




543
544
545
546
547
548
549
550
551
552
553
554
555
556





557
558
559
560




561
562
563
564
























565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652































































































































































































































653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360

<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x1899' onclick='hideorshow("x1899","x1900")'>show</button></p>
 <div id='x1900' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
</div>
</div>
</div>













<p><b><a href="syntax/expr.html">expr:</a></b>
<button id='x1901' onclick='hideorshow("x1901","x1902")'>show</button></p>
 <div id='x1902' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntax/filter-clause.html">filter-clause:</a></b>
<button id='x1903' onclick='hideorshow("x1903","x1904")'>show</button></p>
 <div id='x1904' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram filter-clause" src="images/syntax/filter-clause.gif" />
</div>
<p><b><a href="syntax/literal-value.html">literal-value:</a></b>
<button id='x1905' onclick='hideorshow("x1905","x1906")'>show</button></p>
 <div id='x1906' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</div>
<p><b><a href="syntax/over-clause.html">over-clause:</a></b>
<button id='x1907' onclick='hideorshow("x1907","x1908")'>show</button></p>
 <div id='x1908' style='display:none;' class='imgcontainer'>




 <img alt="syntax diagram over-clause" src="images/syntax/over-clause.gif" />

<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x1909' onclick='hideorshow("x1909","x1910")'>show</button></p>
 <div id='x1910' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
</div>
<p><b><a href="syntax/raise-function.html">raise-function:</a></b>
<button id='x1911' onclick='hideorshow("x1911","x1912")'>show</button></p>
 <div id='x1912' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</div>









<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
<button id='x1913' onclick='hideorshow("x1913","x1914")'>show</button></p>
 <div id='x1914' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />




<p><b><a href="syntax/compound-operator.html">compound-operator:</a></b>
<button id='x1915' onclick='hideorshow("x1915","x1916")'>show</button></p>
 <div id='x1916' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</div>
<p><b><a href="syntax/join-clause.html">join-clause:</a></b>
<button id='x1917' onclick='hideorshow("x1917","x1918")'>show</button></p>
 <div id='x1918' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
<button id='x1919' onclick='hideorshow("x1919","x1920")'>show</button></p>
 <div id='x1920' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</div>





<p><b><a href="syntax/join-operator.html">join-operator:</a></b>
<button id='x1921' onclick='hideorshow("x1921","x1922")'>show</button></p>
 <div id='x1922' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />




</div>
</div>
<p><b><a href="syntax/result-column.html">result-column:</a></b>
<button id='x1923' onclick='hideorshow("x1923","x1924")'>show</button></p>
























 <div id='x1924' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</div>
<p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
<button id='x1925' onclick='hideorshow("x1925","x1926")'>show</button></p>
 <div id='x1926' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</div>
<p><b><a href="syntax/window-defn.html">window-defn:</a></b>
<button id='x1927' onclick='hideorshow("x1927","x1928")'>show</button></p>
 <div id='x1928' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram window-defn" src="images/syntax/window-defn.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x1929' onclick='hideorshow("x1929","x1930")'>show</button></p>
 <div id='x1930' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
</div>
</div>
<p><b><a href="syntax/type-name.html">type-name:</a></b>
<button id='x1931' onclick='hideorshow("x1931","x1932")'>show</button></p>
 <div id='x1932' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
<button id='x1933' onclick='hideorshow("x1933","x1934")'>show</button></p>
 <div id='x1934' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</div>
</div>
</div>
<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
<button id='x1935' onclick='hideorshow("x1935","x1936")'>show</button></p>
 <div id='x1936' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</div>
<p><b><a href="syntax/select-core.html">select-core:</a></b>
<button id='x1937' onclick='hideorshow("x1937","x1938")'>hide</button></p>
 <div id='x1938' class='imgcontainer'>
 <img alt="syntax diagram select-core" src="images/syntax/select-core.gif" />
<p><b><a href="syntax/join-clause.html">join-clause:</a></b>
<button id='x1939' onclick='hideorshow("x1939","x1940")'>show</button></p>
 <div id='x1940' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
<button id='x1941' onclick='hideorshow("x1941","x1942")'>show</button></p>
 <div id='x1942' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</div>
<p><b><a href="syntax/join-operator.html">join-operator:</a></b>
<button id='x1943' onclick='hideorshow("x1943","x1944")'>show</button></p>
 <div id='x1944' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</div>
</div>
<p><b><a href="syntax/result-column.html">result-column:</a></b>
<button id='x1945' onclick='hideorshow("x1945","x1946")'>show</button></p>
 <div id='x1946' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</div>
<p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
<button id='x1947' onclick='hideorshow("x1947","x1948")'>show</button></p>
 <div id='x1948' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
<button id='x1949' onclick='hideorshow("x1949","x1950")'>show</button></p>
 <div id='x1950' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntax/compound-operator.html">compound-operator:</a></b>
<button id='x1951' onclick='hideorshow("x1951","x1952")'>show</button></p>
 <div id='x1952' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</div>
</div>
</div>
<p><b><a href="syntax/window-defn.html">window-defn:</a></b>
<button id='x1953' onclick='hideorshow("x1953","x1954")'>show</button></p>
 <div id='x1954' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram window-defn" src="images/syntax/window-defn.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x1955' onclick='hideorshow("x1955","x1956")'>show</button></p>
 <div id='x1956' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
</div>
</div>
</div>

































































































































































































































</p><p>Generating the results of a simple SELECT
statement is presented as a four step process in the description below:

</p><ol>
  <li> <p><a href="lang_select.html#fromclause">FROM clause</a> processing: The input data for the simple SELECT is
       determined. The input data is either implicitly a single row with 0
       columns (if there is no FROM clause) or is determined by the FROM
       clause.
  </p></li><li> <p><a href="lang_select.html#whereclause">WHERE clause</a> processing: The input data is filtered using the WHERE
       clause expression.  
  </p></li><li> <p><a href="lang_select.html#resultset">GROUP BY, HAVING and result-column expression</a> processing: 
       The set of result rows is computed by aggregating the data according to
       any GROUP BY clause and calculating the result-set expressions for the
       rows of the filtered input dataset.  
  </p></li><li> <p><a href="lang_select.html#distinct">DISTINCT/ALL keyword</a> processing: If the query is a "SELECT
       DISTINCT" query, duplicate rows are removed from the set of result rows.
</p></li></ol>

<p>There are two types of simple SELECT statement - aggregate and 
non-aggregate queries. A simple SELECT statement is an aggregate query if
it contains either a GROUP BY clause or one or more aggregate functions
in the result-set. Otherwise, if a simple SELECT contains no aggregate
functions or a GROUP BY clause, it is a non-aggregate query.

</p><p><b>1. Determination of input data (FROM clause processing).</b>
<a name="fromclause"></a>



</p><p>The input data used by a simple SELECT query is a set of <i>N</i> rows 
each <i>M</i> columns wide.

</p><p>If the FROM clause is omitted from a simple SELECT statement, then the 
input data is implicitly a single row zero columns wide (i.e. <i>N</i>=1 and
<i>M</i>=0).

</p><p>If a FROM clause is specified, the data on which a simple SELECT query
operates comes from the one or more tables or subqueries (SELECT statements
in parentheses) specified following the FROM keyword. A subquery specified
in the <span class='yyterm'>table-or-subquery</span> following the FROM clause in a 
simple SELECT statement is
handled as if it was a table containing the data returned by executing the
subquery statement. Each column of the subquery has the
<a href="datatype3.html#collation">collation sequence</a> and <a href="datatype3.html#affinity">affinity</a> of the corresponding expression
in the subquery statement.

</p><p>If there is only a single table or subquery in the FROM
clause, then the input data used by the SELECT statement is the contents of the
named table. If there is more than one table or subquery in FROM clause
then the contents of all tables and/or subqueries
are joined into a single dataset for the simple SELECT statement to operate on.
Exactly how the data is combined depends on the specific <a href="syntax/join-operator.html">join-operator</a> and
<a href="syntax/join-constraint.html">join-constraint</a> used to connect the tables or subqueries together.

</p><p>All joins in SQLite are based on the cartesian product of the left and
right-hand datasets. The columns of the cartesian product dataset are, in 
order, all the columns of the left-hand dataset followed by all the columns
of the right-hand dataset. There is a row in the cartesian product dataset
formed by combining each unique combination of a row from the left-hand 
and right-hand datasets. In other words, if the left-hand dataset consists of
<i>N<sub><small>left</small></sub></i> rows of 
<i>M<sub><small>left</small></sub></i> columns, and the right-hand dataset of
<i>N<sub><small>right</small></sub></i> rows of
<i>M<sub><small>right</small></sub></i> columns, then the cartesian product is a
dataset of 
<i>N<sub><small>left</small></sub>&times;N<sub><small>right</small></sub></i>
rows, each containing 
<i>M<sub><small>left</small></sub>+M<sub><small>right</small></sub></i> columns.

</p><p>If the join-operator is "CROSS JOIN", "INNER JOIN", "JOIN" or a comma
(",") and there is no ON or USING clause, then the result of the join is
simply the cartesian product of the left and right-hand datasets. 
If join-operator does have ON or USING clauses, those are handled according to
the following bullet points:

</p><ul>
  <li> <p>If there is an ON clause then the ON expression is
       evaluated for each row of the cartesian product as a 
       <a href="lang_expr.html#booleanexpr">boolean expression</a>. Only rows for which the expression evaluates to 
       true are included from the dataset.

  </p></li><li> <p>If there is a USING clause
       then each of the column names specified must exist in the datasets to 
       both the left and right of the join-operator. For each pair of named
       columns, the expression "lhs.X = rhs.X" is evaluated for each row of
       the cartesian product as a <a href="lang_expr.html#booleanexpr">boolean expression</a>. Only rows for which
       all such expressions evaluates to true are included from the
       result set. When comparing values as a result of a USING clause, the
       normal rules for handling affinities, collation sequences and NULL
       values in comparisons apply. The column from the dataset on the
       left-hand side of the join-operator is considered to be on the left-hand
       side of the comparison operator (=) for the purposes of collation 
       sequence and affinity precedence.

       </p><p>For each pair of columns identified by a USING clause, the column
       from the right-hand dataset is omitted from the joined dataset. This 
       is the only difference between a USING clause and its equivalent ON
       constraint.

  </p></li><li> <p>If the NATURAL keyword is in the join-operator then an
       implicit USING clause is added to the join-constraints. The implicit
       USING clause contains each of the column names that appear in both
       the left and right-hand input datasets. If the left and right-hand
       input datasets feature no common column names, then the NATURAL keyword
       has no effect on the results of the join. A USING or ON clause may
       not be added to a join that specifies the NATURAL keyword.

  </p></li><li> <p>If the join-operator is a "LEFT JOIN" or "LEFT OUTER JOIN", then
       after
       the ON or USING filtering clauses have been applied, an extra row is 
       added to the output for each row in the original left-hand input 
       dataset that corresponds to no rows at all in the composite
       dataset (if any). The added rows contain NULL values in the columns
       that would normally contain values copied from the right-hand input
       dataset.  
</p></li></ul>

<p>When more than two tables are joined together as part of a FROM clause,
the join operations are processed in order from left to right. In other 
words, the FROM clause (A join-op-1 B join-op-2 C) is computed as 
((A join-op-1 B) join-op-2 C).

<a name="crossjoin"></a>

</p><p><b>Side note: Special handling of CROSS JOIN.</b>
There is no difference between the "INNER JOIN", "JOIN" and "," join
operators. They are completely interchangeable in SQLite.
The "CROSS JOIN" join operator produces the same result as the 
"INNER JOIN", "JOIN" and "," operators, but is 
<a href="optoverview.html#crossjoin">handled differently by the query optimizer</a>
in that it prevents the query optimizer from reordering
the tables in the join.  An application programmer can use the CROSS JOIN 
operator to directly influence the algorithm that is chosen to implement
the SELECT statement.  Avoid using CROSS JOIN except in specific situations 
where manual control of the query optimizer is desired.  Avoid using
CROSS JOIN early in the development of an application as doing so is
a <a href="http://c2.com/cgi/wiki?PrematureOptimization">premature
optimization</a>.  The special handling of CROSS JOIN is an SQLite-specific
feature and is not a part of standard SQL.
       

<a name="whereclause"></a>


</p><p><b>2. WHERE clause filtering.</b>

</p><p>If a WHERE clause is specified, the WHERE expression is evaluated for 
each row in the input data as a <a href="lang_expr.html#booleanexpr">boolean expression</a>. Only rows for which the
WHERE clause expression evaluates to true are included from the dataset before
continuing.  Rows are excluded from the result if the WHERE clause
evaluates to either false or NULL.

</p><p>For a JOIN or INNER JOIN or CROSS JOIN, there is no difference between 
a constraint expression in the WHERE clause and one in the ON clause.  However,
for a LEFT JOIN or LEFT OUTER JOIN, the difference is very important.  
In a LEFT JOIN,
the extra NULL row for the right-hand table is added after ON clause processing
but before WHERE clause processing.  A constraint of the form "left.x=right.y"
in an ON clause will therefore allow through the added all-NULL rows of the
right table.  But if that same constraint is in the WHERE clause a NULL in
"right.y" will prevent the expression "left.x=right.y" from being true, and
thus exclude that row from the output.

</p><p><b>3. Generation of the set of result rows.</b>
<a name="resultset"></a>



</p><p>Once the input data from the FROM clause has been filtered by the
WHERE clause expression (if any), the set of result rows for the simple 
SELECT are calculated. Exactly how this is done depends on whether the simple 
SELECT is an aggregate or non-aggregate query, and whether or not a GROUP
BY clause was specified.

</p><p> The list of expressions between the SELECT and FROM keywords is known as
the result expression list.  If a result expression is the special expression
"*" then all columns in the input data are substituted for that one expression.
If the expression is the alias of a table or subquery in the FROM clause
followed by ".*" then all columns from the named table or subquery are
substituted for the single expression. It is an error to use a "*" or
"alias.*" expression in any context other than a result expression list.
It is also an error to use a "*" or "alias.*" expression in a simple SELECT
query that does not have a FROM clause.

</p><p> The number of columns in the rows returned by a simple SELECT statement
is equal to the number of expressions in the result expression list after
substitution of * and alias.* expressions. Each result row is calculated by
evaluating the expressions in the result expression list with respect to a
single row of input data or, for aggregate queries, with respect to a group
of rows.

</p><ul>
  <li><p>If the SELECT statement is <b>a non-aggregate query</b>, then 
    each expression in the result expression list is evaluated for each row in
    the dataset filtered by the WHERE clause.

  </p></li><li><p>If the SELECT statement is <b>an aggregate query without a GROUP
    BY</b> clause, then each aggregate expression in the result-set is 
    evaluated once across the entire dataset. Each non-aggregate expression
    in the result-set is evaluated once for an arbitrarily selected row of
    the dataset. The same arbitrarily selected row is used for each
    non-aggregate expression. Or, if the dataset contains zero rows, then 
    each non-aggregate expression is evaluated against a row consisting
    entirely of NULL values.

   </p><p>The single row of result-set data created by evaluating the aggregate
    and non-aggregate expressions in the result-set forms the result of an
    aggregate query without a GROUP BY clause. An aggregate query without a
    GROUP BY clause always returns exactly one row of data, even if there are
    zero rows of input data.

  </p></li><li><p>If the SELECT statement is <b>an aggregate query with a GROUP
    BY</b> clause, then each of the expressions specified as part of the
    GROUP BY clause is evaluated for each row of the dataset. Each row
    is then assigned to a "group" based on the results; rows for which
    the results of evaluating the GROUP BY expressions are the same get
    assigned to the same group. For the purposes of grouping rows, NULL 
    values are considered equal. The usual rules for <a href="datatype3.html#collation">selecting a
    collation sequence</a> with which to compare text values apply when evaluating
    expressions in a GROUP BY clause.  The expressions in the GROUP BY clause
    do <em>not</em> have to be expressions that appear in the result. The
    expressions in a GROUP BY clause may not be aggregate expressions.

    </p><p>If a HAVING clause is specified, it is evaluated once for each group 
    of rows as a <a href="lang_expr.html#booleanexpr">boolean expression</a>. If the result of evaluating the
    HAVING clause is false, the group is discarded. If the HAVING clause is
    an aggregate expression, it is evaluated across all rows in the group. If
    a HAVING clause is a non-aggregate expression, it is evaluated with respect
    to an arbitrarily selected row from the group.  The HAVING expression may
    refer to values, even aggregate functions, that are not in the result.</p>

    <p>Each expression in the result-set is then evaluated once for each
    group of rows. If the expression is an aggregate expression, it is 
    evaluated across all rows in the group. Otherwise, it is evaluated against
    a single arbitrarily chosen row from within the group. If there is more
    than one non-aggregate expression in the result-set, then all such
    expressions are evaluated for the same row.

    </p><p>Each group of input dataset rows contributes a single row to the 
    set of result rows. Subject to filtering associated with the DISTINCT
    keyword, the number of rows returned by an aggregate query with a GROUP
    BY clause is the same as the number of groups of rows produced by applying
    the GROUP BY and HAVING clauses to the filtered input dataset.
</p></li></ul>

<a name="bareagg"></a>

<p><b>Side note: Bare columns in an aggregate queries.</b>
The usual case is that all column names in an aggregate query are either
arguments to <a href="lang_aggfunc.html">aggregate functions</a> or else appear in the GROUP BY clause.
A result column which contains a column name that is not within an
aggregate function and that does not appear in the GROUP BY clause (if
one exists) is called a "bare" column.
Example:
</p><blockquote><pre>
SELECT a, b, sum(c) FROM tab1 GROUP BY a;
</pre></blockquote>
<p>In the query above, the "a" column is part of the GROUP BY clause
and so each row of the output contains one of the distinct values for
"a".  The "c" column is contained within the <a href="lang_aggfunc.html#sumunc">sum()</a> aggregate function
and so that output column is the sum of all "c" values in rows that
have the same value for "a".  But what is the result of the bare 
column "b"? The answer is that the "b" result will be the
value for "b" in one of the input rows that form the aggregate.
The problem is that you usually do not know which input row is used
to compute "b", and so in many cases the value for "b" is undefined.
</p>
<p>
Special processing occurs when the aggregate function is 
either <a href="lang_aggfunc.html#maxggunc">min()</a> or <a href="lang_aggfunc.html#minggunc">max()</a>.  Example:
</p><blockquote><pre>
SELECT a, b, max(c) FROM tab1 GROUP BY a;
</pre></blockquote>

<p>When the <a href="lang_aggfunc.html#maxggunc">min()</a> or <a href="lang_aggfunc.html#minggunc">max()</a> aggregate functions 
are used in an aggregate query, all bare columns in the result set 
take values from the input
row which also contains the minimum or maximum.  So in the query
above, the value of the "b" column in the output will be the value of
the "b" column in the input row that has the largest "c" value.
There is still an ambiguity if two or more of the input rows have the
same minimum or maximum value or if the query contains more than one
min() and/or max() aggregate function. Only the built-in <a href="lang_aggfunc.html#minggunc">min()</a> 
and <a href="lang_aggfunc.html#maxggunc">max()</a> functions work this way.
</p>

<p><b>4. Removal of duplicate rows (DISTINCT processing).</b>
<a name="distinct"></a>



</p><p>One of the ALL or DISTINCT keywords may follow the SELECT keyword in a 
simple SELECT statement. If the simple SELECT is a SELECT ALL, then the
entire set of result rows are returned by the SELECT. If neither ALL or
DISTINCT are present, then the behavior is as if ALL were specified. 
If the simple SELECT is a SELECT DISTINCT, then duplicate rows are removed
from the set of result rows before it is returned. For the purposes of
detecting duplicate rows, two NULL values are considered to be equal. The
<a href="datatype3.html#colrules">usual rules</a> apply for selecting a collation
sequence to compare text values.

<a name="compound"></a>

</p><h1 id="compound_select_statements"><span>3. </span>Compound Select Statements</h1>

<p>Two or more <a href="lang_select.html#simpleselect">simple SELECT</a> statements may be connected together to form
a compound SELECT using the UNION, UNION ALL, INTERSECT or EXCEPT operator,
as shown by the following diagram:

<p><b><a href="syntax/compound-select-stmt.html">compound-select-stmt:</a></b>
<button id='x1957' onclick='hideorshow("x1957","x1958")'>hide</button></p>
 <div id='x1958' class='imgcontainer'>
 <img alt="syntax diagram compound-select-stmt" src="images/syntax/compound-select-stmt.gif" />
<p><b><a href="syntax/common-table-expression.html">common-table-expression:</a></b>
<button id='x1959' onclick='hideorshow("x1959","x1960")'>show</button></p>
 <div id='x1960' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
<button id='x1961' onclick='hideorshow("x1961","x1962")'>show</button></p>
 <div id='x1962' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntax/compound-operator.html">compound-operator:</a></b>
<button id='x1963' onclick='hideorshow("x1963","x1964")'>show</button></p>
 <div id='x1964' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</div>
<p><b><a href="syntax/join-clause.html">join-clause:</a></b>
<button id='x1965' onclick='hideorshow("x1965","x1966")'>show</button></p>
 <div id='x1966' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
<button id='x1967' onclick='hideorshow("x1967","x1968")'>show</button></p>
 <div id='x1968' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</div>
<p><b><a href="syntax/join-operator.html">join-operator:</a></b>
<button id='x1969' onclick='hideorshow("x1969","x1970")'>show</button></p>
 <div id='x1970' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</div>
</div>
<p><b><a href="syntax/result-column.html">result-column:</a></b>
<button id='x1971' onclick='hideorshow("x1971","x1972")'>show</button></p>
 <div id='x1972' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</div>
<p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
<button id='x1973' onclick='hideorshow("x1973","x1974")'>show</button></p>
 <div id='x1974' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</div>
<p><b><a href="syntax/window-defn.html">window-defn:</a></b>
<button id='x1975' onclick='hideorshow("x1975","x1976")'>show</button></p>
 <div id='x1976' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram window-defn" src="images/syntax/window-defn.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x1977' onclick='hideorshow("x1977","x1978")'>show</button></p>
 <div id='x1978' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
</div>
</div>
</div>
<p><b><a href="syntax/expr.html">expr:</a></b>
<button id='x1979' onclick='hideorshow("x1979","x1980")'>show</button></p>
 <div id='x1980' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntax/filter-clause.html">filter-clause:</a></b>
<button id='x1981' onclick='hideorshow("x1981","x1982")'>show</button></p>
 <div id='x1982' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram filter-clause" src="images/syntax/filter-clause.gif" />
</div>
<p><b><a href="syntax/literal-value.html">literal-value:</a></b>
<button id='x1983' onclick='hideorshow("x1983","x1984")'>show</button></p>
 <div id='x1984' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</div>
<p><b><a href="syntax/over-clause.html">over-clause:</a></b>
<button id='x1985' onclick='hideorshow("x1985","x1986")'>show</button></p>
 <div id='x1986' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram over-clause" src="images/syntax/over-clause.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x1987' onclick='hideorshow("x1987","x1988")'>show</button></p>
 <div id='x1988' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
</div>
<p><b><a href="syntax/raise-function.html">raise-function:</a></b>
<button id='x1989' onclick='hideorshow("x1989","x1990")'>show</button></p>
 <div id='x1990' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</div>
<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
<button id='x1991' onclick='hideorshow("x1991","x1992")'>show</button></p>
 <div id='x1992' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntax/compound-operator.html">compound-operator:</a></b>
<button id='x1993' onclick='hideorshow("x1993","x1994")'>show</button></p>
 <div id='x1994' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</div>
<p><b><a href="syntax/join-clause.html">join-clause:</a></b>
<button id='x1995' onclick='hideorshow("x1995","x1996")'>show</button></p>
 <div id='x1996' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
<button id='x1997' onclick='hideorshow("x1997","x1998")'>show</button></p>
 <div id='x1998' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</div>
<p><b><a href="syntax/join-operator.html">join-operator:</a></b>
<button id='x1999' onclick='hideorshow("x1999","x2000")'>show</button></p>
 <div id='x2000' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</div>
</div>
<p><b><a href="syntax/result-column.html">result-column:</a></b>
<button id='x2001' onclick='hideorshow("x2001","x2002")'>show</button></p>
 <div id='x2002' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</div>
<p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
<button id='x2003' onclick='hideorshow("x2003","x2004")'>show</button></p>
 <div id='x2004' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</div>
<p><b><a href="syntax/window-defn.html">window-defn:</a></b>
<button id='x2005' onclick='hideorshow("x2005","x2006")'>show</button></p>
 <div id='x2006' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram window-defn" src="images/syntax/window-defn.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x2007' onclick='hideorshow("x2007","x2008")'>show</button></p>
 <div id='x2008' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
</div>
</div>
<p><b><a href="syntax/type-name.html">type-name:</a></b>
<button id='x2009' onclick='hideorshow("x2009","x2010")'>show</button></p>
 <div id='x2010' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
<button id='x2011' onclick='hideorshow("x2011","x2012")'>show</button></p>
 <div id='x2012' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</div>
</div>
</div>
<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
<button id='x2013' onclick='hideorshow("x2013","x2014")'>show</button></p>
 <div id='x2014' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</div>
<p><b><a href="syntax/select-core.html">select-core:</a></b>
<button id='x2015' onclick='hideorshow("x2015","x2016")'>show</button></p>
 <div id='x2016' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram select-core" src="images/syntax/select-core.gif" />
<p><b><a href="syntax/join-clause.html">join-clause:</a></b>
<button id='x2017' onclick='hideorshow("x2017","x2018")'>show</button></p>
 <div id='x2018' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
<button id='x2019' onclick='hideorshow("x2019","x2020")'>show</button></p>
 <div id='x2020' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</div>
<p><b><a href="syntax/join-operator.html">join-operator:</a></b>
<button id='x2021' onclick='hideorshow("x2021","x2022")'>show</button></p>
 <div id='x2022' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</div>
</div>
<p><b><a href="syntax/result-column.html">result-column:</a></b>
<button id='x2023' onclick='hideorshow("x2023","x2024")'>show</button></p>
 <div id='x2024' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</div>
<p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
<button id='x2025' onclick='hideorshow("x2025","x2026")'>show</button></p>
 <div id='x2026' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
<button id='x2027' onclick='hideorshow("x2027","x2028")'>show</button></p>
 <div id='x2028' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntax/compound-operator.html">compound-operator:</a></b>
<button id='x2029' onclick='hideorshow("x2029","x2030")'>show</button></p>
 <div id='x2030' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</div>
</div>
</div>
<p><b><a href="syntax/window-defn.html">window-defn:</a></b>
<button id='x2031' onclick='hideorshow("x2031","x2032")'>show</button></p>
 <div id='x2032' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram window-defn" src="images/syntax/window-defn.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x2033' onclick='hideorshow("x2033","x2034")'>show</button></p>
 <div id='x2034' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
</div>
</div>
</div>


</p><p>In a compound SELECT, all the constituent SELECTs must return the same 
number of result columns. As the components of a compound SELECT must
be simple SELECT statements, they may not contain <a href="lang_select.html#orderby">ORDER BY</a> or <a href="lang_select.html#limitoffset">LIMIT</a> clauses.
<a href="lang_select.html#orderby">ORDER BY</a> and <a href="lang_select.html#limitoffset">LIMIT</a> clauses may only occur at the end of the entire compound
SELECT, and then only if the final element of the compound is not a <a href="lang_select.html#values">VALUES</a> clause.

</p><p>A compound SELECT created using UNION ALL operator returns all the rows
from the SELECT to the left of the UNION ALL operator, and all the rows
from the SELECT to the right of it. The UNION operator works the same way as
UNION ALL, except that duplicate rows are removed from the final result set.
The INTERSECT operator returns the intersection of the results of the left and
right SELECTs.  The EXCEPT operator returns the subset of rows returned by the
left SELECT that are not also returned by the right-hand SELECT. Duplicate
rows are removed from the results of INTERSECT and EXCEPT operators before the
result set is returned.

</p><p>For the purposes of determining duplicate rows for the results of compound
SELECT operators, NULL values are considered equal to other NULL values and
distinct from all non-NULL values. The collation sequence used to compare 
two text values is determined as if the columns of the left and right-hand
SELECT statements were the left and right-hand operands of the equals (=)
operator, except that greater precedence is not assigned to a collation 
sequence specified with the postfix COLLATE operator. No affinity
transformations are applied to any values when comparing rows as part of a
compound SELECT. 

</p><p>When three or more simple SELECTs are connected into a compound SELECT,
they group from left to right. In other words, if "A", "B" and "C" are all
simple SELECT statements, (A op B op C) is processed as ((A op B) op C).

</p>

<a name="orderby"></a>

<h1 id="the_order_by_clause"><span>4. </span>The ORDER BY clause</h1>

<p>If a SELECT statement that returns more than one row does not have an
ORDER BY clause, the order in which the rows are returned is undefined.
Or, if a SELECT statement does have an ORDER BY clause, then the list of
expressions attached to the ORDER BY determine the order in which rows
are returned to the user.

</p><p>
In a <a href="lang_select.html#compound">compound SELECT</a> statement, only the last or right-most <a href="lang_select.html#simpleselect">simple SELECT</a>
may have an ORDER BY clause. That ORDER BY clause will apply across all elements of
the compound. If the right-most element of a <a href="lang_select.html#compound">compound SELECT</a> is a <a href="lang_select.html#values">VALUES</a> clause,
then no ORDER BY clause is allowed on that statement.


</p><p>Rows are first sorted based on the results of
evaluating the left-most expression in the ORDER BY list, then ties are broken
by evaluating the second left-most expression and so on. The order in which
two rows for which all ORDER BY expressions evaluate to equal values are
returned is undefined. Each ORDER BY expression may be optionally followed
by one of the keywords ASC (smaller values are returned first) or DESC (larger
values are returned first). If neither ASC or DESC are specified, rows
are sorted in ascending (smaller values first) order by default.

<a name="nullslast"></a>

</p><p>SQLite considers NULL values to be smaller than any other values
for sorting purposes.  Hence, NULLs naturally appear at the beginning
of an ASC order-by and at the end of a DESC order-by.  This can be changed
using the "ASC NULLS LAST" or "DESC NULLS FIRST" syntax.

</p><p>Each ORDER BY expression is processed as follows:</p>

<ol>
<li><p>If the ORDER BY expression is a constant integer K then the
expression is considered an alias for the K-th column of the result set
(columns are numbered from left to right starting with 1).

</p></li><li><p>If the ORDER BY expression is an identifier that corresponds to
the alias of one of the output columns, then the expression is considered
an alias for that column.

</p></li><li><p>Otherwise, if the ORDER BY expression is any other expression, it 
is evaluated and the returned value used to order the output rows. If
the SELECT statement is a simple SELECT, then an ORDER BY may contain any
arbitrary expressions. However, if the SELECT is a compound SELECT, then
ORDER BY expressions that are not aliases to output columns must be exactly
the same as an expression used as an output column.
</p></li></ol>

<p>For the purposes of sorting rows, values are compared in the same way
as for <a href="datatype3.html#comparisons">comparison expressions</a>. The collation sequence used to compare
two text values is determined as follows:

</p><ol>
  <li><p>If the ORDER BY expression is assigned a collation sequence using
  the postfix <a href="lang_expr.html#collateop">COLLATE operator</a>, then the specified collation sequence is
  used.
  </p></li><li><p>Otherwise, if the ORDER BY expression is an alias to an expression
  that has been assigned a collation sequence using the postfix 
  <a href="lang_expr.html#collateop">COLLATE operator</a>, then the collation sequence assigned to the aliased
  expression is used.
  </p></li><li><p>Otherwise, if the ORDER BY expression is a column or an alias of
  an expression that is a column, then the default collation sequence for
  the column is used. 
  </p></li><li><p>Otherwise, the <a href="datatype3.html#collation">BINARY</a> collation sequence is used.
</p></li></ol>

<p>In a <a href="lang_select.html#compound">compound SELECT</a> statement, all ORDER BY expressions are handled
as aliases for one of the result columns of the compound.
If an ORDER BY expression is not an integer alias, then SQLite searches
the left-most SELECT in the compound for a result column that matches either
the second or third rules above. If a match is found, the search stops and
the expression is handled as an alias for the result column that it has been
matched against. Otherwise, the next SELECT to the right is tried, and so on.
If no matching expression can be found in the result columns of any
constituent SELECT, it is an error. Each term of the ORDER BY clause is
processed separately and may be matched against result columns from different
SELECT statements in the compound.</p>

<a name="limitoffset"></a>

<h1 id="the_limit_clause"><span>5. </span>The LIMIT clause</h1>

<p>The LIMIT clause is used to place an upper bound on the number of rows
returned by the entire SELECT statement.

</p><p>In a <a href="lang_select.html#compound">compound SELECT</a>, only the
last or right-most <a href="lang_select.html#simpleselect">simple SELECT</a> may contain a LIMIT clause.  
In a <a href="lang_select.html#compound">compound SELECT</a>, 
the LIMIT clause applies to the entire compound, not just the final SELECT.
If the right-most <a href="lang_select.html#simpleselect">simple SELECT</a> is a <a href="lang_select.html#values">VALUES clause</a> then no LIMIT clause
is allowed.

</p><p>Any scalar expression may be used in the 
LIMIT clause, so long as it evaluates to an integer or a value that can be
losslessly converted to an integer. If the expression evaluates to a NULL 
value or any other value that cannot be losslessly converted to an integer, an
error is returned. If the LIMIT expression evaluates to a negative value,
then there is no upper bound on the number of rows returned. Otherwise, the
SELECT returns the first N rows of its result set only, where N is the value
that the LIMIT expression evaluates to. Or, if the SELECT statement would
return less than N rows without a LIMIT clause, then the entire result set is
returned. 

</p><p>The expression attached to the optional OFFSET clause that may follow a
LIMIT clause must also evaluate to an integer, or a value that can be
losslessly converted to an integer. If an expression has an OFFSET clause,
then the first M rows are omitted from the result set returned by the SELECT
statement and the next N rows are returned, where M and N are the values that
the OFFSET and LIMIT clauses evaluate to, respectively. Or, if the SELECT
would return less than M+N rows if it did not have a LIMIT clause, then the
first M rows are skipped and the remaining rows (if any) are returned. If the
OFFSET clause evaluates to a negative value, the results are the same as if it
had evaluated to zero.

</p><p>Instead of a separate OFFSET clause, the LIMIT clause may specify two
scalar expressions separated by a comma. In this case, the first expression
is used as the OFFSET expression and the second as the LIMIT expression.
This is counter-intuitive, as when using the OFFSET clause the second of
the two expressions is the OFFSET and the first the LIMIT. 
This reversal of the offset and limit is intentional
- it maximizes compatibility with other SQL database systems.
However, to avoid confusion, programmers are strongly encouraged to use
the form of the LIMIT clause that uses the "OFFSET" keyword and avoid
using a LIMIT clause with a comma-separated offset.

<a name="values"></a>

</p><h1 id="the_values_clause"><span>6. </span>The VALUES clause</h1>

<p>The phrase "VALUES(<i>expr-list</i>)" means the same thing
as "SELECT <i>expr-list</i>".  The phrase
"VALUES(<i>expr-list-1</i>),...,(<i>expr-list-N</i>)" means the same
thing as "SELECT <i>expr-list-1</i> UNION ALL ... UNION ALL
SELECT <i>expr-list-N</i>".  Both forms are the same, except that
the number of SELECT statements in a compound is limited by
<a href="c3ref/c_limit_attached.html#sqlitelimitcompoundselect">SQLITE_LIMIT_COMPOUND_SELECT</a> whereas the number of rows in a
VALUES clause has no arbitrary limit.

</p><p>There are some restrictions on the use of a VALUES clause that are
not shown on the syntax diagrams:

</p><ul>
<li><p>
A VALUES clause cannot be followed by <a href="lang_select.html#orderby">ORDER BY</a>.

</p></li><li><p>
A VALUES clause cannot be followed by <a href="lang_select.html#limitoffset">LIMIT</a>.
</p></li></ul>


<h1 id="the_with_clause"><span>7. </span>The WITH Clause</h1>

<p>SELECT statements may be optionally preceded by a single
<a href="lang_with.html">WITH clause</a> that defines one or more <a href="lang_with.html">common table expressions</a>
for use within the SELECT statement.

<a name="tabfunc1"></a>

</p><h1 id="table_valued_functions_in_the_from_clause"><span>8. </span>Table-valued Functions In The FROM Clause</h1>

<p>A <a href="vtab.html">virtual table</a> that contains <a href="vtab.html#hiddencol">hidden columns</a> can be used like
a <a href="vtab.html#tabfunc2">table-valued function</a> in the FROM clause.  The arguments to the
table-valued function become constraints on the HIDDEN columns of
the virtual table.  Additional information can be found in the
<a href="vtab.html#tabfunc2">virtual table documentation</a>.
</p>

Changes to Doc/Extra/Core/lang_transaction.html.
1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>SQLite Query Language: BEGIN TRANSACTION</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>





|







1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>Transaction</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93












94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109


110
111
112
113
114
115
116
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>












<div class=nosearch><h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>BEGIN TRANSACTION</h2></div><p><b><a href="syntax/begin-stmt.html">begin-stmt:</a></b>
<button id='x1287' onclick='hideorshow("x1287","x1288")'>hide</button></p>
 <div id='x1288' class='imgcontainer'>
 <img alt="syntax diagram begin-stmt" src="images/syntax/begin-stmt.gif" />
</div>
<p><b><a href="syntax/commit-stmt.html">commit-stmt:</a></b>
<button id='x1289' onclick='hideorshow("x1289","x1290")'>hide</button></p>
 <div id='x1290' class='imgcontainer'>
 <img alt="syntax diagram commit-stmt" src="images/syntax/commit-stmt.gif" />
</div>
<p><b><a href="syntax/rollback-stmt.html">rollback-stmt:</a></b>
<button id='x1291' onclick='hideorshow("x1291","x1292")'>hide</button></p>
 <div id='x1292' class='imgcontainer'>
 <img alt="syntax diagram rollback-stmt" src="images/syntax/rollback-stmt.gif" />
</div>




<p>
No reads or writes occur except within a transaction.
Any command that accesses the database (basically, any SQL command,
except a few <a href="pragma.html#syntax">PRAGMA</a> statements)
will automatically start a transaction if
one is not already in effect.  Automatically started transactions







|

















>
>
>
>
>
>
>
>
>
>
>
>
|
|
|



|
|



|
|



>
>







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<div class=fancy>
<div class=nosearch>
<div class="fancy_title">
Transaction
</div>
</div>




<h1 id="transaction_control_syntax"><span>1. </span>Transaction Control Syntax</h1>

<p><b><a href="syntax/begin-stmt.html">begin-stmt:</a></b>
<button id='x2035' onclick='hideorshow("x2035","x2036")'>hide</button></p>
 <div id='x2036' class='imgcontainer'>
 <img alt="syntax diagram begin-stmt" src="images/syntax/begin-stmt.gif" />
</div>
<p><b><a href="syntax/commit-stmt.html">commit-stmt:</a></b>
<button id='x2037' onclick='hideorshow("x2037","x2038")'>hide</button></p>
 <div id='x2038' class='imgcontainer'>
 <img alt="syntax diagram commit-stmt" src="images/syntax/commit-stmt.gif" />
</div>
<p><b><a href="syntax/rollback-stmt.html">rollback-stmt:</a></b>
<button id='x2039' onclick='hideorshow("x2039","x2040")'>hide</button></p>
 <div id='x2040' class='imgcontainer'>
 <img alt="syntax diagram rollback-stmt" src="images/syntax/rollback-stmt.gif" />
</div>


<h1 id="transactions"><span>2. </span>Transactions</h1>

<p>
No reads or writes occur except within a transaction.
Any command that accesses the database (basically, any SQL command,
except a few <a href="pragma.html#syntax">PRAGMA</a> statements)
will automatically start a transaction if
one is not already in effect.  Automatically started transactions
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
transactions.  An attempt to invoke the BEGIN command within
a transaction will fail with an error, regardless of whether
the transaction was started by <a href="lang_savepoint.html">SAVEPOINT</a> or a prior BEGIN.
The COMMIT command and the ROLLBACK command without the TO clause
work the same on <a href="lang_savepoint.html">SAVEPOINT</a> transactions as they do with transactions
started by BEGIN.</p>

<h3>Read transactions versus write transactions</h3>

<p>SQLite current supports multiple simultaneous read transactions
coming from separate database connections, possibly in separate
threads or processes, but only one simultaneous write transaction.
<p>

<p>A read transaction is used for reading only.  A write transaction
allows both reading and writing.  A read transaction is started
by a SELECT statement, and a write transaction is started by 
statements like CREATE, DELETE, DROP, INSERT, or UPDATE (collectively
"write statements").  If a write statement occurs while
a read transaction is active, then the read transaction is upgraded
to write transaction if possible.  If some other database connection
has already modified the database or is already in the process of







|




|

|







153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
transactions.  An attempt to invoke the BEGIN command within
a transaction will fail with an error, regardless of whether
the transaction was started by <a href="lang_savepoint.html">SAVEPOINT</a> or a prior BEGIN.
The COMMIT command and the ROLLBACK command without the TO clause
work the same on <a href="lang_savepoint.html">SAVEPOINT</a> transactions as they do with transactions
started by BEGIN.</p>

<h2 id="read_transactions_versus_write_transactions"><span>2.1. </span>Read transactions versus write transactions</h2>

<p>SQLite current supports multiple simultaneous read transactions
coming from separate database connections, possibly in separate
threads or processes, but only one simultaneous write transaction.
</p><p>

</p><p>A read transaction is used for reading only.  A write transaction
allows both reading and writing.  A read transaction is started
by a SELECT statement, and a write transaction is started by 
statements like CREATE, DELETE, DROP, INSERT, or UPDATE (collectively
"write statements").  If a write statement occurs while
a read transaction is active, then the read transaction is upgraded
to write transaction if possible.  If some other database connection
has already modified the database or is already in the process of
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
transaction is active, X will continue to see an historic snapshot
the database prior to the changes implemented by Y.
</p>


<a name="immediate"></a>

<h3>DEFERRED, IMMEDIATE, and EXCLUSIVE transactions</h3>

<p>
Transactions can be DEFERRED, IMMEDIATE, or EXCLUSIVE.
The default transaction behavior is DEFERRED.
</p>

<p>
DEFERRED means that the transaction does not actually
start until the database is first accessed.  Internally,
the BEGIN DEFERRRED statement merely sets a flag on the database 
connection that turns off the automatic commit that would normally
occur when the last statement finishes.  This causes the transaction
that is automatically started to persist until an explicit
COMMIT or ROLLBACK or until a rollback is provoked by an error
or an ON CONFLICT ROLLBACK clause.  If the first statement after
BEGIN DEFERRED is a SELECT, then a read transaction is started.
Subsequent write statements will upgrade the transaction to a







|









|







187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
transaction is active, X will continue to see an historic snapshot
the database prior to the changes implemented by Y.
</p>


<a name="immediate"></a>

<h2 id="deferred_immediate_and_exclusive_transactions"><span>2.2. </span>DEFERRED, IMMEDIATE, and EXCLUSIVE transactions</h2>

<p>
Transactions can be DEFERRED, IMMEDIATE, or EXCLUSIVE.
The default transaction behavior is DEFERRED.
</p>

<p>
DEFERRED means that the transaction does not actually
start until the database is first accessed.  Internally,
the BEGIN DEFERRED statement merely sets a flag on the database 
connection that turns off the automatic commit that would normally
occur when the last statement finishes.  This causes the transaction
that is automatically started to persist until an explicit
COMMIT or ROLLBACK or until a rollback is provoked by an error
or an ON CONFLICT ROLLBACK clause.  If the first statement after
BEGIN DEFERRED is a SELECT, then a read transaction is started.
Subsequent write statements will upgrade the transaction to a
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
EXCLUSIVE is similar to IMMEDIATE in that a write transaction
is started immediately.  EXCLUSIVE and IMMEDIATE are the same
in <a href="wal.html">WAL mode</a>, but in other journaling modes, EXCLUSIVE prevents
other database connections from reading the database while the
transaction is underway.
</p>

<h3>Implicit versus explicit transactions</h3>

<p>
An implicit transaction (a transaction that is started automatically,
not a transaction started by BEGIN) is committed automatically when
the last active statement finishes.  A statement finishes when its
last cursor closes, which is guaranteed to happen when the
prepared statement is <a href="c3ref/reset.html">reset</a> or







|







225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
EXCLUSIVE is similar to IMMEDIATE in that a write transaction
is started immediately.  EXCLUSIVE and IMMEDIATE are the same
in <a href="wal.html">WAL mode</a>, but in other journaling modes, EXCLUSIVE prevents
other database connections from reading the database while the
transaction is underway.
</p>

<h2 id="implicit_versus_explicit_transactions"><span>2.3. </span>Implicit versus explicit transactions</h2>

<p>
An implicit transaction (a transaction that is started automatically,
not a transaction started by BEGIN) is committed automatically when
the last active statement finishes.  A statement finishes when its
last cursor closes, which is guaranteed to happen when the
prepared statement is <a href="c3ref/reset.html">reset</a> or
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
</p>

<p>
If <a href="pragma.html#pragma_journal_mode">PRAGMA journal_mode</a> is set to OFF (thus disabling the rollback journal
file) then the behavior of the ROLLBACK command is undefined.
</p>

<h3>Response To Errors Within A Transaction</h3>

<p> If certain kinds of errors occur within a transaction, the
transaction may or may not be rolled back automatically.  The
errors that can cause an automatic rollback include:</p>

<ul>
<li> <a href="rescode.html#full">SQLITE_FULL</a>: database or disk full
<li> <a href="rescode.html#ioerr">SQLITE_IOERR</a>: disk I/O error
<li> <a href="rescode.html#busy">SQLITE_BUSY</a>: database in use by another process
<li> <a href="rescode.html#nomem">SQLITE_NOMEM</a>: out or memory
</ul>

<p>
For all of these errors, SQLite attempts to undo just the one statement
it was working on and leave changes from prior statements within the
same transaction intact and continue with the transaction.  However, 
depending on the statement being evaluated and the point at which the
error occurs, it might be necessary for SQLite to rollback and







|







|
|
|
|







275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
</p>

<p>
If <a href="pragma.html#pragma_journal_mode">PRAGMA journal_mode</a> is set to OFF (thus disabling the rollback journal
file) then the behavior of the ROLLBACK command is undefined.
</p>

<h1 id="response_to_errors_within_a_transaction"><span>3. </span>Response To Errors Within A Transaction</h1>

<p> If certain kinds of errors occur within a transaction, the
transaction may or may not be rolled back automatically.  The
errors that can cause an automatic rollback include:</p>

<ul>
<li> <a href="rescode.html#full">SQLITE_FULL</a>: database or disk full
</li><li> <a href="rescode.html#ioerr">SQLITE_IOERR</a>: disk I/O error
</li><li> <a href="rescode.html#busy">SQLITE_BUSY</a>: database in use by another process
</li><li> <a href="rescode.html#nomem">SQLITE_NOMEM</a>: out or memory
</li></ul>

<p>
For all of these errors, SQLite attempts to undo just the one statement
it was working on and leave changes from prior statements within the
same transaction intact and continue with the transaction.  However, 
depending on the statement being evaluated and the point at which the
error occurs, it might be necessary for SQLite to rollback and
295
296
297
298
299
300
301
302
303
error, but no harm is caused by this.</p>

<p>Future versions of SQLite may extend the list of errors which
might cause automatic transaction rollback.  Future versions of
SQLite might change the error response.  In particular, we may
choose to simplify the interface in future versions of SQLite by
causing the errors above to force an unconditional rollback.</p>










<
309
310
311
312
313
314
315
316

error, but no harm is caused by this.</p>

<p>Future versions of SQLite may extend the list of errors which
might cause automatic transaction rollback.  Future versions of
SQLite might change the error response.  In particular, we may
choose to simplify the interface in future versions of SQLite by
causing the errors above to force an unconditional rollback.</p>


Changes to Doc/Extra/Core/lang_update.html.
1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>SQLite Query Language: UPDATE</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>





|







1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>UPDATE</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93




































94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278


279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>




































<div class=nosearch><h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>UPDATE</h2></div><p><b><a href="syntax/update-stmt.html">update-stmt:</a></b>
<button id='x2131' onclick='hideorshow("x2131","x2132")'>hide</button></p>
 <div id='x2132' class='imgcontainer'>
 <img alt="syntax diagram update-stmt" src="images/syntax/update-stmt.gif" />
<p><b><a href="syntax/column-name-list.html">column-name-list:</a></b>
<button id='x2133' onclick='hideorshow("x2133","x2134")'>show</button></p>
 <div id='x2134' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram column-name-list" src="images/syntax/column-name-list.gif" />
</div>
<p><b><a href="syntax/expr.html">expr:</a></b>
<button id='x2135' onclick='hideorshow("x2135","x2136")'>show</button></p>
 <div id='x2136' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntax/filter-clause.html">filter-clause:</a></b>
<button id='x2137' onclick='hideorshow("x2137","x2138")'>show</button></p>
 <div id='x2138' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram filter-clause" src="images/syntax/filter-clause.gif" />
</div>
<p><b><a href="syntax/literal-value.html">literal-value:</a></b>
<button id='x2139' onclick='hideorshow("x2139","x2140")'>show</button></p>
 <div id='x2140' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</div>
<p><b><a href="syntax/over-clause.html">over-clause:</a></b>
<button id='x2141' onclick='hideorshow("x2141","x2142")'>show</button></p>
 <div id='x2142' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram over-clause" src="images/syntax/over-clause.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x2143' onclick='hideorshow("x2143","x2144")'>show</button></p>
 <div id='x2144' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
<button id='x2145' onclick='hideorshow("x2145","x2146")'>show</button></p>
 <div id='x2146' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</div>
</div>
<p><b><a href="syntax/raise-function.html">raise-function:</a></b>
<button id='x2147' onclick='hideorshow("x2147","x2148")'>show</button></p>
 <div id='x2148' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</div>
<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
<button id='x2149' onclick='hideorshow("x2149","x2150")'>show</button></p>
 <div id='x2150' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntax/common-table-expression.html">common-table-expression:</a></b>
<button id='x2151' onclick='hideorshow("x2151","x2152")'>show</button></p>
 <div id='x2152' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
</div>
<p><b><a href="syntax/compound-operator.html">compound-operator:</a></b>
<button id='x2153' onclick='hideorshow("x2153","x2154")'>show</button></p>
 <div id='x2154' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</div>
<p><b><a href="syntax/join-clause.html">join-clause:</a></b>
<button id='x2155' onclick='hideorshow("x2155","x2156")'>show</button></p>
 <div id='x2156' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
<button id='x2157' onclick='hideorshow("x2157","x2158")'>show</button></p>
 <div id='x2158' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</div>
<p><b><a href="syntax/join-operator.html">join-operator:</a></b>
<button id='x2159' onclick='hideorshow("x2159","x2160")'>show</button></p>
 <div id='x2160' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</div>
</div>
<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
<button id='x2161' onclick='hideorshow("x2161","x2162")'>show</button></p>
 <div id='x2162' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</div>
<p><b><a href="syntax/result-column.html">result-column:</a></b>
<button id='x2163' onclick='hideorshow("x2163","x2164")'>show</button></p>
 <div id='x2164' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</div>
<p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
<button id='x2165' onclick='hideorshow("x2165","x2166")'>show</button></p>
 <div id='x2166' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</div>
<p><b><a href="syntax/window-defn.html">window-defn:</a></b>
<button id='x2167' onclick='hideorshow("x2167","x2168")'>show</button></p>
 <div id='x2168' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram window-defn" src="images/syntax/window-defn.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x2169' onclick='hideorshow("x2169","x2170")'>show</button></p>
 <div id='x2170' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
</div>
</div>
<p><b><a href="syntax/type-name.html">type-name:</a></b>
<button id='x2171' onclick='hideorshow("x2171","x2172")'>show</button></p>
 <div id='x2172' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
<button id='x2173' onclick='hideorshow("x2173","x2174")'>show</button></p>
 <div id='x2174' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</div>
</div>
</div>
<p><b><a href="syntax/qualified-table-name.html">qualified-table-name:</a></b>
<button id='x2175' onclick='hideorshow("x2175","x2176")'>show</button></p>
 <div id='x2176' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram qualified-table-name" src="images/syntax/qualified-table-name.gif" />
</div>
<p><b><a href="syntax/with-clause.html">with-clause:</a></b>
<button id='x2177' onclick='hideorshow("x2177","x2178")'>show</button></p>
 <div id='x2178' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram with-clause" src="images/syntax/with-clause.gif" />
<p><b><a href="syntax/cte-table-name.html">cte-table-name:</a></b>
<button id='x2179' onclick='hideorshow("x2179","x2180")'>show</button></p>
 <div id='x2180' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram cte-table-name" src="images/syntax/cte-table-name.gif" />
</div>
<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
<button id='x2181' onclick='hideorshow("x2181","x2182")'>show</button></p>
 <div id='x2182' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntax/common-table-expression.html">common-table-expression:</a></b>
<button id='x2183' onclick='hideorshow("x2183","x2184")'>show</button></p>
 <div id='x2184' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
</div>
<p><b><a href="syntax/compound-operator.html">compound-operator:</a></b>
<button id='x2185' onclick='hideorshow("x2185","x2186")'>show</button></p>
 <div id='x2186' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</div>
<p><b><a href="syntax/join-clause.html">join-clause:</a></b>
<button id='x2187' onclick='hideorshow("x2187","x2188")'>show</button></p>
 <div id='x2188' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
<button id='x2189' onclick='hideorshow("x2189","x2190")'>show</button></p>
 <div id='x2190' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</div>
<p><b><a href="syntax/join-operator.html">join-operator:</a></b>
<button id='x2191' onclick='hideorshow("x2191","x2192")'>show</button></p>
 <div id='x2192' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</div>
</div>
<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
<button id='x2193' onclick='hideorshow("x2193","x2194")'>show</button></p>
 <div id='x2194' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</div>
<p><b><a href="syntax/result-column.html">result-column:</a></b>
<button id='x2195' onclick='hideorshow("x2195","x2196")'>show</button></p>
 <div id='x2196' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</div>
<p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
<button id='x2197' onclick='hideorshow("x2197","x2198")'>show</button></p>
 <div id='x2198' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</div>
<p><b><a href="syntax/window-defn.html">window-defn:</a></b>
<button id='x2199' onclick='hideorshow("x2199","x2200")'>show</button></p>
 <div id='x2200' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram window-defn" src="images/syntax/window-defn.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x2201' onclick='hideorshow("x2201","x2202")'>show</button></p>
 <div id='x2202' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
</div>
</div>
</div>
</div>


<p>An UPDATE statement is used to modify a subset of the values stored in 
zero or more rows of the database table identified by the 
<a href="syntax/qualified-table-name.html">qualified-table-name</a> specified as part of the UPDATE statement.



<p>If the UPDATE statement does not have a WHERE clause, all rows in the
table are modified by the UPDATE. Otherwise, the UPDATE affects only those
rows for which the WHERE clause
<a href="lang_expr.html#booleanexpr">boolean expression is true</a>. It is not an error if the
WHERE clause does not evaluate to true for any row in the table - this just
means that the UPDATE statement affects zero rows.

<p>The modifications made to each row affected by an UPDATE statement are
determined by the list of assignments following the SET keyword. Each
assignment specifies a <span class='yyterm'>column-name</span> to the left of the 
equals sign and a scalar expression to the right. 
For each affected row, the named columns
are set to the values found by evaluating the corresponding scalar 
expressions. If a single column-name appears more than once in the list of
assignment expressions, all but the rightmost occurrence is ignored. Columns
that do not appear in the list of assignments are left unmodified. The scalar
expressions may refer to columns of the row being updated. In this case all
scalar expressions are evaluated before any assignments are made.

<p>Beginning in SQLite <a href="releaselog/3_15_0.html">version 3.15.0</a> (2016-10-14), an assignment in
the SET clause can be a 
<a href="syntax/column-name-list.html">parenthesized list of column names</a> on the left and a
<a href="rowvalue.html">row value</a> of the same size on the right.


<p>The optional "OR <i>action</i>" conflict clause that follows the
UPDATE keyword allows the user to nominate a specific
constraint conflict resolution algorithm to use during this one UPDATE command.
Refer to the section entitled <a href="lang_conflict.html">ON CONFLICT</a> for additional information.

<h3>Restrictions on UPDATE Statements Within CREATE TRIGGER</h3>

<p>The following additional syntax restrictions apply to UPDATE statements that
occur within the body of a <a href="lang_createtrigger.html">CREATE TRIGGER</a> statement.  

<ul>
  <li><p>The <span class='yyterm'>table-name</span> specified as part of an UPDATE 
      statement within
      a trigger body must be unqualified. In other words, the
      <i>schema-name</i><b>.</b> prefix on the table name of the UPDATE is
      not allowed within triggers. Unless the table to which the trigger
      is attached is in the TEMP database, the table being updated by the
      trigger program must reside in the same database as it. If the table
      to which the trigger is attached is in the TEMP database, then the
      unqualified name of the table being updated is resolved in the same way
      as it is for a top-level statement (by searching first the TEMP database,
      then the main database, then any other databases in the order they were
      attached).

  <li><p>The INDEXED BY and NOT INDEXED clauses are not allowed on UPDATE
      statements within triggers.</p>

  <li><p>The LIMIT and ORDER BY clauses for UPDATE are unsupported within
      triggers, regardless of the compilation options used to build SQLite.
</ul>

<h3>Optional LIMIT and ORDER BY Clauses</h3>

<p>If SQLite is built with the <a href="compile.html#enable_update_delete_limit">SQLITE_ENABLE_UPDATE_DELETE_LIMIT</a>
compile-time option then the syntax of the UPDATE statement is extended
with optional ORDER BY and LIMIT clauses as follows:</p>

<p><b><a href="syntax/update-stmt-limited.html">update-stmt-limited:</a></b></p><div class='imgcontainer'>
 <img alt="syntax diagram update-stmt-limited" src="images/syntax/update-stmt-limited.gif"></img>
 </div>


<p>If an UPDATE statement has a LIMIT clause, the maximum number of rows that
will be updated is found by evaluating the accompanying expression and casting
it to an integer value. A negative value is interpreted as "no limit".

<p>If the LIMIT expression evaluates to non-negative value <i>N</i> and the
UPDATE statement has an ORDER BY clause, then all rows that would be updated in
the absence of the LIMIT clause are sorted according to the ORDER BY and the
first <i>N</i> updated. If the UPDATE statement also has an OFFSET clause,
then it is similarly evaluated and cast to an integer value. If the OFFSET
expression evaluates to a non-negative value <i>M</i>, then the first <i>M</i>
rows are skipped and the following <i>N</i> rows updated instead.

<p>If the UPDATE statement has no ORDER BY clause, then all rows that
would be updated in the absence of the LIMIT clause are assembled in an
arbitrary order before applying the LIMIT and OFFSET clauses to determine 
which are actually updated.

<p>The ORDER BY clause on an UPDATE statement is used only to determine which
rows fall within the LIMIT. The order in which rows are modified is arbitrary
and is not influenced by the ORDER BY clause.









|

















>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
|


|
|



|
|


|
|



|
|



|
|


|
|



|
|




|
|



|
|


|
|



|
|



|
|


|
|



|
|




|
|



|
|



|
|



|
|


|
|





|
|


|
|





|
|



|
|


|
|



|
|


|
|



|
|



|
|


|
|



|
|




|
|



|
|



|
|



|
|


|
|











>
>








|











|





|




|




|













|


|

|

|














|







|




|


|
<
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405

}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<div class=fancy>
<div class=nosearch>
<div class="fancy_title">
UPDATE
</div>
<div class="fancy_toc">
<a onclick="toggle_toc()">
<span class="fancy_toc_mark" id="toc_mk">&#x25ba;</span>
Table Of Contents
</a>
<div id="toc_sub"><div class="fancy-toc1"><a href="#overview">1. Overview</a></div>
<div class="fancy-toc1"><a href="#details">2. Details</a></div>
<div class="fancy-toc2"><a href="#restrictions_on_update_statements_within_create_trigger">2.1. Restrictions on UPDATE Statements Within CREATE TRIGGER</a></div>
<div class="fancy-toc2"><a href="#optional_limit_and_order_by_clauses">2.2. Optional LIMIT and ORDER BY Clauses</a></div>
</div>
</div>
<script>
function toggle_toc(){
var sub = document.getElementById("toc_sub")
var mk = document.getElementById("toc_mk")
if( sub.style.display!="block" ){
sub.style.display = "block";
mk.innerHTML = "&#x25bc;";
} else {
sub.style.display = "none";
mk.innerHTML = "&#x25ba;";
}
}
</script>
</div>




<h1 id="overview"><span>1. </span>Overview</h1>

<p><b><a href="syntax/update-stmt.html">update-stmt:</a></b>
<button id='x2041' onclick='hideorshow("x2041","x2042")'>hide</button></p>
 <div id='x2042' class='imgcontainer'>
 <img alt="syntax diagram update-stmt" src="images/syntax/update-stmt.gif" />
<p><b><a href="syntax/column-name-list.html">column-name-list:</a></b>
<button id='x2043' onclick='hideorshow("x2043","x2044")'>show</button></p>
 <div id='x2044' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram column-name-list" src="images/syntax/column-name-list.gif" />
</div>
<p><b><a href="syntax/expr.html">expr:</a></b>
<button id='x2045' onclick='hideorshow("x2045","x2046")'>show</button></p>
 <div id='x2046' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntax/filter-clause.html">filter-clause:</a></b>
<button id='x2047' onclick='hideorshow("x2047","x2048")'>show</button></p>
 <div id='x2048' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram filter-clause" src="images/syntax/filter-clause.gif" />
</div>
<p><b><a href="syntax/literal-value.html">literal-value:</a></b>
<button id='x2049' onclick='hideorshow("x2049","x2050")'>show</button></p>
 <div id='x2050' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</div>
<p><b><a href="syntax/over-clause.html">over-clause:</a></b>
<button id='x2051' onclick='hideorshow("x2051","x2052")'>show</button></p>
 <div id='x2052' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram over-clause" src="images/syntax/over-clause.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x2053' onclick='hideorshow("x2053","x2054")'>show</button></p>
 <div id='x2054' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
<button id='x2055' onclick='hideorshow("x2055","x2056")'>show</button></p>
 <div id='x2056' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</div>
</div>
<p><b><a href="syntax/raise-function.html">raise-function:</a></b>
<button id='x2057' onclick='hideorshow("x2057","x2058")'>show</button></p>
 <div id='x2058' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</div>
<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
<button id='x2059' onclick='hideorshow("x2059","x2060")'>show</button></p>
 <div id='x2060' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntax/common-table-expression.html">common-table-expression:</a></b>
<button id='x2061' onclick='hideorshow("x2061","x2062")'>show</button></p>
 <div id='x2062' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
</div>
<p><b><a href="syntax/compound-operator.html">compound-operator:</a></b>
<button id='x2063' onclick='hideorshow("x2063","x2064")'>show</button></p>
 <div id='x2064' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</div>
<p><b><a href="syntax/join-clause.html">join-clause:</a></b>
<button id='x2065' onclick='hideorshow("x2065","x2066")'>show</button></p>
 <div id='x2066' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
<button id='x2067' onclick='hideorshow("x2067","x2068")'>show</button></p>
 <div id='x2068' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</div>
<p><b><a href="syntax/join-operator.html">join-operator:</a></b>
<button id='x2069' onclick='hideorshow("x2069","x2070")'>show</button></p>
 <div id='x2070' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</div>
</div>
<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
<button id='x2071' onclick='hideorshow("x2071","x2072")'>show</button></p>
 <div id='x2072' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</div>
<p><b><a href="syntax/result-column.html">result-column:</a></b>
<button id='x2073' onclick='hideorshow("x2073","x2074")'>show</button></p>
 <div id='x2074' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</div>
<p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
<button id='x2075' onclick='hideorshow("x2075","x2076")'>show</button></p>
 <div id='x2076' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</div>
<p><b><a href="syntax/window-defn.html">window-defn:</a></b>
<button id='x2077' onclick='hideorshow("x2077","x2078")'>show</button></p>
 <div id='x2078' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram window-defn" src="images/syntax/window-defn.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x2079' onclick='hideorshow("x2079","x2080")'>show</button></p>
 <div id='x2080' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
</div>
</div>
<p><b><a href="syntax/type-name.html">type-name:</a></b>
<button id='x2081' onclick='hideorshow("x2081","x2082")'>show</button></p>
 <div id='x2082' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
<button id='x2083' onclick='hideorshow("x2083","x2084")'>show</button></p>
 <div id='x2084' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</div>
</div>
</div>
<p><b><a href="syntax/qualified-table-name.html">qualified-table-name:</a></b>
<button id='x2085' onclick='hideorshow("x2085","x2086")'>show</button></p>
 <div id='x2086' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram qualified-table-name" src="images/syntax/qualified-table-name.gif" />
</div>
<p><b><a href="syntax/with-clause.html">with-clause:</a></b>
<button id='x2087' onclick='hideorshow("x2087","x2088")'>show</button></p>
 <div id='x2088' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram with-clause" src="images/syntax/with-clause.gif" />
<p><b><a href="syntax/cte-table-name.html">cte-table-name:</a></b>
<button id='x2089' onclick='hideorshow("x2089","x2090")'>show</button></p>
 <div id='x2090' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram cte-table-name" src="images/syntax/cte-table-name.gif" />
</div>
<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
<button id='x2091' onclick='hideorshow("x2091","x2092")'>show</button></p>
 <div id='x2092' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntax/common-table-expression.html">common-table-expression:</a></b>
<button id='x2093' onclick='hideorshow("x2093","x2094")'>show</button></p>
 <div id='x2094' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
</div>
<p><b><a href="syntax/compound-operator.html">compound-operator:</a></b>
<button id='x2095' onclick='hideorshow("x2095","x2096")'>show</button></p>
 <div id='x2096' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</div>
<p><b><a href="syntax/join-clause.html">join-clause:</a></b>
<button id='x2097' onclick='hideorshow("x2097","x2098")'>show</button></p>
 <div id='x2098' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
<button id='x2099' onclick='hideorshow("x2099","x2100")'>show</button></p>
 <div id='x2100' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</div>
<p><b><a href="syntax/join-operator.html">join-operator:</a></b>
<button id='x2101' onclick='hideorshow("x2101","x2102")'>show</button></p>
 <div id='x2102' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</div>
</div>
<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
<button id='x2103' onclick='hideorshow("x2103","x2104")'>show</button></p>
 <div id='x2104' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</div>
<p><b><a href="syntax/result-column.html">result-column:</a></b>
<button id='x2105' onclick='hideorshow("x2105","x2106")'>show</button></p>
 <div id='x2106' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</div>
<p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
<button id='x2107' onclick='hideorshow("x2107","x2108")'>show</button></p>
 <div id='x2108' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</div>
<p><b><a href="syntax/window-defn.html">window-defn:</a></b>
<button id='x2109' onclick='hideorshow("x2109","x2110")'>show</button></p>
 <div id='x2110' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram window-defn" src="images/syntax/window-defn.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x2111' onclick='hideorshow("x2111","x2112")'>show</button></p>
 <div id='x2112' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
</div>
</div>
</div>
</div>


<p>An UPDATE statement is used to modify a subset of the values stored in 
zero or more rows of the database table identified by the 
<a href="syntax/qualified-table-name.html">qualified-table-name</a> specified as part of the UPDATE statement.

</p><h1 id="details"><span>2. </span>Details</h1>

<p>If the UPDATE statement does not have a WHERE clause, all rows in the
table are modified by the UPDATE. Otherwise, the UPDATE affects only those
rows for which the WHERE clause
<a href="lang_expr.html#booleanexpr">boolean expression is true</a>. It is not an error if the
WHERE clause does not evaluate to true for any row in the table - this just
means that the UPDATE statement affects zero rows.

</p><p>The modifications made to each row affected by an UPDATE statement are
determined by the list of assignments following the SET keyword. Each
assignment specifies a <span class='yyterm'>column-name</span> to the left of the 
equals sign and a scalar expression to the right. 
For each affected row, the named columns
are set to the values found by evaluating the corresponding scalar 
expressions. If a single column-name appears more than once in the list of
assignment expressions, all but the rightmost occurrence is ignored. Columns
that do not appear in the list of assignments are left unmodified. The scalar
expressions may refer to columns of the row being updated. In this case all
scalar expressions are evaluated before any assignments are made.

</p><p>Beginning in SQLite <a href="releaselog/3_15_0.html">version 3.15.0</a> (2016-10-14), an assignment in
the SET clause can be a 
<a href="syntax/column-name-list.html">parenthesized list of column names</a> on the left and a
<a href="rowvalue.html">row value</a> of the same size on the right.


</p><p>The optional "OR <i>action</i>" conflict clause that follows the
UPDATE keyword allows the user to nominate a specific
constraint conflict resolution algorithm to use during this one UPDATE command.
Refer to the section entitled <a href="lang_conflict.html">ON CONFLICT</a> for additional information.

</p><h2 id="restrictions_on_update_statements_within_create_trigger"><span>2.1. </span>Restrictions on UPDATE Statements Within CREATE TRIGGER</h2>

<p>The following additional syntax restrictions apply to UPDATE statements that
occur within the body of a <a href="lang_createtrigger.html">CREATE TRIGGER</a> statement.  

</p><ul>
  <li><p>The <span class='yyterm'>table-name</span> specified as part of an UPDATE 
      statement within
      a trigger body must be unqualified. In other words, the
      <i>schema-name</i><b>.</b> prefix on the table name of the UPDATE is
      not allowed within triggers. Unless the table to which the trigger
      is attached is in the TEMP database, the table being updated by the
      trigger program must reside in the same database as it. If the table
      to which the trigger is attached is in the TEMP database, then the
      unqualified name of the table being updated is resolved in the same way
      as it is for a top-level statement (by searching first the TEMP database,
      then the main database, then any other databases in the order they were
      attached).

  </p></li><li><p>The INDEXED BY and NOT INDEXED clauses are not allowed on UPDATE
      statements within triggers.</p>

  </li><li><p>The LIMIT and ORDER BY clauses for UPDATE are unsupported within
      triggers, regardless of the compilation options used to build SQLite.
</p></li></ul>

<h2 id="optional_limit_and_order_by_clauses"><span>2.2. </span>Optional LIMIT and ORDER BY Clauses</h2>

<p>If SQLite is built with the <a href="compile.html#enable_update_delete_limit">SQLITE_ENABLE_UPDATE_DELETE_LIMIT</a>
compile-time option then the syntax of the UPDATE statement is extended
with optional ORDER BY and LIMIT clauses as follows:</p>

<p><b><a href="syntax/update-stmt-limited.html">update-stmt-limited:</a></b></p><div class='imgcontainer'>
 <img alt="syntax diagram update-stmt-limited" src="images/syntax/update-stmt-limited.gif"></img>
 </div>


<p>If an UPDATE statement has a LIMIT clause, the maximum number of rows that
will be updated is found by evaluating the accompanying expression and casting
it to an integer value. A negative value is interpreted as "no limit".

</p><p>If the LIMIT expression evaluates to non-negative value <i>N</i> and the
UPDATE statement has an ORDER BY clause, then all rows that would be updated in
the absence of the LIMIT clause are sorted according to the ORDER BY and the
first <i>N</i> updated. If the UPDATE statement also has an OFFSET clause,
then it is similarly evaluated and cast to an integer value. If the OFFSET
expression evaluates to a non-negative value <i>M</i>, then the first <i>M</i>
rows are skipped and the following <i>N</i> rows updated instead.

</p><p>If the UPDATE statement has no ORDER BY clause, then all rows that
would be updated in the absence of the LIMIT clause are assembled in an
arbitrary order before applying the LIMIT and OFFSET clauses to determine 
which are actually updated.

</p><p>The ORDER BY clause on an UPDATE statement is used only to determine which
rows fall within the LIMIT. The order in which rows are modified is arbitrary
and is not influenced by the ORDER BY clause.
</p>

Changes to Doc/Extra/Core/lang_vacuum.html.
1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>SQLite Query Language: VACUUM</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>





|







1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>VACUUM</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93











94
95
96
97
98
99
100

101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>











<div class=nosearch><h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>VACUUM</h2></div><p><b><a href="syntax/vacuum-stmt.html">vacuum-stmt:</a></b>
<button id='x2203' onclick='hideorshow("x2203","x2204")'>hide</button></p>
 <div id='x2204' class='imgcontainer'>
 <img alt="syntax diagram vacuum-stmt" src="images/syntax/vacuum-stmt.gif" />
</div>



<p>
  The VACUUM command rebuilds the database file, repacking it into a minimal
  amount of disk space. There are several 
  reasons an application might do this:

<ul>
  <li> <p> Unless SQLite is running in "auto_vacuum=FULL" mode, when a large
     amount of data is deleted from the database file it leaves behind empty
     space, or "free" database pages. This means the database file might
     be larger than strictly necessary. Running VACUUM to rebuild the 
     database reclaims this space and reduces the size of the database file.

  <li> <p> Frequent inserts, updates, and deletes can cause the database file
     to become fragmented - where data for a single table or index is scattered 
     around the database file. Running VACUUM ensures that each table and
     index is largely stored contiguously within the database file. In some
     cases, VACUUM may also reduce the number of partially filled pages in
     the database, reducing the size of the database file further.

  <li> <p> When content is deleted from an SQLite database, the content is not
     usually erased but rather the space used to hold the content is marked as
     being available for reuse.  This can allow deleted content to be recovered
     by a hacker or by forensic analysis.  Running VACUUM will clean the database
     of all traces of deleted content, thus preventing an adversary from recovering
     deleted content.  Using VACUUM in this way is an alternative to setting
     <a href="pragma.html#pragma_secure_delete">PRAGMA secure_delete=ON</a>. 

  <li> <p> Normally, the database <a href="pragma.html#pragma_page_size">page_size</a> and whether or not the database
     supports <a href="pragma.html#pragma_auto_vacuum">auto_vacuum</a> must be configured before the database file is
     actually created. However, when not in <a href="wal.html">write-ahead log</a> mode, the 
     <a href="pragma.html#pragma_page_size">page_size</a> and/or <a href="pragma.html#pragma_auto_vacuum">auto_vacuum</a> properties of an existing database may be
     changed by using the <a href="pragma.html#pragma_page_size">page_size</a>  and/or 
     <a href="pragma.html#pragma_auto_vacuum">pragma auto_vacuum</a> pragmas and then immediately VACUUMing
     the database. When in <a href="wal.html">write-ahead log</a> mode, only the <a href="pragma.html#pragma_auto_vacuum">auto_vacuum</a>
     support property can be changed using VACUUM.
</ul>

<p>By default, VACUUM only works only on the main database.
<a href="lang_attach.html">Attached databases</a> can be vacuumed by appending the appropriate
<span class='yyterm'>schema-name</span> to the VACUUM statement.

<p><b>Compatibility Warning:</b> The ability to vacuum attached databases was
added in <a href="releaselog/3_15_0.html">version 3.15.0</a> (2016-10-14).  Prior to that, a 
<span class='yyterm'>schema-name</span> added to the
VACUUM statement would be silently ignored and the "main" schema would be
vacuumed.</p>

<a name="vacuuminto"></a>

<h3>VACUUM with an INTO clause</h3>

<p>If the INTO clause is included, then the original database file is
unchanged and a new database is created in the filename given by the
argument to the INTO clause.  The new database will contain the same
logical content as the original database, fully vacuumed.

<p>
The VACUUM command with an INTO clause is an alternative to the
<a href="backup.html">backup API</a> for generating backup copies of a live database.
The advantage of using VACUUM INTO is that the resulting backup
database is minimal in size and hence the amount of filesystem
I/O may be reduced.  Also, all deleted content is purged from the
backup, leaving behind no forensic traces.  On the other hand,
the <a href="backup.html">backup API</a> uses fewer CPU cycles and can be executed
incrementally.

<p>
The filename in the INTO clause can be an arbitrary SQL expression
that evaluates to a string.
The file named by the INTO clause must not previously exist, or
else it must be an empty file, or the VACUUM INTO command will
fail with an error.

<p>
The argument to INTO can be a <a href="uri.html">URI filename</a> if URI filenames
are enabled.
URL filenames are enabled if any of the following are true:
<ul>
<li> The SQLite library was compiled with <a href="compile.html#use_uri">-DSQLITE_USE_URI=1</a>.
<li> The <a href="c3ref/config.html">sqlite3_config</a>(<a href="c3ref/c_config_covering_index_scan.html#sqliteconfiguri">SQLITE_CONFIG_URI</a>,1) interfaces was
     invoked at start-time.
<li> The <a href="c3ref/sqlite3.html">database connection</a> that is running the VACUUM INTO
     statement was originally opened using the
     <a href="c3ref/c_open_autoproxy.html">SQLITE_OPEN_URI</a> flag.
</ul>

<p>
The VACUUM INTO command is transactional in the sense that
the generated output database is a consistent snapshot of the
original database.  However, if the VACUUM INTO command is
interrupted by an unplanned shutdown or power lose, then
the generated output database might be incomplete and corrupt.
Also, SQLite does not invoke fsync() or FlushFileBuffers()
on the generated database to ensure that it has reached
non-volatile storage before completing.


<a name="howvacuumworks"></a>

<h3>How VACUUM works</h3>

<p>The VACUUM command works by copying the contents of the database into
a temporary database file and then overwriting the original with the 
contents of the temporary file. When overwriting the original, a rollback
journal or <a href="wal.html">write-ahead log</a> WAL file is used just as it would be for any
other database transaction. This means that when VACUUMing a database, 
as much as twice the size of the original database file is required in free
disk space.

<p>The VACUUM INTO command works the same way except that it uses the file
named on the INTO clause in place of the temporary database and omits the
step of copying the vacuumed database back over top of the original database.

<p>The VACUUM command may change the <a href="lang_createtable.html#rowid">ROWIDs</a> of entries in any
tables that do not have an explicit <a href="lang_createtable.html#rowid">INTEGER PRIMARY KEY</a>.
</p>

<p>A VACUUM will fail if there is an open transaction on the database
connection that is attempting to run the VACUUM.  Unfinalized SQL
statements typically hold a read transaction open, so the VACUUM
might fail if there are unfinalized SQL statements on the same connection.
VACUUM (but not VACUUM INTO) is a write operation and so if another
database connection is holding a lock that prevents writes, then
the VACUUM will fail.

<p>An alternative to using the VACUUM command to
reclaim space after data has been deleted is auto-vacuum mode, enabled using
the <a href="pragma.html#pragma_auto_vacuum">auto_vacuum</a> pragma. When <a href="pragma.html#pragma_auto_vacuum">auto_vacuum</a> is enabled for a database
free pages may be reclaimed after deleting data, causing the file to shrink,
without rebuilding the entire database using VACUUM.  However, using
<a href="pragma.html#pragma_auto_vacuum">auto_vacuum</a> can lead to extra database file fragmentation.  And <a href="pragma.html#pragma_auto_vacuum">auto_vacuum</a>
does not compact partially filled pages of the database as VACUUM does.

</p>










|

















>
>
>
>
>
>
>
>
>
>
>
|
|
|




>





|






|






|







|







|





|







|






|









|






|



|

|

|


|














|









|



|











|









<
<
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247


}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<div class=fancy>
<div class=nosearch>
<div class="fancy_title">
VACUUM
</div>
</div>




<h1 id="syntax"><span>1. </span>Syntax</h1>
<p><b><a href="syntax/vacuum-stmt.html">vacuum-stmt:</a></b>
<button id='x2159' onclick='hideorshow("x2159","x2160")'>hide</button></p>
 <div id='x2160' class='imgcontainer'>
 <img alt="syntax diagram vacuum-stmt" src="images/syntax/vacuum-stmt.gif" />
</div>


<h1 id="description"><span>2. </span>Description</h1>
<p>
  The VACUUM command rebuilds the database file, repacking it into a minimal
  amount of disk space. There are several 
  reasons an application might do this:

</p><ul>
  <li> <p> Unless SQLite is running in "auto_vacuum=FULL" mode, when a large
     amount of data is deleted from the database file it leaves behind empty
     space, or "free" database pages. This means the database file might
     be larger than strictly necessary. Running VACUUM to rebuild the 
     database reclaims this space and reduces the size of the database file.

  </p></li><li> <p> Frequent inserts, updates, and deletes can cause the database file
     to become fragmented - where data for a single table or index is scattered 
     around the database file. Running VACUUM ensures that each table and
     index is largely stored contiguously within the database file. In some
     cases, VACUUM may also reduce the number of partially filled pages in
     the database, reducing the size of the database file further.

  </p></li><li> <p> When content is deleted from an SQLite database, the content is not
     usually erased but rather the space used to hold the content is marked as
     being available for reuse.  This can allow deleted content to be recovered
     by a hacker or by forensic analysis.  Running VACUUM will clean the database
     of all traces of deleted content, thus preventing an adversary from recovering
     deleted content.  Using VACUUM in this way is an alternative to setting
     <a href="pragma.html#pragma_secure_delete">PRAGMA secure_delete=ON</a>. 

  </p></li><li> <p> Normally, the database <a href="pragma.html#pragma_page_size">page_size</a> and whether or not the database
     supports <a href="pragma.html#pragma_auto_vacuum">auto_vacuum</a> must be configured before the database file is
     actually created. However, when not in <a href="wal.html">write-ahead log</a> mode, the 
     <a href="pragma.html#pragma_page_size">page_size</a> and/or <a href="pragma.html#pragma_auto_vacuum">auto_vacuum</a> properties of an existing database may be
     changed by using the <a href="pragma.html#pragma_page_size">page_size</a>  and/or 
     <a href="pragma.html#pragma_auto_vacuum">pragma auto_vacuum</a> pragmas and then immediately VACUUMing
     the database. When in <a href="wal.html">write-ahead log</a> mode, only the <a href="pragma.html#pragma_auto_vacuum">auto_vacuum</a>
     support property can be changed using VACUUM.
</p></li></ul>

<p>By default, VACUUM only works only on the main database.
<a href="lang_attach.html">Attached databases</a> can be vacuumed by appending the appropriate
<span class='yyterm'>schema-name</span> to the VACUUM statement.

</p><p><b>Compatibility Warning:</b> The ability to vacuum attached databases was
added in <a href="releaselog/3_15_0.html">version 3.15.0</a> (2016-10-14).  Prior to that, a 
<span class='yyterm'>schema-name</span> added to the
VACUUM statement would be silently ignored and the "main" schema would be
vacuumed.</p>

<a name="vacuuminto"></a>

<h2 id="vacuum_with_an_into_clause"><span>2.1. </span>VACUUM with an INTO clause</h2>

<p>If the INTO clause is included, then the original database file is
unchanged and a new database is created in the filename given by the
argument to the INTO clause.  The new database will contain the same
logical content as the original database, fully vacuumed.

</p><p>
The VACUUM command with an INTO clause is an alternative to the
<a href="backup.html">backup API</a> for generating backup copies of a live database.
The advantage of using VACUUM INTO is that the resulting backup
database is minimal in size and hence the amount of filesystem
I/O may be reduced.  Also, all deleted content is purged from the
backup, leaving behind no forensic traces.  On the other hand,
the <a href="backup.html">backup API</a> uses fewer CPU cycles and can be executed
incrementally.

</p><p>
The filename in the INTO clause can be an arbitrary SQL expression
that evaluates to a string.
The file named by the INTO clause must not previously exist, or
else it must be an empty file, or the VACUUM INTO command will
fail with an error.

</p><p>
The argument to INTO can be a <a href="uri.html">URI filename</a> if URI filenames
are enabled.
URL filenames are enabled if any of the following are true:
</p><ul>
<li> The SQLite library was compiled with <a href="compile.html#use_uri">-DSQLITE_USE_URI=1</a>.
</li><li> The <a href="c3ref/config.html">sqlite3_config</a>(<a href="c3ref/c_config_covering_index_scan.html#sqliteconfiguri">SQLITE_CONFIG_URI</a>,1) interfaces was
     invoked at start-time.
</li><li> The <a href="c3ref/sqlite3.html">database connection</a> that is running the VACUUM INTO
     statement was originally opened using the
     <a href="c3ref/c_open_autoproxy.html">SQLITE_OPEN_URI</a> flag.
</li></ul>

<p>
The VACUUM INTO command is transactional in the sense that
the generated output database is a consistent snapshot of the
original database.  However, if the VACUUM INTO command is
interrupted by an unplanned shutdown or power lose, then
the generated output database might be incomplete and corrupt.
Also, SQLite does not invoke fsync() or FlushFileBuffers()
on the generated database to ensure that it has reached
non-volatile storage before completing.


<a name="howvacuumworks"></a>

</p><h1 id="how_vacuum_works"><span>3. </span>How VACUUM works</h1>

<p>The VACUUM command works by copying the contents of the database into
a temporary database file and then overwriting the original with the 
contents of the temporary file. When overwriting the original, a rollback
journal or <a href="wal.html">write-ahead log</a> WAL file is used just as it would be for any
other database transaction. This means that when VACUUMing a database, 
as much as twice the size of the original database file is required in free
disk space.

</p><p>The VACUUM INTO command works the same way except that it uses the file
named on the INTO clause in place of the temporary database and omits the
step of copying the vacuumed database back over top of the original database.

</p><p>The VACUUM command may change the <a href="lang_createtable.html#rowid">ROWIDs</a> of entries in any
tables that do not have an explicit <a href="lang_createtable.html#rowid">INTEGER PRIMARY KEY</a>.
</p>

<p>A VACUUM will fail if there is an open transaction on the database
connection that is attempting to run the VACUUM.  Unfinalized SQL
statements typically hold a read transaction open, so the VACUUM
might fail if there are unfinalized SQL statements on the same connection.
VACUUM (but not VACUUM INTO) is a write operation and so if another
database connection is holding a lock that prevents writes, then
the VACUUM will fail.

</p><p>An alternative to using the VACUUM command to
reclaim space after data has been deleted is auto-vacuum mode, enabled using
the <a href="pragma.html#pragma_auto_vacuum">auto_vacuum</a> pragma. When <a href="pragma.html#pragma_auto_vacuum">auto_vacuum</a> is enabled for a database
free pages may be reclaimed after deleting data, causing the file to shrink,
without rebuilding the entire database using VACUUM.  However, using
<a href="pragma.html#pragma_auto_vacuum">auto_vacuum</a> can lead to extra database file fragmentation.  And <a href="pragma.html#pragma_auto_vacuum">auto_vacuum</a>
does not compact partially filled pages of the database as VACUUM does.

</p>



Changes to Doc/Extra/Core/lang_with.html.
1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>SQLite Query Language: WITH clause</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>





|







1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>The WITH Clause</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93









































94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>









































<div class=nosearch><h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>WITH clause</h2></div><p><b><a href="syntax/with-clause.html">with-clause:</a></b>
<button id='x1817' onclick='hideorshow("x1817","x1818")'>hide</button></p>
 <div id='x1818' class='imgcontainer'>
 <img alt="syntax diagram with-clause" src="images/syntax/with-clause.gif" />
<p><b><a href="syntax/cte-table-name.html">cte-table-name:</a></b>
<button id='x1819' onclick='hideorshow("x1819","x1820")'>show</button></p>
 <div id='x1820' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram cte-table-name" src="images/syntax/cte-table-name.gif" />
</div>
<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
<button id='x1821' onclick='hideorshow("x1821","x1822")'>show</button></p>
 <div id='x1822' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntax/common-table-expression.html">common-table-expression:</a></b>
<button id='x1823' onclick='hideorshow("x1823","x1824")'>show</button></p>
 <div id='x1824' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
</div>
<p><b><a href="syntax/compound-operator.html">compound-operator:</a></b>
<button id='x1825' onclick='hideorshow("x1825","x1826")'>show</button></p>
 <div id='x1826' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</div>
<p><b><a href="syntax/expr.html">expr:</a></b>
<button id='x1827' onclick='hideorshow("x1827","x1828")'>show</button></p>
 <div id='x1828' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntax/filter-clause.html">filter-clause:</a></b>
<button id='x1829' onclick='hideorshow("x1829","x1830")'>show</button></p>
 <div id='x1830' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram filter-clause" src="images/syntax/filter-clause.gif" />
</div>
<p><b><a href="syntax/literal-value.html">literal-value:</a></b>
<button id='x1831' onclick='hideorshow("x1831","x1832")'>show</button></p>
 <div id='x1832' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</div>
<p><b><a href="syntax/over-clause.html">over-clause:</a></b>
<button id='x1833' onclick='hideorshow("x1833","x1834")'>show</button></p>
 <div id='x1834' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram over-clause" src="images/syntax/over-clause.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x1835' onclick='hideorshow("x1835","x1836")'>show</button></p>
 <div id='x1836' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
</div>
<p><b><a href="syntax/raise-function.html">raise-function:</a></b>
<button id='x1837' onclick='hideorshow("x1837","x1838")'>show</button></p>
 <div id='x1838' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</div>
<p><b><a href="syntax/type-name.html">type-name:</a></b>
<button id='x1839' onclick='hideorshow("x1839","x1840")'>show</button></p>
 <div id='x1840' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
<button id='x1841' onclick='hideorshow("x1841","x1842")'>show</button></p>
 <div id='x1842' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</div>
</div>
</div>
<p><b><a href="syntax/join-clause.html">join-clause:</a></b>
<button id='x1843' onclick='hideorshow("x1843","x1844")'>show</button></p>
 <div id='x1844' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
<button id='x1845' onclick='hideorshow("x1845","x1846")'>show</button></p>
 <div id='x1846' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</div>
<p><b><a href="syntax/join-operator.html">join-operator:</a></b>
<button id='x1847' onclick='hideorshow("x1847","x1848")'>show</button></p>
 <div id='x1848' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</div>
</div>
<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
<button id='x1849' onclick='hideorshow("x1849","x1850")'>show</button></p>
 <div id='x1850' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</div>
<p><b><a href="syntax/result-column.html">result-column:</a></b>
<button id='x1851' onclick='hideorshow("x1851","x1852")'>show</button></p>
 <div id='x1852' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</div>
<p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
<button id='x1853' onclick='hideorshow("x1853","x1854")'>show</button></p>
 <div id='x1854' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</div>
<p><b><a href="syntax/window-defn.html">window-defn:</a></b>
<button id='x1855' onclick='hideorshow("x1855","x1856")'>show</button></p>
 <div id='x1856' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram window-defn" src="images/syntax/window-defn.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x1857' onclick='hideorshow("x1857","x1858")'>show</button></p>
 <div id='x1858' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
</div>
</div>
</div>


<p>Common Table Expressions or CTEs act like temporary <a href="lang_createview.html">views</a> that exist
only for the duration of a single SQL statement.  There are two kinds of
common table expressions: "ordinary" and "recursive". Ordinary 
common table expressions are helpful for making
queries easier to understand by factoring
subqueries out of the main SQL statement.
Recursive common table expressions
provide the ability to do hierarchical or
recursive queries of trees and graphs, a capability
that is not otherwise available in the SQL language.

<p>All common table expressions (ordinary and recursive) are 
created by prepending a WITH clause in front of a <a href="lang_select.html">SELECT</a>, <a href="lang_insert.html">INSERT</a>, <a href="lang_delete.html">DELETE</a>,
or <a href="lang_update.html">UPDATE</a> statement.  A single WITH clause can specify one or more
common table expressions, some of which are ordinary and some of which
are recursive.

<a name="ordinarycte"></a>

<h3>Ordinary Common Table Expressions</h3>

<p>An ordinary common table expression works as if it were a <a href="lang_createview.html">view</a> that
exists for the duration of a single statement.  Ordinary common table
expressions are useful for factoring out subqueries and making the overall
SQL statement easier to read and understand.

<p>A WITH clause can contain ordinary common table expressions even if
it includes the RECURSIVE keyword.  The use of RECURSIVE does not force
common table expressions to be recursive.

<a name="recursivecte"></a>

<h3>Recursive Common Table Expressions</h3>

<p>A recursive common table expression can be used to write a query that
walks a tree or graph.  A recursive common table expression has the same
basic syntax as an ordinary common table expression, but with the following
additional features:

<ol>
<li> The "<a href="syntax/select-stmt.html">select-stmt</a>"
     must be a <a href="lang_select.html#compound">compound select</a> where the right-most <a href="syntax/compound-operator.html">compound-operator</a> is
     either UNION or UNION ALL.
<li> The table named on the left-hand side of the AS keyword must appear
     exactly once in the FROM clause of the right-most SELECT statement
     of the compound select, and nowhere else.
<li> The right-most SELECT of the compound select must not make use of
     <a href="lang_aggfunc.html">aggregate</a> or <a href="windowfunctions.html">window functions</a>.
</ol>

<p>To put it another way, a recursive common table expression must
look like the following:

<p><b><a href="syntax/recursive-cte.html">recursive-cte:</a></b>
<button id='x1859' onclick='hideorshow("x1859","x1860")'>hide</button></p>
 <div id='x1860' class='imgcontainer'>
 <img alt="syntax diagram recursive-cte" src="images/syntax/recursive-cte.gif" />
<p><b><a href="syntax/cte-table-name.html">cte-table-name:</a></b>
<button id='x1861' onclick='hideorshow("x1861","x1862")'>show</button></p>
 <div id='x1862' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram cte-table-name" src="images/syntax/cte-table-name.gif" />
</div>
</div>


<p>Call the table named by the <a href="syntax/cte-table-name.html">cte-table-name</a> in a recursive
common table expression the "recursive table".
In the <a href="syntax/recursive-cte.html">recursive-cte</a> bubble diagram above, the recursive
table must appear exactly once in the FROM clause of the 
<span class='yyterm'>recursive-select</span>
and must not appear anywhere else in either the
<span class='yyterm'>initial-select</span> or the
<span class='yyterm'>recursive-select</span>, including subqueries.
The <span class='yyterm'>initial-select</span> may be
a <a href="lang_select.html#compound">compound select</a>, but it may not include an ORDER BY, LIMIT, or OFFSET.
The recursive-select must be a simple select, not a compound.  The
recursive-select is allowed to include an ORDER BY, LIMIT, and/or OFFSET.

<p>The basic algorithm for computing the content of the recursive table
is as follows:

<ol>
<li> Run the <span class='yyterm'>initial-select</span> and add the results to a queue.
<li> While the queue is not empty:
<ol type="a">
<li> Extract a single row from the queue.
<li> Insert that single row into the recursive table
<li> Pretend that the single row just extracted is the only
     row in the recursive table and run the recursive-select,
     adding all results to the queue.
</ol>
</ol>

<p>The basic procedure above may modified by the following additional rules:

<ul>
<li><p>
  If a UNION operator connects the <span class='yyterm'>initial-select</span> with the
  <span class='yyterm'>recursive-select</span>, then only add rows to the queue if 
  no identical row has
  been previously added to the queue.  Repeated rows are discarded before being
  added to the queue even if the repeated rows have already been extracted
  from the queue by the recursion step.  If the operator is UNION ALL,
  then all rows generated by both the <span class='yyterm'>initial-select</span> and the
  <span class='yyterm'>recursive-select</span> are always added to the queue even if
  they are repeats.
  When determining if a row is repeated, NULL values compare
  equal to one another and not equal to any other value.
<li><p>
  The LIMIT clause, if present, determines the maximum number of rows that
  will ever be added to the recursive table in step 2b.
  Once the limit is reached, the recursion stops.
  A limit of zero means that no rows are ever added to the
  recursive table, and a negative limit means an unlimited number of rows
  may be added to the recursive table.
<li><p>
  The OFFSET clause, if it is present and has a positive value N, prevents the
  first N rows from being added to the recursive table.
  The first N rows are still processed
  by the <span class='yyterm'>recursive-select</span> &mdash; they
  just are not added to the recursive table.  Rows are not counted toward
  fulfilling the LIMIT until all OFFSET rows have been skipped.
<li><p>
  If an ORDER BY clause is present, it determines the order in which rows
  are extracted from the queue in step 2a.  If there is no ORDER BY clause,
  then the order in which rows are extracted is undefined.  (In the current
  implementation, the queue becomes a FIFO if the ORDER BY clause is omitted,
  but applications should not depend on that fact since it might change.)
</ul>

<a name="rcex1"></a>

<h4>Recursive Query Examples</h4>

<p>The following query returns all integers between 1 and 1000000:

<blockquote><pre>
WITH RECURSIVE
  cnt(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM cnt WHERE x<1000000)
SELECT x FROM cnt;
</pre></blockquote>

<p>Consider how this query works.  The initial-select
runs first and returns a single row
with a single column "1".  This one row is added to the queue.  In
step 2a, that one row is extracted from the queue and added to "cnt".
Then the recursive-select is run in accordance with step 2c generating
a single new row with value "2" to add to the queue.  The queue still
has one row, so step 2 repeats.  The "2" row is extracted and added to the
recursive table by steps 2a and 2b.  Then the row containing 2 is used 
as if it were the complete content of the recursive table and the 
recursive-select is run again, resulting in a row with value "3" being added
to the queue.  This repeats 999999 times until finally at step 2a the
only value on the queue is a row containing 1000000.  That row is
extracted and added to the recursive table.  But this time, the
WHERE clause causes the recursive-select to return no rows, so the
queue remains empty and the recursion stops.

<p><b>Optimization note:</b>
In the discussion above, statements like "insert the row into
the recursive table" should be understood conceptually, not literally.
It sounds as if SQLite is accumulating a huge table
containing one million rows, then going back and scanning that table
from top to bottom to generate the result.  What really happens
is that the query optimizer sees that values in the
"cnt" recursive table are only used once.  So as each row is added to
the recursive table, that row is immediately returned as a result of the main
SELECT statement and then discarded.  SQLite does <em>not</em> accumulate
a temporary table containing a million rows.  Very little memory is
needed to run the above example.  However, if the example had used
UNION instead of UNION ALL, then SQLite would have had to keep around
all previously generated content in order to check for duplicates.
For this reason, programmers should strive to use UNION ALL instead
of UNION when feasible.

<p>Here is a variation on the previous example:

<blockquote><pre>
WITH RECURSIVE
  cnt(x) AS (
     SELECT 1
     UNION ALL
     SELECT x+1 FROM cnt
      LIMIT 1000000
  )







|

















>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
|


|
|



|
|


|
|



|
|



|
|


|
|



|
|



|
|


|
|




|
|



|
|


|
|





|
|


|
|



|
|




|
|



|
|



|
|



|
|


|
|


















|







|






|





|






|



|


|

|





|
|


|
|





|












|


|

|


|
|


|
|



|












|






|






|





|



|



|

|
<
<

















|
















|

|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380


381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<div class=fancy>
<div class=nosearch>
<div class="fancy_title">
The WITH Clause
</div>
<div class="fancy_toc">
<a onclick="toggle_toc()">
<span class="fancy_toc_mark" id="toc_mk">&#x25ba;</span>
Table Of Contents
</a>
<div id="toc_sub"><div class="fancy-toc1"><a href="#overview">1. Overview</a></div>
<div class="fancy-toc1"><a href="#ordinary_common_table_expressions">2. Ordinary Common Table Expressions</a></div>
<div class="fancy-toc1"><a href="#recursive_common_table_expressions">3. Recursive Common Table Expressions</a></div>
<div class="fancy-toc2"><a href="#recursive_query_examples">3.1. Recursive Query Examples</a></div>
<div class="fancy-toc2"><a href="#hierarchical_query_examples">3.2. Hierarchical Query Examples</a></div>
<div class="fancy-toc2"><a href="#queries_against_a_graph">3.3. Queries Against A Graph</a></div>
<div class="fancy-toc2"><a href="#controlling_depth_first_versus_breadth_first_search_of_a_tree_using_order_by">3.4. Controlling Depth-First Versus Breadth-First Search Of a Tree
Using ORDER BY</a></div>
<div class="fancy-toc2"><a href="#outlandish_recursive_query_examples">3.5. Outlandish Recursive Query Examples</a></div>
<div class="fancy-toc1"><a href="#limitations_and_caveats">4. Limitations And Caveats</a></div>
</div>
</div>
<script>
function toggle_toc(){
var sub = document.getElementById("toc_sub")
var mk = document.getElementById("toc_mk")
if( sub.style.display!="block" ){
sub.style.display = "block";
mk.innerHTML = "&#x25bc;";
} else {
sub.style.display = "none";
mk.innerHTML = "&#x25ba;";
}
}
</script>
</div>




<h1 id="overview"><span>1. </span>Overview</h1>
<p><b><a href="syntax/with-clause.html">with-clause:</a></b>
<button id='x2161' onclick='hideorshow("x2161","x2162")'>hide</button></p>
 <div id='x2162' class='imgcontainer'>
 <img alt="syntax diagram with-clause" src="images/syntax/with-clause.gif" />
<p><b><a href="syntax/cte-table-name.html">cte-table-name:</a></b>
<button id='x2163' onclick='hideorshow("x2163","x2164")'>show</button></p>
 <div id='x2164' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram cte-table-name" src="images/syntax/cte-table-name.gif" />
</div>
<p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
<button id='x2165' onclick='hideorshow("x2165","x2166")'>show</button></p>
 <div id='x2166' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntax/common-table-expression.html">common-table-expression:</a></b>
<button id='x2167' onclick='hideorshow("x2167","x2168")'>show</button></p>
 <div id='x2168' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
</div>
<p><b><a href="syntax/compound-operator.html">compound-operator:</a></b>
<button id='x2169' onclick='hideorshow("x2169","x2170")'>show</button></p>
 <div id='x2170' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</div>
<p><b><a href="syntax/expr.html">expr:</a></b>
<button id='x2171' onclick='hideorshow("x2171","x2172")'>show</button></p>
 <div id='x2172' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntax/filter-clause.html">filter-clause:</a></b>
<button id='x2173' onclick='hideorshow("x2173","x2174")'>show</button></p>
 <div id='x2174' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram filter-clause" src="images/syntax/filter-clause.gif" />
</div>
<p><b><a href="syntax/literal-value.html">literal-value:</a></b>
<button id='x2175' onclick='hideorshow("x2175","x2176")'>show</button></p>
 <div id='x2176' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</div>
<p><b><a href="syntax/over-clause.html">over-clause:</a></b>
<button id='x2177' onclick='hideorshow("x2177","x2178")'>show</button></p>
 <div id='x2178' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram over-clause" src="images/syntax/over-clause.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x2179' onclick='hideorshow("x2179","x2180")'>show</button></p>
 <div id='x2180' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
</div>
<p><b><a href="syntax/raise-function.html">raise-function:</a></b>
<button id='x2181' onclick='hideorshow("x2181","x2182")'>show</button></p>
 <div id='x2182' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</div>
<p><b><a href="syntax/type-name.html">type-name:</a></b>
<button id='x2183' onclick='hideorshow("x2183","x2184")'>show</button></p>
 <div id='x2184' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntax/signed-number.html">signed-number:</a></b>
<button id='x2185' onclick='hideorshow("x2185","x2186")'>show</button></p>
 <div id='x2186' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</div>
</div>
</div>
<p><b><a href="syntax/join-clause.html">join-clause:</a></b>
<button id='x2187' onclick='hideorshow("x2187","x2188")'>show</button></p>
 <div id='x2188' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
<button id='x2189' onclick='hideorshow("x2189","x2190")'>show</button></p>
 <div id='x2190' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</div>
<p><b><a href="syntax/join-operator.html">join-operator:</a></b>
<button id='x2191' onclick='hideorshow("x2191","x2192")'>show</button></p>
 <div id='x2192' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</div>
</div>
<p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
<button id='x2193' onclick='hideorshow("x2193","x2194")'>show</button></p>
 <div id='x2194' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</div>
<p><b><a href="syntax/result-column.html">result-column:</a></b>
<button id='x2195' onclick='hideorshow("x2195","x2196")'>show</button></p>
 <div id='x2196' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</div>
<p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
<button id='x2197' onclick='hideorshow("x2197","x2198")'>show</button></p>
 <div id='x2198' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</div>
<p><b><a href="syntax/window-defn.html">window-defn:</a></b>
<button id='x2199' onclick='hideorshow("x2199","x2200")'>show</button></p>
 <div id='x2200' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram window-defn" src="images/syntax/window-defn.gif" />
<p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
<button id='x2201' onclick='hideorshow("x2201","x2202")'>show</button></p>
 <div id='x2202' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
</div>
</div>
</div>
</div>


<p>Common Table Expressions or CTEs act like temporary <a href="lang_createview.html">views</a> that exist
only for the duration of a single SQL statement.  There are two kinds of
common table expressions: "ordinary" and "recursive". Ordinary 
common table expressions are helpful for making
queries easier to understand by factoring
subqueries out of the main SQL statement.
Recursive common table expressions
provide the ability to do hierarchical or
recursive queries of trees and graphs, a capability
that is not otherwise available in the SQL language.

</p><p>All common table expressions (ordinary and recursive) are 
created by prepending a WITH clause in front of a <a href="lang_select.html">SELECT</a>, <a href="lang_insert.html">INSERT</a>, <a href="lang_delete.html">DELETE</a>,
or <a href="lang_update.html">UPDATE</a> statement.  A single WITH clause can specify one or more
common table expressions, some of which are ordinary and some of which
are recursive.

<a name="ordinarycte"></a>

</p><h1 id="ordinary_common_table_expressions"><span>2. </span>Ordinary Common Table Expressions</h1>

<p>An ordinary common table expression works as if it were a <a href="lang_createview.html">view</a> that
exists for the duration of a single statement.  Ordinary common table
expressions are useful for factoring out subqueries and making the overall
SQL statement easier to read and understand.

</p><p>A WITH clause can contain ordinary common table expressions even if
it includes the RECURSIVE keyword.  The use of RECURSIVE does not force
common table expressions to be recursive.

<a name="recursivecte"></a>

</p><h1 id="recursive_common_table_expressions"><span>3. </span>Recursive Common Table Expressions</h1>

<p>A recursive common table expression can be used to write a query that
walks a tree or graph.  A recursive common table expression has the same
basic syntax as an ordinary common table expression, but with the following
additional features:

</p><ol>
<li> The "<a href="syntax/select-stmt.html">select-stmt</a>"
     must be a <a href="lang_select.html#compound">compound select</a> where the right-most <a href="syntax/compound-operator.html">compound-operator</a> is
     either UNION or UNION ALL.
</li><li> The table named on the left-hand side of the AS keyword must appear
     exactly once in the FROM clause of the right-most SELECT statement
     of the compound select, and nowhere else.
</li><li> The right-most SELECT of the compound select must not make use of
     <a href="lang_aggfunc.html">aggregate</a> or <a href="windowfunctions.html">window functions</a>.
</li></ol>

<p>To put it another way, a recursive common table expression must
look like the following:

<p><b><a href="syntax/recursive-cte.html">recursive-cte:</a></b>
<button id='x2203' onclick='hideorshow("x2203","x2204")'>hide</button></p>
 <div id='x2204' class='imgcontainer'>
 <img alt="syntax diagram recursive-cte" src="images/syntax/recursive-cte.gif" />
<p><b><a href="syntax/cte-table-name.html">cte-table-name:</a></b>
<button id='x2205' onclick='hideorshow("x2205","x2206")'>show</button></p>
 <div id='x2206' style='display:none;' class='imgcontainer'>
 <img alt="syntax diagram cte-table-name" src="images/syntax/cte-table-name.gif" />
</div>
</div>


</p><p>Call the table named by the <a href="syntax/cte-table-name.html">cte-table-name</a> in a recursive
common table expression the "recursive table".
In the <a href="syntax/recursive-cte.html">recursive-cte</a> bubble diagram above, the recursive
table must appear exactly once in the FROM clause of the 
<span class='yyterm'>recursive-select</span>
and must not appear anywhere else in either the
<span class='yyterm'>initial-select</span> or the
<span class='yyterm'>recursive-select</span>, including subqueries.
The <span class='yyterm'>initial-select</span> may be
a <a href="lang_select.html#compound">compound select</a>, but it may not include an ORDER BY, LIMIT, or OFFSET.
The recursive-select must be a simple select, not a compound.  The
recursive-select is allowed to include an ORDER BY, LIMIT, and/or OFFSET.

</p><p>The basic algorithm for computing the content of the recursive table
is as follows:

</p><ol>
<li> Run the <span class='yyterm'>initial-select</span> and add the results to a queue.
</li><li> While the queue is not empty:
<ol type="a">
<li> Extract a single row from the queue.
</li><li> Insert that single row into the recursive table
</li><li> Pretend that the single row just extracted is the only
     row in the recursive table and run the recursive-select,
     adding all results to the queue.
</li></ol>
</li></ol>

<p>The basic procedure above may modified by the following additional rules:

</p><ul>
<li><p>
  If a UNION operator connects the <span class='yyterm'>initial-select</span> with the
  <span class='yyterm'>recursive-select</span>, then only add rows to the queue if 
  no identical row has
  been previously added to the queue.  Repeated rows are discarded before being
  added to the queue even if the repeated rows have already been extracted
  from the queue by the recursion step.  If the operator is UNION ALL,
  then all rows generated by both the <span class='yyterm'>initial-select</span> and the
  <span class='yyterm'>recursive-select</span> are always added to the queue even if
  they are repeats.
  When determining if a row is repeated, NULL values compare
  equal to one another and not equal to any other value.
</p></li><li><p>
  The LIMIT clause, if present, determines the maximum number of rows that
  will ever be added to the recursive table in step 2b.
  Once the limit is reached, the recursion stops.
  A limit of zero means that no rows are ever added to the
  recursive table, and a negative limit means an unlimited number of rows
  may be added to the recursive table.
</p></li><li><p>
  The OFFSET clause, if it is present and has a positive value N, prevents the
  first N rows from being added to the recursive table.
  The first N rows are still processed
  by the <span class='yyterm'>recursive-select</span> &mdash; they
  just are not added to the recursive table.  Rows are not counted toward
  fulfilling the LIMIT until all OFFSET rows have been skipped.
</p></li><li><p>
  If an ORDER BY clause is present, it determines the order in which rows
  are extracted from the queue in step 2a.  If there is no ORDER BY clause,
  then the order in which rows are extracted is undefined.  (In the current
  implementation, the queue becomes a FIFO if the ORDER BY clause is omitted,
  but applications should not depend on that fact since it might change.)
</p></li></ul>

<a name="rcex1"></a>

<h2 id="recursive_query_examples"><span>3.1. </span>Recursive Query Examples</h2>

<p>The following query returns all integers between 1 and 1000000:

</p><blockquote><pre>
WITH RECURSIVE
  cnt(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM cnt WHERE x<1000000) SELECT="1" x="1" FROM="1" cnt;="1" </pre="1"></1000000)></pre></blockquote>



<p>Consider how this query works.  The initial-select
runs first and returns a single row
with a single column "1".  This one row is added to the queue.  In
step 2a, that one row is extracted from the queue and added to "cnt".
Then the recursive-select is run in accordance with step 2c generating
a single new row with value "2" to add to the queue.  The queue still
has one row, so step 2 repeats.  The "2" row is extracted and added to the
recursive table by steps 2a and 2b.  Then the row containing 2 is used 
as if it were the complete content of the recursive table and the 
recursive-select is run again, resulting in a row with value "3" being added
to the queue.  This repeats 999999 times until finally at step 2a the
only value on the queue is a row containing 1000000.  That row is
extracted and added to the recursive table.  But this time, the
WHERE clause causes the recursive-select to return no rows, so the
queue remains empty and the recursion stops.

</p><p><b>Optimization note:</b>
In the discussion above, statements like "insert the row into
the recursive table" should be understood conceptually, not literally.
It sounds as if SQLite is accumulating a huge table
containing one million rows, then going back and scanning that table
from top to bottom to generate the result.  What really happens
is that the query optimizer sees that values in the
"cnt" recursive table are only used once.  So as each row is added to
the recursive table, that row is immediately returned as a result of the main
SELECT statement and then discarded.  SQLite does <em>not</em> accumulate
a temporary table containing a million rows.  Very little memory is
needed to run the above example.  However, if the example had used
UNION instead of UNION ALL, then SQLite would have had to keep around
all previously generated content in order to check for duplicates.
For this reason, programmers should strive to use UNION ALL instead
of UNION when feasible.

</p><p>Here is a variation on the previous example:

</p><blockquote><pre>
WITH RECURSIVE
  cnt(x) AS (
     SELECT 1
     UNION ALL
     SELECT x+1 FROM cnt
      LIMIT 1000000
  )
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
queue to drain and the recursion to terminate.  But the LIMIT clause will
always stop the recursion.  So it is good practice to always include a
LIMIT clause as a safety if an upper bound on the size of the recursion 
is known.

<a name="rcex2"></a>

<h4>Hierarchical Query Examples</h4>

<p>Consider a table that describes the members of an organization as
well as the chain-of-command within that organization:

<blockquote><pre>
CREATE TABLE org(
  name TEXT PRIMARY KEY,
  boss TEXT REFERENCES org,
  height INT,
  -- other content omitted
);
</pre></blockquote>

<p>Every member in the organization has a name, and most members have
a single boss.  (The head of the whole organization has a NULL
"boss" field.) The rows of the "org" table form a tree.

<p>Here is a query that computes the average height over everyone
in Alice's organization, including Alice:

<blockquote><pre>
WITH RECURSIVE
  works_for_alice(n) AS (
    VALUES('Alice')
    UNION
    SELECT name FROM org, works_for_alice
     WHERE org.boss=works_for_alice.n
  )
SELECT avg(height) FROM org
 WHERE org.name IN works_for_alice;
</pre></blockquote>

<p>The next example uses two 
common table expressions in a single WITH clause.  
The following table records a family tree:

<blockquote><pre>
CREATE TABLE family(
  name TEXT PRIMARY KEY,
  mom TEXT REFERENCES family,
  dad TEXT REFERENCES family,
  born DATETIME,
  died DATETIME, -- NULL if still alive
  -- other content
);
</pre></blockquote>

<p>The "family" table is similar to the earlier "org" table except that 
now there are two parents to each member.
We want to know all living ancestors of Alice, from oldest to youngest.
An ordinary common table expression, "parent_of", is defined first.  That
ordinary CTE is a view that can be used to find all parents of any
individual.  That ordinary CTE is then used in the "ancestor_of_alice"
recursive CTE.  The recursive CTE is then used in the final query:

<blockquote><pre>
WITH RECURSIVE
  parent_of(name, parent) AS
    (SELECT name, mom FROM family UNION SELECT name, dad FROM family),
  ancestor_of_alice(name) AS
    (SELECT parent FROM parent_of WHERE name='Alice'
     UNION ALL
     SELECT parent FROM parent_of JOIN ancestor_of_alice USING(name))
SELECT family.name FROM ancestor_of_alice, family
 WHERE ancestor_of_alice.name=family.name
   AND died IS NULL
 ORDER BY born;
</pre></blockquote>

<a name="rcex3"></a>

<h4>Queries Against A Graph</h4>

<p>A version control system (VCS) will typically store the evolving
versions of a project as a directed acyclic graph (DAG).  Call each
version of the project a "checkin".  A single
checkin can have zero or more parents.  Most checkins (except the
first) have a single parent, but in the case of a merge, a checkin
might have two or three or more parents.  A schema to keep track of
checkins and the order in which they occur might look something like
this:

<blockquote><pre>
CREATE TABLE checkin(
  id INTEGER PRIMARY KEY,
  mtime INTEGER -- timestamp when this checkin occurred
);
CREATE TABLE derivedfrom(
  xfrom INTEGER NOT NULL REFERENCES checkin, -- parent checkin
  xto INTEGER NOT NULL REFERENCES checkin,   -- derived checkin
  PRIMARY KEY(xfrom,xto)
);
CREATE INDEX derivedfrom_back ON derivedfrom(xto,xfrom);
</pre></blockquote>

<p>This graph is acyclic.  And we assume that the mtime of every
child checkin is no less than the mtime of all its parents.  But
unlike the earlier examples, this graph might have multiple paths of
differing lengths between any two checkins.

<p>We want to know the twenty most recent ancestors in time (out of
the thousands and thousands of ancestors in the whole DAG) for
checkin "@BASELINE".  (A query similar to this is used
by the <a href="http://www.fossil-scm.org/">Fossil</a> VCS to
show the N most recent ancestors of a check.  For example:
<a href="http://www.sqlite.org/src/timeline?p=trunk&n=30">http://www.sqlite.org/src/timeline?p=trunk&n=30</a>.)

<blockquote><pre>
WITH RECURSIVE
  ancestor(id,mtime) AS (
    SELECT id, mtime FROM checkin WHERE id=@BASELINE
    UNION
    SELECT derivedfrom.xfrom, checkin.mtime
      FROM ancestor, derivedfrom, checkin
     WHERE ancestor.id=derivedfrom.xto







|




|












|


|















|


















|















|










|

















|






|







437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
queue to drain and the recursion to terminate.  But the LIMIT clause will
always stop the recursion.  So it is good practice to always include a
LIMIT clause as a safety if an upper bound on the size of the recursion 
is known.

<a name="rcex2"></a>

</p><h2 id="hierarchical_query_examples"><span>3.2. </span>Hierarchical Query Examples</h2>

<p>Consider a table that describes the members of an organization as
well as the chain-of-command within that organization:

</p><blockquote><pre>
CREATE TABLE org(
  name TEXT PRIMARY KEY,
  boss TEXT REFERENCES org,
  height INT,
  -- other content omitted
);
</pre></blockquote>

<p>Every member in the organization has a name, and most members have
a single boss.  (The head of the whole organization has a NULL
"boss" field.) The rows of the "org" table form a tree.

</p><p>Here is a query that computes the average height over everyone
in Alice's organization, including Alice:

</p><blockquote><pre>
WITH RECURSIVE
  works_for_alice(n) AS (
    VALUES('Alice')
    UNION
    SELECT name FROM org, works_for_alice
     WHERE org.boss=works_for_alice.n
  )
SELECT avg(height) FROM org
 WHERE org.name IN works_for_alice;
</pre></blockquote>

<p>The next example uses two 
common table expressions in a single WITH clause.  
The following table records a family tree:

</p><blockquote><pre>
CREATE TABLE family(
  name TEXT PRIMARY KEY,
  mom TEXT REFERENCES family,
  dad TEXT REFERENCES family,
  born DATETIME,
  died DATETIME, -- NULL if still alive
  -- other content
);
</pre></blockquote>

<p>The "family" table is similar to the earlier "org" table except that 
now there are two parents to each member.
We want to know all living ancestors of Alice, from oldest to youngest.
An ordinary common table expression, "parent_of", is defined first.  That
ordinary CTE is a view that can be used to find all parents of any
individual.  That ordinary CTE is then used in the "ancestor_of_alice"
recursive CTE.  The recursive CTE is then used in the final query:

</p><blockquote><pre>
WITH RECURSIVE
  parent_of(name, parent) AS
    (SELECT name, mom FROM family UNION SELECT name, dad FROM family),
  ancestor_of_alice(name) AS
    (SELECT parent FROM parent_of WHERE name='Alice'
     UNION ALL
     SELECT parent FROM parent_of JOIN ancestor_of_alice USING(name))
SELECT family.name FROM ancestor_of_alice, family
 WHERE ancestor_of_alice.name=family.name
   AND died IS NULL
 ORDER BY born;
</pre></blockquote>

<a name="rcex3"></a>

<h2 id="queries_against_a_graph"><span>3.3. </span>Queries Against A Graph</h2>

<p>A version control system (VCS) will typically store the evolving
versions of a project as a directed acyclic graph (DAG).  Call each
version of the project a "checkin".  A single
checkin can have zero or more parents.  Most checkins (except the
first) have a single parent, but in the case of a merge, a checkin
might have two or three or more parents.  A schema to keep track of
checkins and the order in which they occur might look something like
this:

</p><blockquote><pre>
CREATE TABLE checkin(
  id INTEGER PRIMARY KEY,
  mtime INTEGER -- timestamp when this checkin occurred
);
CREATE TABLE derivedfrom(
  xfrom INTEGER NOT NULL REFERENCES checkin, -- parent checkin
  xto INTEGER NOT NULL REFERENCES checkin,   -- derived checkin
  PRIMARY KEY(xfrom,xto)
);
CREATE INDEX derivedfrom_back ON derivedfrom(xto,xfrom);
</pre></blockquote>

<p>This graph is acyclic.  And we assume that the mtime of every
child checkin is no less than the mtime of all its parents.  But
unlike the earlier examples, this graph might have multiple paths of
differing lengths between any two checkins.

</p><p>We want to know the twenty most recent ancestors in time (out of
the thousands and thousands of ancestors in the whole DAG) for
checkin "@BASELINE".  (A query similar to this is used
by the <a href="http://www.fossil-scm.org/">Fossil</a> VCS to
show the N most recent ancestors of a check.  For example:
<a href="http://www.sqlite.org/src/timeline?p=trunk&n=30">http://www.sqlite.org/src/timeline?p=trunk&n=30</a>.)

</p><blockquote><pre>
WITH RECURSIVE
  ancestor(id,mtime) AS (
    SELECT id, mtime FROM checkin WHERE id=@BASELINE
    UNION
    SELECT derivedfrom.xfrom, checkin.mtime
      FROM ancestor, derivedfrom, checkin
     WHERE ancestor.id=derivedfrom.xto
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
The ORDER BY essentially sets up a priority queue that
forces the recursive query to look at the most recent ancestors first,
allowing the use of a LIMIT clause to restrict the scope of the
query to just the checkins of interest.

<a name="withorderby"></a>

<h4>Controlling Depth-First Versus Breadth-First Search Of a Tree
Using ORDER BY</h4>

<p>An ORDER BY clause on the recursive-select can be used to control
whether the search of a tree is depth-first or breadth-first.  To
illustrate, we will use a variation on the "org" table from an example
above, without the "height" column, and with some real data inserted:

<blockquote><pre>
CREATE TABLE org(
  name TEXT PRIMARY KEY,
  boss TEXT REFERENCES org
) WITHOUT ROWID;
INSERT INTO org VALUES('Alice',NULL);
INSERT INTO org VALUES('Bob','Alice');
INSERT INTO org VALUES('Cindy','Alice');
INSERT INTO org VALUES('Dave','Bob');
INSERT INTO org VALUES('Emma','Bob');
INSERT INTO org VALUES('Fred','Cindy');
INSERT INTO org VALUES('Gail','Cindy');
</pre></blockquote>

<p>Here is a query to show the tree structure in a breadth-first pattern:

<blockquote><pre>
WITH RECURSIVE
  under_alice(name,level) AS (
    VALUES('Alice',0)
    UNION ALL
    SELECT org.name, under_alice.level+1
      FROM org JOIN under_alice ON org.boss=under_alice.name
     ORDER BY 2
  )
SELECT substr('..........',1,level*3) || name FROM under_alice;
</pre></blockquote>

<p>The "ORDER BY 2" (which means the same as "ORDER BY under_alice.level+1")
causes higher levels in the organization chart (with smaller "level" values)
to be processed first, resulting in a breadth-first search.  The output is:

<blockquote><pre>
Alice
...Bob
...Cindy
......Dave
......Emma
......Fred
......Gail
</pre></blockquote>

<p>But if we change the ORDER BY clause to add the "DESC" modifier, that will
cause lower levels in the organization (with larger "level" values) to be
processed first by the recursive-select, resulting in a depth-first search:

<blockquote><pre>
WITH RECURSIVE
  under_alice(name,level) AS (
    VALUES('Alice',0)
    UNION ALL
    SELECT org.name, under_alice.level+1
      FROM org JOIN under_alice ON org.boss=under_alice.name
     ORDER BY 2 <b>DESC</b>
  )
SELECT substr('..........',1,level*3) || name FROM under_alice;
</pre></blockquote>

<p>The output of this revised query is:

<blockquote><pre>
Alice
...Bob
......Dave
......Emma
...Cindy
......Fred
......Gail
</pre></blockquote>

<p>When the ORDER BY clause is omitted from the recursive-select, the
queue behaves as a FIFO, which results in a breadth-first search.


<a name="mandelbrot"></a>

<h4>Outlandish Recursive Query Examples</h4>

<p>The following query computes an approximation of the Mandelbrot Set
and outputs the result as ASCII-art:

<blockquote><pre>
WITH RECURSIVE
  xaxis(x) AS (VALUES(-2.0) UNION ALL SELECT x+0.05 FROM xaxis WHERE x&lt;1.2),
  yaxis(y) AS (VALUES(-1.0) UNION ALL SELECT y+0.1 FROM yaxis WHERE y&lt;1.0),
  m(iter, cx, cy, x, y) AS (
    SELECT 0, x, y, 0.0, 0.0 FROM xaxis, yaxis
    UNION ALL
    SELECT iter+1, cx, cy, x*x-y*y + cx, 2.0*x*y + cy FROM m 







|
|






|















|















|













|













|















|




|







575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
The ORDER BY essentially sets up a priority queue that
forces the recursive query to look at the most recent ancestors first,
allowing the use of a LIMIT clause to restrict the scope of the
query to just the checkins of interest.

<a name="withorderby"></a>

</p><h2 id="controlling_depth_first_versus_breadth_first_search_of_a_tree_using_order_by"><span>3.4. </span>Controlling Depth-First Versus Breadth-First Search Of a Tree
Using ORDER BY</h2>

<p>An ORDER BY clause on the recursive-select can be used to control
whether the search of a tree is depth-first or breadth-first.  To
illustrate, we will use a variation on the "org" table from an example
above, without the "height" column, and with some real data inserted:

</p><blockquote><pre>
CREATE TABLE org(
  name TEXT PRIMARY KEY,
  boss TEXT REFERENCES org
) WITHOUT ROWID;
INSERT INTO org VALUES('Alice',NULL);
INSERT INTO org VALUES('Bob','Alice');
INSERT INTO org VALUES('Cindy','Alice');
INSERT INTO org VALUES('Dave','Bob');
INSERT INTO org VALUES('Emma','Bob');
INSERT INTO org VALUES('Fred','Cindy');
INSERT INTO org VALUES('Gail','Cindy');
</pre></blockquote>

<p>Here is a query to show the tree structure in a breadth-first pattern:

</p><blockquote><pre>
WITH RECURSIVE
  under_alice(name,level) AS (
    VALUES('Alice',0)
    UNION ALL
    SELECT org.name, under_alice.level+1
      FROM org JOIN under_alice ON org.boss=under_alice.name
     ORDER BY 2
  )
SELECT substr('..........',1,level*3) || name FROM under_alice;
</pre></blockquote>

<p>The "ORDER BY 2" (which means the same as "ORDER BY under_alice.level+1")
causes higher levels in the organization chart (with smaller "level" values)
to be processed first, resulting in a breadth-first search.  The output is:

</p><blockquote><pre>
Alice
...Bob
...Cindy
......Dave
......Emma
......Fred
......Gail
</pre></blockquote>

<p>But if we change the ORDER BY clause to add the "DESC" modifier, that will
cause lower levels in the organization (with larger "level" values) to be
processed first by the recursive-select, resulting in a depth-first search:

</p><blockquote><pre>
WITH RECURSIVE
  under_alice(name,level) AS (
    VALUES('Alice',0)
    UNION ALL
    SELECT org.name, under_alice.level+1
      FROM org JOIN under_alice ON org.boss=under_alice.name
     ORDER BY 2 <b>DESC</b>
  )
SELECT substr('..........',1,level*3) || name FROM under_alice;
</pre></blockquote>

<p>The output of this revised query is:

</p><blockquote><pre>
Alice
...Bob
......Dave
......Emma
...Cindy
......Fred
......Gail
</pre></blockquote>

<p>When the ORDER BY clause is omitted from the recursive-select, the
queue behaves as a FIFO, which results in a breadth-first search.


<a name="mandelbrot"></a>

</p><h2 id="outlandish_recursive_query_examples"><span>3.5. </span>Outlandish Recursive Query Examples</h2>

<p>The following query computes an approximation of the Mandelbrot Set
and outputs the result as ASCII-art:

</p><blockquote><pre>
WITH RECURSIVE
  xaxis(x) AS (VALUES(-2.0) UNION ALL SELECT x+0.05 FROM xaxis WHERE x&lt;1.2),
  yaxis(y) AS (VALUES(-1.0) UNION ALL SELECT y+0.1 FROM yaxis WHERE y&lt;1.0),
  m(iter, cx, cy, x, y) AS (
    SELECT 0, x, y, 0.0, 0.0 FROM xaxis, yaxis
    UNION ALL
    SELECT iter+1, cx, cy, x*x-y*y + cx, 2.0*x*y + cy FROM m 
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
The "m2(iter,cx,cy)" CTE holds the maximum number of iterations reached when
starting at point cx,cy.
Finally, each row in the "a(t)" CTE holds a string 
which is a single line of the output ASCII-art.
The SELECT statement at the end just queries the "a" CTE to
retrieve all lines of ASCII-art, one by one.

<p>Running the query above in an SQLite <a href="cli.html">command-line shell</a> results
in the following output:

<blockquote><pre>
                                    ....#
                                   ..#*..
                                 ..+####+.
                            .......+####....   +
                           ..##+*##########+.++++
                          .+.##################+.
              .............+###################+.+







|


|







697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
The "m2(iter,cx,cy)" CTE holds the maximum number of iterations reached when
starting at point cx,cy.
Finally, each row in the "a(t)" CTE holds a string 
which is a single line of the output ASCII-art.
The SELECT statement at the end just queries the "a" CTE to
retrieve all lines of ASCII-art, one by one.

</p><p>Running the query above in an SQLite <a href="cli.html">command-line shell</a> results
in the following output:

</p><blockquote><pre>
                                    ....#
                                   ..#*..
                                 ..+####+.
                            .......+####....   +
                           ..##+*##########+.++++
                          .+.##################+.
              .............+###################+.+
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730

<p>This next query solves a Sudoku puzzle.  The state of the puzzle is
defined by an 81-character string formed by reading entries from the
puzzle box row by row from left to right and then from top to bottom.
Blank squares in the puzzle are denoted by a "." character.  
Thus the input string:

<blockquote>
53..7....6..195....98....6.8...6...34..8.3..17...2...6.6....28....419..5....8..79
</blockquote>

<p>Corresponds to a puzzle like this:

<blockquote>
<table border="1" cellpadding="5">
<tr><td>5<td>3<td> <td> <td>7<td> <td> <td> <td>
<tr><td>6<td> <td> <td>1<td>9<td>5<td> <td> <td>
<tr><td> <td>9<td>8<td> <td> <td> <td> <td>6<td>
<tr><td>8<td> <td> <td> <td>6<td> <td> <td> <td>3
<tr><td>4<td> <td> <td>8<td> <td>3<td> <td> <td>1
<tr><td>7<td> <td> <td> <td>2<td> <td> <td> <td>6
<tr><td> <td>6<td> <td> <td> <td> <td>2<td>8<td>
<tr><td> <td> <td> <td>4<td>1<td>9<td> <td> <td>5
<tr><td> <td> <td> <td> <td>8<td> <td> <td>7<td>9
</table>
</blockquote>

<p>This is the query that solves the puzzle:

<blockquote><pre>
WITH RECURSIVE
  input(sud) AS (
    VALUES('53..7....6..195....98....6.8...6...34..8.3..17...2...6.6....28....419..5....8..79')
  ),
  digits(z, lp) AS (
    VALUES('1', 1)
    UNION ALL SELECT







|





|

|
|
|
|
|
|
|
|
|
|




|







733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769

<p>This next query solves a Sudoku puzzle.  The state of the puzzle is
defined by an 81-character string formed by reading entries from the
puzzle box row by row from left to right and then from top to bottom.
Blank squares in the puzzle are denoted by a "." character.  
Thus the input string:

</p><blockquote>
53..7....6..195....98....6.8...6...34..8.3..17...2...6.6....28....419..5....8..79
</blockquote>

<p>Corresponds to a puzzle like this:

</p><blockquote>
<table border="1" cellpadding="5">
<tr><td>5</td><td>3</td><td> </td><td> </td><td>7</td><td> </td><td> </td><td> </td><td>
</td></tr><tr><td>6</td><td> </td><td> </td><td>1</td><td>9</td><td>5</td><td> </td><td> </td><td>
</td></tr><tr><td> </td><td>9</td><td>8</td><td> </td><td> </td><td> </td><td> </td><td>6</td><td>
</td></tr><tr><td>8</td><td> </td><td> </td><td> </td><td>6</td><td> </td><td> </td><td> </td><td>3
</td></tr><tr><td>4</td><td> </td><td> </td><td>8</td><td> </td><td>3</td><td> </td><td> </td><td>1
</td></tr><tr><td>7</td><td> </td><td> </td><td> </td><td>2</td><td> </td><td> </td><td> </td><td>6
</td></tr><tr><td> </td><td>6</td><td> </td><td> </td><td> </td><td> </td><td>2</td><td>8</td><td>
</td></tr><tr><td> </td><td> </td><td> </td><td>4</td><td>1</td><td>9</td><td> </td><td> </td><td>5
</td></tr><tr><td> </td><td> </td><td> </td><td> </td><td>8</td><td> </td><td> </td><td>7</td><td>9
</td></tr></table>
</blockquote>

<p>This is the query that solves the puzzle:

</p><blockquote><pre>
WITH RECURSIVE
  input(sud) AS (
    VALUES('53..7....6..195....98....6.8...6...34..8.3..17...2...6.6....28....419..5....8..79')
  ),
  digits(z, lp) AS (
    VALUES('1', 1)
    UNION ALL SELECT
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
The "digits" CTE defines a table that holds all digits between 1 and 9.
The work of solving the puzzle is undertaken by the "x" CTE.
An entry in x(s,ind) means that the 81-character string "s" is a valid
sudoku puzzle (it has no conflicts) and that the first unknown character
is at position "ind", or ind==0 if all character positions are filled in.
The goal, then, is to compute entries for "x" with an "ind" of 0.

<p>The solver works by adding new entries to the "x" recursive table.
Given prior entries, the recursive-select tries to fill in a single new
position with all values between 1 and 9 that actually work in that
position.  The complicated "NOT EXISTS" subquery is the magic that
figures out whether or not each candidate "s" string is a valid
sudoku puzzle or not.

<p>The final answer is found by looking for a string with ind==0.
If the original sudoku problem did not have a unique solution, then
the query will return all possible solutions.  If the original problem
was unsolvable, then no rows will be returned.  In this case, the unique
answer is:

<blockquote>
534678912672195348198342567859761423426853791713924856961537284287419635345286179
</blockquote>

<p>The solution was computed in less than 300 milliseconds on a modern
workstation.

<h3>Limitations And Caveats</h3>

<ul>
<li><p>
The WITH clause cannot be used within a <a href="lang_createtrigger.html">CREATE TRIGGER</a>.
<li><p>
The WITH clause must appear at the beginning of a top-level <a href="lang_select.html">SELECT</a> statement
or at the beginning of a subquery.  The WITH clause cannot be prepended to
the second or subsequent SELECT statement of a <a href="lang_select.html#compound">compound select</a>.
<li><p>
The SQL:1999 spec requires that the RECURSIVE keyword follow WITH in any
WITH clause that includes a recursive common table expression.  However, for
compatibility with SqlServer and Oracle, SQLite does not enforce this rule.
</ul>









|






|





|






|




|



|



|

<
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835

The "digits" CTE defines a table that holds all digits between 1 and 9.
The work of solving the puzzle is undertaken by the "x" CTE.
An entry in x(s,ind) means that the 81-character string "s" is a valid
sudoku puzzle (it has no conflicts) and that the first unknown character
is at position "ind", or ind==0 if all character positions are filled in.
The goal, then, is to compute entries for "x" with an "ind" of 0.

</p><p>The solver works by adding new entries to the "x" recursive table.
Given prior entries, the recursive-select tries to fill in a single new
position with all values between 1 and 9 that actually work in that
position.  The complicated "NOT EXISTS" subquery is the magic that
figures out whether or not each candidate "s" string is a valid
sudoku puzzle or not.

</p><p>The final answer is found by looking for a string with ind==0.
If the original sudoku problem did not have a unique solution, then
the query will return all possible solutions.  If the original problem
was unsolvable, then no rows will be returned.  In this case, the unique
answer is:

</p><blockquote>
534678912672195348198342567859761423426853791713924856961537284287419635345286179
</blockquote>

<p>The solution was computed in less than 300 milliseconds on a modern
workstation.

</p><h1 id="limitations_and_caveats"><span>4. </span>Limitations And Caveats</h1>

<ul>
<li><p>
The WITH clause cannot be used within a <a href="lang_createtrigger.html">CREATE TRIGGER</a>.
</p></li><li><p>
The WITH clause must appear at the beginning of a top-level <a href="lang_select.html">SELECT</a> statement
or at the beginning of a subquery.  The WITH clause cannot be prepended to
the second or subsequent SELECT statement of a <a href="lang_select.html#compound">compound select</a>.
</p></li><li><p>
The SQL:1999 spec requires that the RECURSIVE keyword follow WITH in any
WITH clause that includes a recursive common table expression.  However, for
compatibility with SqlServer and Oracle, SQLite does not enforce this rule.
</p></li></ul>


Changes to Doc/Extra/Core/pragma.html.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260

261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344

345
346
347
348
349
350
351



352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374





























375
376
377
378
379
380
381
382
383
384
385
386
387
feature becomes officially supported.
<li><p>
The table-valued functions for PRAGMA feature was added
in SQLite version 3.16.0 (2017-01-02).  Prior versions of SQLite
cannot use this feature.
</ul>


<hr /><a name="toc"></a>
<h2>List Of PRAGMAs</h2>
<style>
#listtab36 tr td {vertical-align:top;}
</style>
<table id='listtab36' width='100%'></table>
<script>

var listitems36 = [{"u":"pragma.html#pragma_application_id","x":"application_id","s":0},
{"u":"pragma.html#pragma_auto_vacuum","x":"auto_vacuum","s":0},
{"u":"pragma.html#pragma_automatic_index","x":"automatic_index","s":0},
{"u":"pragma.html#pragma_busy_timeout","x":"busy_timeout","s":0},
{"u":"pragma.html#pragma_cache_size","x":"cache_size","s":0},
{"u":"pragma.html#pragma_cache_spill","x":"cache_spill","s":0},
{"u":"pragma.html#pragma_case_sensitive_like","x":"case_sensitive_like","s":0},
{"u":"pragma.html#pragma_cell_size_check","x":"cell_size_check","s":0},
{"u":"pragma.html#pragma_checkpoint_fullfsync","x":"checkpoint_fullfsync","s":0},
{"u":"pragma.html#pragma_collation_list","x":"collation_list","s":0},
{"u":"pragma.html#pragma_compile_options","x":"compile_options","s":0},
{"u":"pragma.html#pragma_count_changes","x":"count_changes","s":3},
{"u":"pragma.html#pragma_data_store_directory","x":"data_store_directory","s":3},
{"u":"pragma.html#pragma_data_version","x":"data_version","s":0},
{"u":"pragma.html#pragma_database_list","x":"database_list","s":0},
{"u":"pragma.html#pragma_default_cache_size","x":"default_cache_size","s":3},
{"u":"pragma.html#pragma_defer_foreign_keys","x":"defer_foreign_keys","s":0},
{"u":"pragma.html#pragma_empty_result_callbacks","x":"empty_result_callbacks","s":3},
{"u":"pragma.html#pragma_encoding","x":"encoding","s":0},
{"u":"pragma.html#pragma_foreign_key_check","x":"foreign_key_check","s":0},
{"u":"pragma.html#pragma_foreign_key_list","x":"foreign_key_list","s":0},
{"u":"pragma.html#pragma_foreign_keys","x":"foreign_keys","s":0},
{"u":"pragma.html#pragma_freelist_count","x":"freelist_count","s":0},
{"u":"pragma.html#pragma_full_column_names","x":"full_column_names","s":3},
{"u":"pragma.html#pragma_fullfsync","x":"fullfsync","s":0},
{"u":"pragma.html#pragma_function_list","x":"function_list","s":0},
{"u":"pragma.html#pragma_hard_heap_limit","x":"hard_heap_limit","s":0},
{"u":"pragma.html#pragma_ignore_check_constraints","x":"ignore_check_constraints","s":0},
{"u":"pragma.html#pragma_incremental_vacuum","x":"incremental_vacuum","s":0},
{"u":"pragma.html#pragma_index_info","x":"index_info","s":0},
{"u":"pragma.html#pragma_index_list","x":"index_list","s":0},
{"u":"pragma.html#pragma_index_xinfo","x":"index_xinfo","s":0},
{"u":"pragma.html#pragma_integrity_check","x":"integrity_check","s":0},
{"u":"pragma.html#pragma_journal_mode","x":"journal_mode","s":0},
{"u":"pragma.html#pragma_journal_size_limit","x":"journal_size_limit","s":0},
{"u":"pragma.html#pragma_legacy_alter_table","x":"legacy_alter_table","s":0},
{"u":"pragma.html#pragma_legacy_file_format","x":"legacy_file_format","s":0},
{"u":"pragma.html#pragma_locking_mode","x":"locking_mode","s":0},
{"u":"pragma.html#pragma_max_page_count","x":"max_page_count","s":0},
{"u":"pragma.html#pragma_mmap_size","x":"mmap_size","s":0},
{"u":"pragma.html#pragma_module_list","x":"module_list","s":0},
{"u":"pragma.html#pragma_optimize","x":"optimize","s":0},
{"u":"pragma.html#pragma_page_count","x":"page_count","s":0},
{"u":"pragma.html#pragma_page_size","x":"page_size","s":0},
{"u":"pragma.html#pragma_parser_trace","x":"parser_trace","s":4},
{"u":"pragma.html#pragma_pragma_list","x":"pragma_list","s":0},
{"u":"pragma.html#pragma_query_only","x":"query_only","s":0},
{"u":"pragma.html#pragma_quick_check","x":"quick_check","s":0},
{"u":"pragma.html#pragma_read_uncommitted","x":"read_uncommitted","s":0},
{"u":"pragma.html#pragma_recursive_triggers","x":"recursive_triggers","s":0},
{"u":"pragma.html#pragma_reverse_unordered_selects","x":"reverse_unordered_selects","s":0},
{"u":"pragma.html#pragma_schema_version","x":"schema_version","s":5},
{"u":"pragma.html#pragma_secure_delete","x":"secure_delete","s":0},
{"u":"pragma.html#pragma_short_column_names","x":"short_column_names","s":3},
{"u":"pragma.html#pragma_shrink_memory","x":"shrink_memory","s":0},
{"u":"pragma.html#pragma_soft_heap_limit","x":"soft_heap_limit","s":0},
{"u":"pragma.html#pragma_stats","x":"stats","s":5},
{"u":"pragma.html#pragma_synchronous","x":"synchronous","s":0},
{"u":"pragma.html#pragma_table_info","x":"table_info","s":0},
{"u":"pragma.html#pragma_table_xinfo","x":"table_xinfo","s":0},
{"u":"pragma.html#pragma_temp_store","x":"temp_store","s":0},
{"u":"pragma.html#pragma_temp_store_directory","x":"temp_store_directory","s":3},
{"u":"pragma.html#pragma_threads","x":"threads","s":0},
{"u":"pragma.html#pragma_trusted_schema","x":"trusted_schema","s":0},
{"u":"pragma.html#pragma_user_version","x":"user_version","s":0},
{"u":"pragma.html#pragma_vdbe_addoptrace","x":"vdbe_addoptrace","s":4},
{"u":"pragma.html#pragma_vdbe_debug","x":"vdbe_debug","s":4},
{"u":"pragma.html#pragma_vdbe_listing","x":"vdbe_listing","s":4},
{"u":"pragma.html#pragma_vdbe_trace","x":"vdbe_trace","s":4},
{"u":"pragma.html#pragma_wal_autocheckpoint","x":"wal_autocheckpoint","s":0},
{"u":"pragma.html#pragma_wal_checkpoint","x":"wal_checkpoint","s":0},
{"u":"pragma.html#pragma_writable_schema","x":"writable_schema","s":5}];
var j = 0;
var w = Math.max(document.documentElement.clientWidth,  window.innerWidth || 0);
var nCol = Math.floor(w/250);
if(nCol<=0) nCol=1;
var nRow = Math.ceil((listitems36.length+1)/nCol);
var h="<tr><td><ul class='multicol_list'>"
var ea
for(var i=0; i<listitems36.length; i++){
  if( (++j)>nRow ){
    h += "</ul></td>\n<td><ul class='multicol_list'>\n";
    j = 1;
  }

  if(listitems36[i].u=="" || listitems36[i].s==2){
    h += "<li>"
    ea = ""
  }else{
    h += "<li><a href='";
    h += listitems36[i].u;
    h += "'>";



    ea = "</a>"
  }
  if(listitems36[i].s==2 || listitems36[i].s==3) h += "<s>"
  h += listitems36[i].x;
  if(listitems36[i].s==2 || listitems36[i].s==3) h += "</s>"
  h += ea
  if(listitems36[i].s==1) h += "<small><i>(exp)</i></small>\n";
  if(listitems36[i].s==3) h += "&sup1\n";
  if(listitems36[i].s==4) h += "&sup2\n";
  if(listitems36[i].s==5) h += "&sup3\n";
}
document.getElementById("listtab36").innerHTML = h;
</script>

<p>Notes:
<ol>
<li>Pragmas whose names are <s>struck through</s>
are deprecated. Do not use them. They exist
for historical compatibility.
<li>These pragmas are only available in builds using non-standard
compile-time options.
<li>These pragmas are used for testing SQLite and are not recommended
for use in application programs.</ol></p>





























<a name="pragma_application_id"></a>
<h _id=pragma_application_id style="display:none"> PRAGMA application_id</h><hr>
    <p><b>PRAGMA </b><i>schema.</i><b>application_id;
     <br>PRAGMA </b><i>schema.</i><b>application_id = </b><i>integer </i><b>;</b>
  
<p>    The application_id PRAGMA is used to query or set the 32-bit
       signed big-endian "Application ID" integer located at offset
       68 into the <a href="fileformat2.html#database_header">database header</a>.  Applications that use SQLite as their
       <a href="appfileformat.html">application file-format</a> should set the Application ID integer to
       a unique integer so that utilities such as 
       <a href="http://www.darwinsys.com/file/">file(1)</a> can determine the specific
       file type rather than just reporting "SQLite3 Database".  A list of
       assigned application IDs can be seen by consulting the







<


|
<
|
<
<
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
<
|
|
<
|
|
|
|
|
|
|
<
|
|
|
|
|
|
|
<
|
|
<
<
<
<
|
|
|
|
|
|
|
<
>
|
|
|
|
|
|
|
>
>
>
|
<
<
<
<
<
<
<
<
<
<
<
|










>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>





|







246
247
248
249
250
251
252

253
254
255

256


257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292














293

294
295

296
297
298
299
300
301
302

303
304
305
306
307
308
309

310
311




312
313
314
315
316
317
318

319
320
321
322
323
324
325
326
327
328
329
330











331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
feature becomes officially supported.
<li><p>
The table-valued functions for PRAGMA feature was added
in SQLite version 3.16.0 (2017-01-02).  Prior versions of SQLite
cannot use this feature.
</ul>


<hr /><a name="toc"></a>
<h2>List Of PRAGMAs</h2>
<div class='columns' style='columns: 12em auto;'>

<ul style='padding-top:0;'>


<li><a href='pragma.html#pragma_analysis_limit'>analysis_limit</a></li>
<li><a href='pragma.html#pragma_application_id'>application_id</a></li>
<li><a href='pragma.html#pragma_auto_vacuum'>auto_vacuum</a></li>
<li><a href='pragma.html#pragma_automatic_index'>automatic_index</a></li>
<li><a href='pragma.html#pragma_busy_timeout'>busy_timeout</a></li>
<li><a href='pragma.html#pragma_cache_size'>cache_size</a></li>
<li><a href='pragma.html#pragma_cache_spill'>cache_spill</a></li>
<li><a href='pragma.html#pragma_case_sensitive_like'>case_sensitive_like</a></li>
<li><a href='pragma.html#pragma_cell_size_check'>cell_size_check</a></li>
<li><a href='pragma.html#pragma_checkpoint_fullfsync'>checkpoint_fullfsync</a></li>
<li><a href='pragma.html#pragma_collation_list'>collation_list</a></li>
<li><a href='pragma.html#pragma_compile_options'>compile_options</a></li>
<li><a href='pragma.html#pragma_count_changes'><s>count_changes&sup1;</s></a></li>
<li><a href='pragma.html#pragma_data_store_directory'><s>data_store_directory&sup1;</s></a></li>
<li><a href='pragma.html#pragma_data_version'>data_version</a></li>
<li><a href='pragma.html#pragma_database_list'>database_list</a></li>
<li><a href='pragma.html#pragma_default_cache_size'><s>default_cache_size&sup1;</s></a></li>
<li><a href='pragma.html#pragma_defer_foreign_keys'>defer_foreign_keys</a></li>
<li><a href='pragma.html#pragma_empty_result_callbacks'><s>empty_result_callbacks&sup1;</s></a></li>
<li><a href='pragma.html#pragma_encoding'>encoding</a></li>
<li><a href='pragma.html#pragma_foreign_key_check'>foreign_key_check</a></li>
<li><a href='pragma.html#pragma_foreign_key_list'>foreign_key_list</a></li>
<li><a href='pragma.html#pragma_foreign_keys'>foreign_keys</a></li>
<li><a href='pragma.html#pragma_freelist_count'>freelist_count</a></li>
<li><a href='pragma.html#pragma_full_column_names'><s>full_column_names&sup1;</s></a></li>
<li><a href='pragma.html#pragma_fullfsync'>fullfsync</a></li>
<li><a href='pragma.html#pragma_function_list'>function_list</a></li>
<li><a href='pragma.html#pragma_hard_heap_limit'>hard_heap_limit</a></li>
<li><a href='pragma.html#pragma_ignore_check_constraints'>ignore_check_constraints</a></li>
<li><a href='pragma.html#pragma_incremental_vacuum'>incremental_vacuum</a></li>
<li><a href='pragma.html#pragma_index_info'>index_info</a></li>
<li><a href='pragma.html#pragma_index_list'>index_list</a></li>
<li><a href='pragma.html#pragma_index_xinfo'>index_xinfo</a></li>
<li><a href='pragma.html#pragma_integrity_check'>integrity_check</a></li>
<li><a href='pragma.html#pragma_journal_mode'>journal_mode</a></li>
<li><a href='pragma.html#pragma_journal_size_limit'>journal_size_limit</a></li>














<li><a href='pragma.html#pragma_legacy_alter_table'>legacy_alter_table</a></li>

<li><a href='pragma.html#pragma_legacy_file_format'>legacy_file_format</a></li>
<li><a href='pragma.html#pragma_locking_mode'>locking_mode</a></li>

<li><a href='pragma.html#pragma_max_page_count'>max_page_count</a></li>
<li><a href='pragma.html#pragma_mmap_size'>mmap_size</a></li>
<li><a href='pragma.html#pragma_module_list'>module_list</a></li>
<li><a href='pragma.html#pragma_optimize'>optimize</a></li>
<li><a href='pragma.html#pragma_page_count'>page_count</a></li>
<li><a href='pragma.html#pragma_page_size'>page_size</a></li>
<li><a href='pragma.html#pragma_parser_trace'>parser_trace&sup2;</a></li>

<li><a href='pragma.html#pragma_pragma_list'>pragma_list</a></li>
<li><a href='pragma.html#pragma_query_only'>query_only</a></li>
<li><a href='pragma.html#pragma_quick_check'>quick_check</a></li>
<li><a href='pragma.html#pragma_read_uncommitted'>read_uncommitted</a></li>
<li><a href='pragma.html#pragma_recursive_triggers'>recursive_triggers</a></li>
<li><a href='pragma.html#pragma_reverse_unordered_selects'>reverse_unordered_selects</a></li>
<li><a href='pragma.html#pragma_schema_version'>schema_version&sup3;</a></li>

<li><a href='pragma.html#pragma_secure_delete'>secure_delete</a></li>
<li><a href='pragma.html#pragma_short_column_names'><s>short_column_names&sup1;</s></a></li>




<li><a href='pragma.html#pragma_shrink_memory'>shrink_memory</a></li>
<li><a href='pragma.html#pragma_soft_heap_limit'>soft_heap_limit</a></li>
<li><a href='pragma.html#pragma_stats'>stats&sup3;</a></li>
<li><a href='pragma.html#pragma_synchronous'>synchronous</a></li>
<li><a href='pragma.html#pragma_table_info'>table_info</a></li>
<li><a href='pragma.html#pragma_table_xinfo'>table_xinfo</a></li>
<li><a href='pragma.html#pragma_temp_store'>temp_store</a></li>

<li><a href='pragma.html#pragma_temp_store_directory'><s>temp_store_directory&sup1;</s></a></li>
<li><a href='pragma.html#pragma_threads'>threads</a></li>
<li><a href='pragma.html#pragma_trusted_schema'>trusted_schema</a></li>
<li><a href='pragma.html#pragma_user_version'>user_version</a></li>
<li><a href='pragma.html#pragma_vdbe_addoptrace'>vdbe_addoptrace&sup2;</a></li>
<li><a href='pragma.html#pragma_vdbe_debug'>vdbe_debug&sup2;</a></li>
<li><a href='pragma.html#pragma_vdbe_listing'>vdbe_listing&sup2;</a></li>
<li><a href='pragma.html#pragma_vdbe_trace'>vdbe_trace&sup2;</a></li>
<li><a href='pragma.html#pragma_wal_autocheckpoint'>wal_autocheckpoint</a></li>
<li><a href='pragma.html#pragma_wal_checkpoint'>wal_checkpoint</a></li>
<li><a href='pragma.html#pragma_writable_schema'>writable_schema&sup3;</a></li>
</ul>











</div>

<p>Notes:
<ol>
<li>Pragmas whose names are <s>struck through</s>
are deprecated. Do not use them. They exist
for historical compatibility.
<li>These pragmas are only available in builds using non-standard
compile-time options.
<li>These pragmas are used for testing SQLite and are not recommended
for use in application programs.</ol></p>
<a name="pragma_analysis_limit"></a>
<h _id=pragma_analysis_limit style="display:none"> PRAGMA analysis_limit</h><hr>
   <p><b>PRAGMA analysis_limit;
        <br>PRAGMA analysis_limit = </b><i>N</i><b>;</b></p>
   <p>Query or change a limit on the <a href="lang_analyze.html#approx">approximate ANALYZE</a> setting.
      This is approximate number of
      rows examined in each index by the <a href="lang_analyze.html">ANALYZE</a> command.
      If the argument <i>N</i> is omitted, then the analysis limit
      is unchanged.
      If the limit is zero, then the analysis limit is disabled and
      the ANALYZE command will examine all rows of each index.
      If N is greater than zero, then the analysis limit is set to N
      and subsequent ANALYZE commands will breaks off processing
      each index after it has examined approximately N rows.
      If N is a negative number or something other than an integer value,
      then the pragma behaves as if the N argument was omitted.
      In all cases, the value returned is the new analysis limit used
      for subsequent ANALYZE commands.
   <p>This pragma can be used to help the ANALYZE command run faster
      on large databases.  The results of analysis are not as good
      when only part of each index is examined, but the results are
      usually good enough.  Setting N to 100 or 1000 allows the
      ANALYZE command to run very quickly, even on multi-gigabyte
      database files.  This pragma is particularly useful in combination
      with <a href="pragma.html#pragma_optimize">PRAGMA optimize</a>.
   <p>This pragma was added in SQLite version 3.32.0 (2020-05-22).
      The current implementation only uses the lower 31 bits of the
      N value - higher order bits are silently ignored.  Future versions
      of SQLite might begin using higher order bits.
<a name="pragma_application_id"></a>
<h _id=pragma_application_id style="display:none"> PRAGMA application_id</h><hr>
    <p><b>PRAGMA </b><i>schema.</i><b>application_id;
     <br>PRAGMA </b><i>schema.</i><b>application_id = </b><i>integer </i><b>;</b>
  
    <p>The application_id PRAGMA is used to query or set the 32-bit
       signed big-endian "Application ID" integer located at offset
       68 into the <a href="fileformat2.html#database_header">database header</a>.  Applications that use SQLite as their
       <a href="appfileformat.html">application file-format</a> should set the Application ID integer to
       a unique integer so that utilities such as 
       <a href="http://www.darwinsys.com/file/">file(1)</a> can determine the specific
       file type rather than just reporting "SQLite3 Database".  A list of
       assigned application IDs can be seen by consulting the
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
    <p>Query or change the count-changes flag. Normally, when the
    count-changes flag is not set, <a href="lang_insert.html">INSERT</a>, <a href="lang_update.html">UPDATE</a> and <a href="lang_delete.html">DELETE</a> statements
    return no data. When count-changes is set, each of these commands 
    returns a single row of data consisting of one integer value - the
    number of rows inserted, modified or deleted by the command. The 
    returned change count does not include any insertions, modifications
    or deletions performed by triggers, any changes made automatically
    by <a href="foreignkeys.html#fk_actions">foreign key actions</a>, or updates caused by an <a href="lang_UPSERT.html">upsert</a>.</p>

    <p>Another way to get the row change counts is to use the
    <a href="c3ref/changes.html">sqlite3_changes()</a> or <a href="c3ref/total_changes.html">sqlite3_total_changes()</a> interfaces.
    There is a subtle different, though.  When an INSERT, UPDATE, or
    DELETE is run against a view using an <a href="lang_createtrigger.html#instead_of_trigger">INSTEAD OF trigger</a>,
    the count_changes pragma reports the number of rows in the view
    that fired the trigger, whereas <a href="c3ref/changes.html">sqlite3_changes()</a> and







|







597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
    <p>Query or change the count-changes flag. Normally, when the
    count-changes flag is not set, <a href="lang_insert.html">INSERT</a>, <a href="lang_update.html">UPDATE</a> and <a href="lang_delete.html">DELETE</a> statements
    return no data. When count-changes is set, each of these commands 
    returns a single row of data consisting of one integer value - the
    number of rows inserted, modified or deleted by the command. The 
    returned change count does not include any insertions, modifications
    or deletions performed by triggers, any changes made automatically
    by <a href="foreignkeys.html#fk_actions">foreign key actions</a>, or updates caused by an <a href="lang_upsert.html">upsert</a>.</p>

    <p>Another way to get the row change counts is to use the
    <a href="c3ref/changes.html">sqlite3_changes()</a> or <a href="c3ref/total_changes.html">sqlite3_total_changes()</a> interfaces.
    There is a subtle different, though.  When an INSERT, UPDATE, or
    DELETE is run against a view using an <a href="lang_createtrigger.html#instead_of_trigger">INSTEAD OF trigger</a>,
    the count_changes pragma reports the number of rows in the view
    that fired the trigger, whereas <a href="c3ref/changes.html">sqlite3_changes()</a> and
1183
1184
1185
1186
1187
1188
1189





1190
1191
1192
1193
1194
1195
1196
    <p>For compatibility with older <a href="vtab.html">virtual table</a> implementations,
    this flag is turned on temporarily while the <a href="vtab.html#xrename">sqlite3_module.xRename</a>
    method is being run.  The value of this flag is restore after the 
    <a href="vtab.html#xrename">sqlite3_module.xRename</a> method finishes.
    <p>The legacy alter table behavior can also be toggled on and off
    using the <a href="c3ref/c_dbconfig_defensive.html#sqlitedbconfiglegacyaltertable">SQLITE_DBCONFIG_LEGACY_ALTER_TABLE</a> option to the
    <a href="c3ref/db_config.html">sqlite3_db_config()</a> interface.





<a name="pragma_legacy_file_format"></a>
<h _id=pragma_legacy_file_format style="display:none"> PRAGMA legacy_file_format</h><hr>
   <p><b>PRAGMA legacy_file_format;</b>
    <p>This pragma no longer functions.  It has become a no-op.
    The capabilities formerly provided by PRAGMA legacy_file_format
    are now available using the <a href="c3ref/c_dbconfig_defensive.html#sqlitedbconfiglegacyfileformat">SQLITE_DBCONFIG_LEGACY_FILE_FORMAT</a>
    option to the <a href="c3ref/db_config.html">sqlite3_db_config()</a> C-language interface.







>
>
>
>
>







1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
    <p>For compatibility with older <a href="vtab.html">virtual table</a> implementations,
    this flag is turned on temporarily while the <a href="vtab.html#xrename">sqlite3_module.xRename</a>
    method is being run.  The value of this flag is restore after the 
    <a href="vtab.html#xrename">sqlite3_module.xRename</a> method finishes.
    <p>The legacy alter table behavior can also be toggled on and off
    using the <a href="c3ref/c_dbconfig_defensive.html#sqlitedbconfiglegacyaltertable">SQLITE_DBCONFIG_LEGACY_ALTER_TABLE</a> option to the
    <a href="c3ref/db_config.html">sqlite3_db_config()</a> interface.
    <p>The legacy alter table behavior is a per-connection setting.  Turning
    this features on or off affects all attached database files within the
    <a href="c3ref/sqlite3.html">database connection</a>.
    The setting does not persist.  Changing this setting in one connection
    does not affect any other connections.
<a name="pragma_legacy_file_format"></a>
<h _id=pragma_legacy_file_format style="display:none"> PRAGMA legacy_file_format</h><hr>
   <p><b>PRAGMA legacy_file_format;</b>
    <p>This pragma no longer functions.  It has become a no-op.
    The capabilities formerly provided by PRAGMA legacy_file_format
    are now available using the <a href="c3ref/c_dbconfig_defensive.html#sqlitedbconfiglegacyfileformat">SQLITE_DBCONFIG_LEGACY_FILE_FORMAT</a>
    option to the <a href="c3ref/db_config.html">sqlite3_db_config()</a> C-language interface.
1325
1326
1327
1328
1329
1330
1331




1332
1333
1334
1335
1336
1337
1338
  <p>This pragma is usually a no-op or nearly so and is very fast.
  However if SQLite feels
  that performing database optimizations (such as running <a href="lang_analyze.html">ANALYZE</a>
  or creating new indexes) will improve the performance of future queries, then
  some database I/O may be done.  Applications that want to limit the amount
  of work performed can set a timer that will invoke
  <a href="c3ref/interrupt.html">sqlite3_interrupt()</a> if the pragma goes on for too long.




  </p>
  <p>The details of optimizations performed by this pragma are expected
  to change and improve over time.  Applications should anticipate that
  this pragma will perform new optimizations in future releases.</p>

  <p>The optional MASK argument is a bitmask of optimizations to perform:
  <ol>







>
>
>
>







1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
  <p>This pragma is usually a no-op or nearly so and is very fast.
  However if SQLite feels
  that performing database optimizations (such as running <a href="lang_analyze.html">ANALYZE</a>
  or creating new indexes) will improve the performance of future queries, then
  some database I/O may be done.  Applications that want to limit the amount
  of work performed can set a timer that will invoke
  <a href="c3ref/interrupt.html">sqlite3_interrupt()</a> if the pragma goes on for too long.
  Or, since SQLite 3.32.0, the application can use 
  <a href="pragma.html#pragma_analysis_limit">PRAGMA analysis_limit=<i>N</i></a> for some small
  value of <i>N</i> (a few hundred or a few thousand) to limit the depth
  of analyze.
  </p>
  <p>The details of optimizations performed by this pragma are expected
  to change and improve over time.  Applications should anticipate that
  this pragma will perform new optimizations in future releases.</p>

  <p>The optional MASK argument is a bitmask of optimizations to perform:
  <ol>
Changes to Doc/Extra/Core/sqlite.css.
282
283
284
285
286
287
288




















}
th.sort.asc:after {
  content: '\2193';
}
th.sort.desc:after {
  content: '\2191'
}



























>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
}
th.sort.asc:after {
  content: '\2193';
}
th.sort.desc:after {
  content: '\2191'
}

div.columns {
  padding: 0 2em 0 2em;
  max-width: 2000px;
}
div.columns > ul {
  margin: 0;
  padding: 0 0 0 1em;
  list-style-type: none;
  padding: 10px;
  margin: 0px;
  white-space: nowrap;
}
div.columns > ul li:first-child {
  margin-top:0px;
}
.columns li {
  break-inside: avoid;
  page-break-inside: avoid;
}
Changes to Doc/Extra/Core/syntax.html.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182

183
184
185
186
187

188
189



190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
}
</script>
</div>


<h1 align="center">List of SQLite Syntax Diagrams</h1>

<style>
#listtab44 tr td {vertical-align:top;}
</style>
<table id='listtab44' width='100%'></table>
<script>
var listitems44 = [{"u":"syntax/aggregate-function-invocation.html","x":"aggregate-function-invocation","s":0},
{"u":"syntax/alter-table-stmt.html","x":"alter-table-stmt","s":0},
{"u":"syntax/analyze-stmt.html","x":"analyze-stmt","s":0},
{"u":"syntax/attach-stmt.html","x":"attach-stmt","s":0},
{"u":"syntax/begin-stmt.html","x":"begin-stmt","s":0},
{"u":"syntax/column-constraint.html","x":"column-constraint","s":0},
{"u":"syntax/column-def.html","x":"column-def","s":0},
{"u":"syntax/column-name-list.html","x":"column-name-list","s":0},
{"u":"syntax/comment-syntax.html","x":"comment-syntax","s":0},
{"u":"syntax/commit-stmt.html","x":"commit-stmt","s":0},
{"u":"syntax/common-table-expression.html","x":"common-table-expression","s":0},
{"u":"syntax/compound-operator.html","x":"compound-operator","s":0},
{"u":"syntax/compound-select-stmt.html","x":"compound-select-stmt","s":0},
{"u":"syntax/conflict-clause.html","x":"conflict-clause","s":0},
{"u":"syntax/create-index-stmt.html","x":"create-index-stmt","s":0},
{"u":"syntax/create-table-stmt.html","x":"create-table-stmt","s":0},
{"u":"syntax/create-trigger-stmt.html","x":"create-trigger-stmt","s":0},
{"u":"syntax/create-view-stmt.html","x":"create-view-stmt","s":0},
{"u":"syntax/create-virtual-table-stmt.html","x":"create-virtual-table-stmt","s":0},
{"u":"syntax/cte-table-name.html","x":"cte-table-name","s":0},
{"u":"syntax/delete-stmt.html","x":"delete-stmt","s":0},
{"u":"syntax/delete-stmt-limited.html","x":"delete-stmt-limited","s":0},
{"u":"syntax/detach-stmt.html","x":"detach-stmt","s":0},
{"u":"syntax/drop-index-stmt.html","x":"drop-index-stmt","s":0},
{"u":"syntax/drop-table-stmt.html","x":"drop-table-stmt","s":0},
{"u":"syntax/drop-trigger-stmt.html","x":"drop-trigger-stmt","s":0},
{"u":"syntax/drop-view-stmt.html","x":"drop-view-stmt","s":0},
{"u":"syntax/expr.html","x":"expr","s":0},
{"u":"syntax/factored-select-stmt.html","x":"factored-select-stmt","s":0},
{"u":"syntax/filter-clause.html","x":"filter-clause","s":0},
{"u":"syntax/foreign-key-clause.html","x":"foreign-key-clause","s":0},
{"u":"syntax/frame-spec.html","x":"frame-spec","s":0},
{"u":"syntax/indexed-column.html","x":"indexed-column","s":0},
{"u":"syntax/insert-stmt.html","x":"insert-stmt","s":0},
{"u":"syntax/join-clause.html","x":"join-clause","s":0},
{"u":"syntax/join-constraint.html","x":"join-constraint","s":0},
{"u":"syntax/join-operator.html","x":"join-operator","s":0},
{"u":"syntax/literal-value.html","x":"literal-value","s":0},
{"u":"syntax/numeric-literal.html","x":"numeric-literal","s":0},
{"u":"syntax/ordering-term.html","x":"ordering-term","s":0},
{"u":"syntax/over-clause.html","x":"over-clause","s":0},
{"u":"syntax/pragma-stmt.html","x":"pragma-stmt","s":0},
{"u":"syntax/pragma-value.html","x":"pragma-value","s":0},
{"u":"syntax/qualified-table-name.html","x":"qualified-table-name","s":0},
{"u":"syntax/raise-function.html","x":"raise-function","s":0},
{"u":"syntax/recursive-cte.html","x":"recursive-cte","s":0},
{"u":"syntax/reindex-stmt.html","x":"reindex-stmt","s":0},
{"u":"syntax/release-stmt.html","x":"release-stmt","s":0},
{"u":"syntax/result-column.html","x":"result-column","s":0},
{"u":"syntax/rollback-stmt.html","x":"rollback-stmt","s":0},
{"u":"syntax/savepoint-stmt.html","x":"savepoint-stmt","s":0},
{"u":"syntax/select-core.html","x":"select-core","s":0},
{"u":"syntax/select-stmt.html","x":"select-stmt","s":0},
{"u":"syntax/signed-number.html","x":"signed-number","s":0},
{"u":"syntax/simple-function-invocation.html","x":"simple-function-invocation","s":0},
{"u":"syntax/simple-select-stmt.html","x":"simple-select-stmt","s":0},
{"u":"syntax/sql-stmt.html","x":"sql-stmt","s":0},
{"u":"syntax/sql-stmt-list.html","x":"sql-stmt-list","s":0},
{"u":"syntax/table-constraint.html","x":"table-constraint","s":0},
{"u":"syntax/table-or-subquery.html","x":"table-or-subquery","s":0},
{"u":"syntax/type-name.html","x":"type-name","s":0},
{"u":"syntax/update-stmt.html","x":"update-stmt","s":0},
{"u":"syntax/update-stmt-limited.html","x":"update-stmt-limited","s":0},
{"u":"syntax/upsert-clause.html","x":"upsert-clause","s":0},
{"u":"syntax/vacuum-stmt.html","x":"vacuum-stmt","s":0},
{"u":"syntax/window-defn.html","x":"window-defn","s":0},
{"u":"syntax/window-function-invocation.html","x":"window-function-invocation","s":0},
{"u":"syntax/with-clause.html","x":"with-clause","s":0}];
var j = 0;
var w = Math.max(document.documentElement.clientWidth,  window.innerWidth || 0);
var nCol = Math.floor(w/300);
if(nCol<=0) nCol=1;
var nRow = Math.ceil((listitems44.length+1)/nCol);
var h="<tr><td><ul class='multicol_list'>"
var ea
for(var i=0; i<listitems44.length; i++){
  if( (++j)>nRow ){
    h += "</ul></td>\n<td><ul class='multicol_list'>\n";
    j = 1;
  }

  if(listitems44[i].u=="" || listitems44[i].s==2){
    h += "<li>"
    ea = ""
  }else{
    h += "<li><a href='";

    h += listitems44[i].u;
    h += "'>";



    ea = "</a>"
  }
  if(listitems44[i].s==2 || listitems44[i].s==3) h += "<s>"
  h += listitems44[i].x;
  if(listitems44[i].s==2 || listitems44[i].s==3) h += "</s>"
  h += ea
  if(listitems44[i].s==1) h += "<small><i>(exp)</i></small>\n";
  if(listitems44[i].s==3) h += "&sup1\n";
  if(listitems44[i].s==4) h += "&sup2\n";
  if(listitems44[i].s==5) h += "&sup3\n";
}
document.getElementById("listtab44").innerHTML = h;
</script>









|
<
|
<
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
|
|
|
|
|
|
<
|
|
|
|
|
|
|
|
|
|
|
<
<
<
<
<
<
<
|
|
|
|
|
|
<
>
|
|
|
<
|
>
|
|
>
>
>
|
<
<
<
<
<
<
<
<
<
<
<
|


91
92
93
94
95
96
97
98

99


100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132














133
134
135
136
137
138
139

140
141
142
143
144
145
146
147
148
149
150







151
152
153
154
155
156

157
158
159
160

161
162
163
164
165
166
167
168











169
170
171
}
</script>
</div>


<h1 align="center">List of SQLite Syntax Diagrams</h1>

<div class='columns' style='columns: 15em auto;'>

<ul style='padding-top:0;'>


<li><a href='syntax/aggregate-function-invocation.html'>aggregate-function-invocation</a></li>
<li><a href='syntax/alter-table-stmt.html'>alter-table-stmt</a></li>
<li><a href='syntax/analyze-stmt.html'>analyze-stmt</a></li>
<li><a href='syntax/attach-stmt.html'>attach-stmt</a></li>
<li><a href='syntax/begin-stmt.html'>begin-stmt</a></li>
<li><a href='syntax/column-constraint.html'>column-constraint</a></li>
<li><a href='syntax/column-def.html'>column-def</a></li>
<li><a href='syntax/column-name-list.html'>column-name-list</a></li>
<li><a href='syntax/comment-syntax.html'>comment-syntax</a></li>
<li><a href='syntax/commit-stmt.html'>commit-stmt</a></li>
<li><a href='syntax/common-table-expression.html'>common-table-expression</a></li>
<li><a href='syntax/compound-operator.html'>compound-operator</a></li>
<li><a href='syntax/compound-select-stmt.html'>compound-select-stmt</a></li>
<li><a href='syntax/conflict-clause.html'>conflict-clause</a></li>
<li><a href='syntax/create-index-stmt.html'>create-index-stmt</a></li>
<li><a href='syntax/create-table-stmt.html'>create-table-stmt</a></li>
<li><a href='syntax/create-trigger-stmt.html'>create-trigger-stmt</a></li>
<li><a href='syntax/create-view-stmt.html'>create-view-stmt</a></li>
<li><a href='syntax/create-virtual-table-stmt.html'>create-virtual-table-stmt</a></li>
<li><a href='syntax/cte-table-name.html'>cte-table-name</a></li>
<li><a href='syntax/delete-stmt.html'>delete-stmt</a></li>
<li><a href='syntax/delete-stmt-limited.html'>delete-stmt-limited</a></li>
<li><a href='syntax/detach-stmt.html'>detach-stmt</a></li>
<li><a href='syntax/drop-index-stmt.html'>drop-index-stmt</a></li>
<li><a href='syntax/drop-table-stmt.html'>drop-table-stmt</a></li>
<li><a href='syntax/drop-trigger-stmt.html'>drop-trigger-stmt</a></li>
<li><a href='syntax/drop-view-stmt.html'>drop-view-stmt</a></li>
<li><a href='syntax/expr.html'>expr</a></li>
<li><a href='syntax/factored-select-stmt.html'>factored-select-stmt</a></li>
<li><a href='syntax/filter-clause.html'>filter-clause</a></li>
<li><a href='syntax/foreign-key-clause.html'>foreign-key-clause</a></li>
<li><a href='syntax/frame-spec.html'>frame-spec</a></li>
<li><a href='syntax/indexed-column.html'>indexed-column</a></li>














<li><a href='syntax/insert-stmt.html'>insert-stmt</a></li>
<li><a href='syntax/join-clause.html'>join-clause</a></li>
<li><a href='syntax/join-constraint.html'>join-constraint</a></li>
<li><a href='syntax/join-operator.html'>join-operator</a></li>
<li><a href='syntax/literal-value.html'>literal-value</a></li>
<li><a href='syntax/numeric-literal.html'>numeric-literal</a></li>
<li><a href='syntax/ordering-term.html'>ordering-term</a></li>

<li><a href='syntax/over-clause.html'>over-clause</a></li>
<li><a href='syntax/pragma-stmt.html'>pragma-stmt</a></li>
<li><a href='syntax/pragma-value.html'>pragma-value</a></li>
<li><a href='syntax/qualified-table-name.html'>qualified-table-name</a></li>
<li><a href='syntax/raise-function.html'>raise-function</a></li>
<li><a href='syntax/recursive-cte.html'>recursive-cte</a></li>
<li><a href='syntax/reindex-stmt.html'>reindex-stmt</a></li>
<li><a href='syntax/release-stmt.html'>release-stmt</a></li>
<li><a href='syntax/result-column.html'>result-column</a></li>
<li><a href='syntax/rollback-stmt.html'>rollback-stmt</a></li>
<li><a href='syntax/savepoint-stmt.html'>savepoint-stmt</a></li>







<li><a href='syntax/select-core.html'>select-core</a></li>
<li><a href='syntax/select-stmt.html'>select-stmt</a></li>
<li><a href='syntax/signed-number.html'>signed-number</a></li>
<li><a href='syntax/simple-function-invocation.html'>simple-function-invocation</a></li>
<li><a href='syntax/simple-select-stmt.html'>simple-select-stmt</a></li>
<li><a href='syntax/sql-stmt.html'>sql-stmt</a></li>

<li><a href='syntax/sql-stmt-list.html'>sql-stmt-list</a></li>
<li><a href='syntax/table-constraint.html'>table-constraint</a></li>
<li><a href='syntax/table-or-subquery.html'>table-or-subquery</a></li>
<li><a href='syntax/type-name.html'>type-name</a></li>

<li><a href='syntax/update-stmt.html'>update-stmt</a></li>
<li><a href='syntax/update-stmt-limited.html'>update-stmt-limited</a></li>
<li><a href='syntax/upsert-clause.html'>upsert-clause</a></li>
<li><a href='syntax/vacuum-stmt.html'>vacuum-stmt</a></li>
<li><a href='syntax/window-defn.html'>window-defn</a></li>
<li><a href='syntax/window-function-invocation.html'>window-function-invocation</a></li>
<li><a href='syntax/with-clause.html'>with-clause</a></li>
</ul>











</div>


Changes to Doc/Extra/Core/syntax/alter-table-stmt.html.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
Changes to Doc/Extra/Core/syntax/analyze-stmt.html.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
Changes to Doc/Extra/Core/syntax/attach-stmt.html.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
Changes to Doc/Extra/Core/syntax/begin-stmt.html.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
Changes to Doc/Extra/Core/syntax/column-constraint.html.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
Changes to Doc/Extra/Core/syntax/column-def.html.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
Changes to Doc/Extra/Core/syntax/column-name-list.html.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
92
93
94
95
96
97
98
99
100
101
102
</script>
</div>
<h1 align='center'>column-name-list</h1>
<div class='imgcontainer'>
<img alt="syntax diagram column-name-list" src="../images/syntax/column-name-list.gif"></img><br>

Used by:&nbsp;&nbsp; <a href='./update-stmt.html'>update-stmt</a>&nbsp;&nbsp; <a href='./update-stmt-limited.html'>update-stmt-limited</a>&nbsp;&nbsp; <a href='./upsert-clause.html'>upsert-clause</a><br></br>
See also:&nbsp;&nbsp; <a href='../lang_UPSERT.html'>lang_UPSERT.html</a>&nbsp;&nbsp; <a href='../lang_createtrigger.html'>lang_createtrigger.html</a>&nbsp;&nbsp; <a href='../lang_insert.html'>lang_insert.html</a>&nbsp;&nbsp; <a href='../lang_update.html'>lang_update.html</a>
</div>









|



92
93
94
95
96
97
98
99
100
101
102
</script>
</div>
<h1 align='center'>column-name-list</h1>
<div class='imgcontainer'>
<img alt="syntax diagram column-name-list" src="../images/syntax/column-name-list.gif"></img><br>

Used by:&nbsp;&nbsp; <a href='./update-stmt.html'>update-stmt</a>&nbsp;&nbsp; <a href='./update-stmt-limited.html'>update-stmt-limited</a>&nbsp;&nbsp; <a href='./upsert-clause.html'>upsert-clause</a><br></br>
See also:&nbsp;&nbsp; <a href='../lang_createtrigger.html'>lang_createtrigger.html</a>&nbsp;&nbsp; <a href='../lang_insert.html'>lang_insert.html</a>&nbsp;&nbsp; <a href='../lang_update.html'>lang_update.html</a>&nbsp;&nbsp; <a href='../lang_upsert.html'>lang_upsert.html</a>
</div>


Changes to Doc/Extra/Core/syntax/comment-syntax.html.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
Changes to Doc/Extra/Core/syntax/commit-stmt.html.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
Changes to Doc/Extra/Core/syntax/common-table-expression.html.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
93
94
95
96
97
98
99
100
101
102
103
</div>
<h1 align='center'>common-table-expression</h1>
<div class='imgcontainer'>
<img alt="syntax diagram common-table-expression" src="../images/syntax/common-table-expression.gif"></img><br>

Used by:&nbsp;&nbsp; <a href='./compound-select-stmt.html'>compound-select-stmt</a>&nbsp;&nbsp; <a href='./factored-select-stmt.html'>factored-select-stmt</a>&nbsp;&nbsp; <a href='./select-stmt.html'>select-stmt</a>&nbsp;&nbsp; <a href='./simple-select-stmt.html'>simple-select-stmt</a><br></br>
References:&nbsp;&nbsp; <a href='./select-stmt.html'>select-stmt</a><br></br>
See also:&nbsp;&nbsp; <a href='../lang_UPSERT.html'>lang_UPSERT.html</a>&nbsp;&nbsp; <a href='../lang_aggfunc.html'>lang_aggfunc.html</a>&nbsp;&nbsp; <a href='../lang_altertable.html'>lang_altertable.html</a>&nbsp;&nbsp; <a href='../lang_attach.html'>lang_attach.html</a>&nbsp;&nbsp; <a href='../lang_createindex.html'>lang_createindex.html</a>&nbsp;&nbsp; <a href='../lang_createtable.html'>lang_createtable.html</a>&nbsp;&nbsp; <a href='../lang_createtrigger.html'>lang_createtrigger.html</a>&nbsp;&nbsp; <a href='../lang_createview.html'>lang_createview.html</a>&nbsp;&nbsp; <a href='../lang_delete.html'>lang_delete.html</a>&nbsp;&nbsp; <a href='../lang_expr.html'>lang_expr.html</a>&nbsp;&nbsp; <a href='../lang_insert.html'>lang_insert.html</a>&nbsp;&nbsp; <a href='../lang_select.html'>lang_select.html</a>&nbsp;&nbsp; <a href='../lang_update.html'>lang_update.html</a>&nbsp;&nbsp; <a href='../lang_with.html'>lang_with.html</a>&nbsp;&nbsp; <a href='../partialindex.html'>partialindex.html</a>
</div>









|



93
94
95
96
97
98
99
100
101
102
103
</div>
<h1 align='center'>common-table-expression</h1>
<div class='imgcontainer'>
<img alt="syntax diagram common-table-expression" src="../images/syntax/common-table-expression.gif"></img><br>

Used by:&nbsp;&nbsp; <a href='./compound-select-stmt.html'>compound-select-stmt</a>&nbsp;&nbsp; <a href='./factored-select-stmt.html'>factored-select-stmt</a>&nbsp;&nbsp; <a href='./select-stmt.html'>select-stmt</a>&nbsp;&nbsp; <a href='./simple-select-stmt.html'>simple-select-stmt</a><br></br>
References:&nbsp;&nbsp; <a href='./select-stmt.html'>select-stmt</a><br></br>
See also:&nbsp;&nbsp; <a href='../lang_aggfunc.html'>lang_aggfunc.html</a>&nbsp;&nbsp; <a href='../lang_altertable.html'>lang_altertable.html</a>&nbsp;&nbsp; <a href='../lang_attach.html'>lang_attach.html</a>&nbsp;&nbsp; <a href='../lang_createindex.html'>lang_createindex.html</a>&nbsp;&nbsp; <a href='../lang_createtable.html'>lang_createtable.html</a>&nbsp;&nbsp; <a href='../lang_createtrigger.html'>lang_createtrigger.html</a>&nbsp;&nbsp; <a href='../lang_createview.html'>lang_createview.html</a>&nbsp;&nbsp; <a href='../lang_delete.html'>lang_delete.html</a>&nbsp;&nbsp; <a href='../lang_expr.html'>lang_expr.html</a>&nbsp;&nbsp; <a href='../lang_insert.html'>lang_insert.html</a>&nbsp;&nbsp; <a href='../lang_select.html'>lang_select.html</a>&nbsp;&nbsp; <a href='../lang_update.html'>lang_update.html</a>&nbsp;&nbsp; <a href='../lang_upsert.html'>lang_upsert.html</a>&nbsp;&nbsp; <a href='../lang_with.html'>lang_with.html</a>&nbsp;&nbsp; <a href='../partialindex.html'>partialindex.html</a>
</div>


Changes to Doc/Extra/Core/syntax/compound-operator.html.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
92
93
94
95
96
97
98
99
100
101
102
</script>
</div>
<h1 align='center'>compound-operator</h1>
<div class='imgcontainer'>
<img alt="syntax diagram compound-operator" src="../images/syntax/compound-operator.gif"></img><br>

Used by:&nbsp;&nbsp; <a href='./factored-select-stmt.html'>factored-select-stmt</a>&nbsp;&nbsp; <a href='./select-stmt.html'>select-stmt</a><br></br>
See also:&nbsp;&nbsp; <a href='../lang_UPSERT.html'>lang_UPSERT.html</a>&nbsp;&nbsp; <a href='../lang_aggfunc.html'>lang_aggfunc.html</a>&nbsp;&nbsp; <a href='../lang_altertable.html'>lang_altertable.html</a>&nbsp;&nbsp; <a href='../lang_attach.html'>lang_attach.html</a>&nbsp;&nbsp; <a href='../lang_createindex.html'>lang_createindex.html</a>&nbsp;&nbsp; <a href='../lang_createtable.html'>lang_createtable.html</a>&nbsp;&nbsp; <a href='../lang_createtrigger.html'>lang_createtrigger.html</a>&nbsp;&nbsp; <a href='../lang_createview.html'>lang_createview.html</a>&nbsp;&nbsp; <a href='../lang_delete.html'>lang_delete.html</a>&nbsp;&nbsp; <a href='../lang_expr.html'>lang_expr.html</a>&nbsp;&nbsp; <a href='../lang_insert.html'>lang_insert.html</a>&nbsp;&nbsp; <a href='../lang_select.html'>lang_select.html</a>&nbsp;&nbsp; <a href='../lang_update.html'>lang_update.html</a>&nbsp;&nbsp; <a href='../lang_with.html'>lang_with.html</a>&nbsp;&nbsp; <a href='../partialindex.html'>partialindex.html</a>
</div>









|



92
93
94
95
96
97
98
99
100
101
102
</script>
</div>
<h1 align='center'>compound-operator</h1>
<div class='imgcontainer'>
<img alt="syntax diagram compound-operator" src="../images/syntax/compound-operator.gif"></img><br>

Used by:&nbsp;&nbsp; <a href='./factored-select-stmt.html'>factored-select-stmt</a>&nbsp;&nbsp; <a href='./select-stmt.html'>select-stmt</a><br></br>
See also:&nbsp;&nbsp; <a href='../lang_aggfunc.html'>lang_aggfunc.html</a>&nbsp;&nbsp; <a href='../lang_altertable.html'>lang_altertable.html</a>&nbsp;&nbsp; <a href='../lang_attach.html'>lang_attach.html</a>&nbsp;&nbsp; <a href='../lang_createindex.html'>lang_createindex.html</a>&nbsp;&nbsp; <a href='../lang_createtable.html'>lang_createtable.html</a>&nbsp;&nbsp; <a href='../lang_createtrigger.html'>lang_createtrigger.html</a>&nbsp;&nbsp; <a href='../lang_createview.html'>lang_createview.html</a>&nbsp;&nbsp; <a href='../lang_delete.html'>lang_delete.html</a>&nbsp;&nbsp; <a href='../lang_expr.html'>lang_expr.html</a>&nbsp;&nbsp; <a href='../lang_insert.html'>lang_insert.html</a>&nbsp;&nbsp; <a href='../lang_select.html'>lang_select.html</a>&nbsp;&nbsp; <a href='../lang_update.html'>lang_update.html</a>&nbsp;&nbsp; <a href='../lang_upsert.html'>lang_upsert.html</a>&nbsp;&nbsp; <a href='../lang_with.html'>lang_with.html</a>&nbsp;&nbsp; <a href='../partialindex.html'>partialindex.html</a>
</div>


Changes to Doc/Extra/Core/syntax/compound-select-stmt.html.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
Changes to Doc/Extra/Core/syntax/conflict-clause.html.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
Changes to Doc/Extra/Core/syntax/create-index-stmt.html.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
Changes to Doc/Extra/Core/syntax/create-table-stmt.html.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
Changes to Doc/Extra/Core/syntax/create-trigger-stmt.html.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
Changes to Doc/Extra/Core/syntax/create-view-stmt.html.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
Changes to Doc/Extra/Core/syntax/create-virtual-table-stmt.html.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
Changes to Doc/Extra/Core/syntax/cte-table-name.html.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
Changes to Doc/Extra/Core/syntax/delete-stmt-limited.html.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
Changes to Doc/Extra/Core/syntax/delete-stmt.html.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
Changes to Doc/Extra/Core/syntax/detach-stmt.html.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
Changes to Doc/Extra/Core/syntax/drop-index-stmt.html.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
Changes to Doc/Extra/Core/syntax/drop-table-stmt.html.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
Changes to Doc/Extra/Core/syntax/drop-trigger-stmt.html.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
Changes to Doc/Extra/Core/syntax/drop-view-stmt.html.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
Changes to Doc/Extra/Core/syntax/expr.html.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
93
94
95
96
97
98
99
100
101
102
103
</div>
<h1 align='center'>expr</h1>
<div class='imgcontainer'>
<img alt="syntax diagram expr" src="../images/syntax/expr.gif"></img><br>

Used by:&nbsp;&nbsp; <a href='./aggregate-function-invocation.html'>aggregate-function-invocation</a>&nbsp;&nbsp; <a href='./attach-stmt.html'>attach-stmt</a>&nbsp;&nbsp; <a href='./column-constraint.html'>column-constraint</a>&nbsp;&nbsp; <a href='./compound-select-stmt.html'>compound-select-stmt</a>&nbsp;&nbsp; <a href='./create-index-stmt.html'>create-index-stmt</a>&nbsp;&nbsp; <a href='./create-trigger-stmt.html'>create-trigger-stmt</a>&nbsp;&nbsp; <a href='./delete-stmt.html'>delete-stmt</a>&nbsp;&nbsp; <a href='./delete-stmt-limited.html'>delete-stmt-limited</a>&nbsp;&nbsp; <a href='./factored-select-stmt.html'>factored-select-stmt</a>&nbsp;&nbsp; <a href='./filter-clause.html'>filter-clause</a>&nbsp;&nbsp; <a href='./frame-spec.html'>frame-spec</a>&nbsp;&nbsp; <a href='./indexed-column.html'>indexed-column</a>&nbsp;&nbsp; <a href='./insert-stmt.html'>insert-stmt</a>&nbsp;&nbsp; <a href='./join-constraint.html'>join-constraint</a>&nbsp;&nbsp; <a href='./ordering-term.html'>ordering-term</a>&nbsp;&nbsp; <a href='./over-clause.html'>over-clause</a>&nbsp;&nbsp; <a href='./result-column.html'>result-column</a>&nbsp;&nbsp; <a href='./select-core.html'>select-core</a>&nbsp;&nbsp; <a href='./select-stmt.html'>select-stmt</a>&nbsp;&nbsp; <a href='./simple-function-invocation.html'>simple-function-invocation</a>&nbsp;&nbsp; <a href='./simple-select-stmt.html'>simple-select-stmt</a>&nbsp;&nbsp; <a href='./table-constraint.html'>table-constraint</a>&nbsp;&nbsp; <a href='./table-or-subquery.html'>table-or-subquery</a>&nbsp;&nbsp; <a href='./update-stmt.html'>update-stmt</a>&nbsp;&nbsp; <a href='./update-stmt-limited.html'>update-stmt-limited</a>&nbsp;&nbsp; <a href='./upsert-clause.html'>upsert-clause</a>&nbsp;&nbsp; <a href='./window-defn.html'>window-defn</a>&nbsp;&nbsp; <a href='./window-function-invocation.html'>window-function-invocation</a><br></br>
References:&nbsp;&nbsp; <a href='./filter-clause.html'>filter-clause</a>&nbsp;&nbsp; <a href='./literal-value.html'>literal-value</a>&nbsp;&nbsp; <a href='./over-clause.html'>over-clause</a>&nbsp;&nbsp; <a href='./raise-function.html'>raise-function</a>&nbsp;&nbsp; <a href='./select-stmt.html'>select-stmt</a>&nbsp;&nbsp; <a href='./type-name.html'>type-name</a><br></br>
See also:&nbsp;&nbsp; <a href='../lang_UPSERT.html'>lang_UPSERT.html</a>&nbsp;&nbsp; <a href='../lang_aggfunc.html'>lang_aggfunc.html</a>&nbsp;&nbsp; <a href='../lang_altertable.html'>lang_altertable.html</a>&nbsp;&nbsp; <a href='../lang_attach.html'>lang_attach.html</a>&nbsp;&nbsp; <a href='../lang_createindex.html'>lang_createindex.html</a>&nbsp;&nbsp; <a href='../lang_createtable.html'>lang_createtable.html</a>&nbsp;&nbsp; <a href='../lang_createtrigger.html'>lang_createtrigger.html</a>&nbsp;&nbsp; <a href='../lang_createview.html'>lang_createview.html</a>&nbsp;&nbsp; <a href='../lang_delete.html'>lang_delete.html</a>&nbsp;&nbsp; <a href='../lang_expr.html'>lang_expr.html</a>&nbsp;&nbsp; <a href='../lang_insert.html'>lang_insert.html</a>&nbsp;&nbsp; <a href='../lang_select.html'>lang_select.html</a>&nbsp;&nbsp; <a href='../lang_update.html'>lang_update.html</a>&nbsp;&nbsp; <a href='../lang_with.html'>lang_with.html</a>&nbsp;&nbsp; <a href='../partialindex.html'>partialindex.html</a>
</div>









|



93
94
95
96
97
98
99
100
101
102
103
</div>
<h1 align='center'>expr</h1>
<div class='imgcontainer'>
<img alt="syntax diagram expr" src="../images/syntax/expr.gif"></img><br>

Used by:&nbsp;&nbsp; <a href='./aggregate-function-invocation.html'>aggregate-function-invocation</a>&nbsp;&nbsp; <a href='./attach-stmt.html'>attach-stmt</a>&nbsp;&nbsp; <a href='./column-constraint.html'>column-constraint</a>&nbsp;&nbsp; <a href='./compound-select-stmt.html'>compound-select-stmt</a>&nbsp;&nbsp; <a href='./create-index-stmt.html'>create-index-stmt</a>&nbsp;&nbsp; <a href='./create-trigger-stmt.html'>create-trigger-stmt</a>&nbsp;&nbsp; <a href='./delete-stmt.html'>delete-stmt</a>&nbsp;&nbsp; <a href='./delete-stmt-limited.html'>delete-stmt-limited</a>&nbsp;&nbsp; <a href='./factored-select-stmt.html'>factored-select-stmt</a>&nbsp;&nbsp; <a href='./filter-clause.html'>filter-clause</a>&nbsp;&nbsp; <a href='./frame-spec.html'>frame-spec</a>&nbsp;&nbsp; <a href='./indexed-column.html'>indexed-column</a>&nbsp;&nbsp; <a href='./insert-stmt.html'>insert-stmt</a>&nbsp;&nbsp; <a href='./join-constraint.html'>join-constraint</a>&nbsp;&nbsp; <a href='./ordering-term.html'>ordering-term</a>&nbsp;&nbsp; <a href='./over-clause.html'>over-clause</a>&nbsp;&nbsp; <a href='./result-column.html'>result-column</a>&nbsp;&nbsp; <a href='./select-core.html'>select-core</a>&nbsp;&nbsp; <a href='./select-stmt.html'>select-stmt</a>&nbsp;&nbsp; <a href='./simple-function-invocation.html'>simple-function-invocation</a>&nbsp;&nbsp; <a href='./simple-select-stmt.html'>simple-select-stmt</a>&nbsp;&nbsp; <a href='./table-constraint.html'>table-constraint</a>&nbsp;&nbsp; <a href='./table-or-subquery.html'>table-or-subquery</a>&nbsp;&nbsp; <a href='./update-stmt.html'>update-stmt</a>&nbsp;&nbsp; <a href='./update-stmt-limited.html'>update-stmt-limited</a>&nbsp;&nbsp; <a href='./upsert-clause.html'>upsert-clause</a>&nbsp;&nbsp; <a href='./window-defn.html'>window-defn</a>&nbsp;&nbsp; <a href='./window-function-invocation.html'>window-function-invocation</a><br></br>
References:&nbsp;&nbsp; <a href='./filter-clause.html'>filter-clause</a>&nbsp;&nbsp; <a href='./literal-value.html'>literal-value</a>&nbsp;&nbsp; <a href='./over-clause.html'>over-clause</a>&nbsp;&nbsp; <a href='./raise-function.html'>raise-function</a>&nbsp;&nbsp; <a href='./select-stmt.html'>select-stmt</a>&nbsp;&nbsp; <a href='./type-name.html'>type-name</a><br></br>
See also:&nbsp;&nbsp; <a href='../lang_aggfunc.html'>lang_aggfunc.html</a>&nbsp;&nbsp; <a href='../lang_altertable.html'>lang_altertable.html</a>&nbsp;&nbsp; <a href='../lang_attach.html'>lang_attach.html</a>&nbsp;&nbsp; <a href='../lang_createindex.html'>lang_createindex.html</a>&nbsp;&nbsp; <a href='../lang_createtable.html'>lang_createtable.html</a>&nbsp;&nbsp; <a href='../lang_createtrigger.html'>lang_createtrigger.html</a>&nbsp;&nbsp; <a href='../lang_createview.html'>lang_createview.html</a>&nbsp;&nbsp; <a href='../lang_delete.html'>lang_delete.html</a>&nbsp;&nbsp; <a href='../lang_expr.html'>lang_expr.html</a>&nbsp;&nbsp; <a href='../lang_insert.html'>lang_insert.html</a>&nbsp;&nbsp; <a href='../lang_select.html'>lang_select.html</a>&nbsp;&nbsp; <a href='../lang_update.html'>lang_update.html</a>&nbsp;&nbsp; <a href='../lang_upsert.html'>lang_upsert.html</a>&nbsp;&nbsp; <a href='../lang_with.html'>lang_with.html</a>&nbsp;&nbsp; <a href='../partialindex.html'>partialindex.html</a>
</div>


Changes to Doc/Extra/Core/syntax/factored-select-stmt.html.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
Changes to Doc/Extra/Core/syntax/foreign-key-clause.html.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
Changes to Doc/Extra/Core/syntax/indexed-column.html.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
93
94
95
96
97
98
99
100
101
102
103
</div>
<h1 align='center'>indexed-column</h1>
<div class='imgcontainer'>
<img alt="syntax diagram indexed-column" src="../images/syntax/indexed-column.gif"></img><br>

Used by:&nbsp;&nbsp; <a href='./create-index-stmt.html'>create-index-stmt</a>&nbsp;&nbsp; <a href='./table-constraint.html'>table-constraint</a>&nbsp;&nbsp; <a href='./upsert-clause.html'>upsert-clause</a><br></br>
References:&nbsp;&nbsp; <a href='./expr.html'>expr</a><br></br>
See also:&nbsp;&nbsp; <a href='../lang_UPSERT.html'>lang_UPSERT.html</a>&nbsp;&nbsp; <a href='../lang_createindex.html'>lang_createindex.html</a>&nbsp;&nbsp; <a href='../lang_createtable.html'>lang_createtable.html</a>&nbsp;&nbsp; <a href='../lang_createtrigger.html'>lang_createtrigger.html</a>&nbsp;&nbsp; <a href='../lang_insert.html'>lang_insert.html</a>&nbsp;&nbsp; <a href='../partialindex.html'>partialindex.html</a>
</div>









|



93
94
95
96
97
98
99
100
101
102
103
</div>
<h1 align='center'>indexed-column</h1>
<div class='imgcontainer'>
<img alt="syntax diagram indexed-column" src="../images/syntax/indexed-column.gif"></img><br>

Used by:&nbsp;&nbsp; <a href='./create-index-stmt.html'>create-index-stmt</a>&nbsp;&nbsp; <a href='./table-constraint.html'>table-constraint</a>&nbsp;&nbsp; <a href='./upsert-clause.html'>upsert-clause</a><br></br>
References:&nbsp;&nbsp; <a href='./expr.html'>expr</a><br></br>
See also:&nbsp;&nbsp; <a href='../lang_createindex.html'>lang_createindex.html</a>&nbsp;&nbsp; <a href='../lang_createtable.html'>lang_createtable.html</a>&nbsp;&nbsp; <a href='../lang_createtrigger.html'>lang_createtrigger.html</a>&nbsp;&nbsp; <a href='../lang_insert.html'>lang_insert.html</a>&nbsp;&nbsp; <a href='../lang_upsert.html'>lang_upsert.html</a>&nbsp;&nbsp; <a href='../partialindex.html'>partialindex.html</a>
</div>


Changes to Doc/Extra/Core/syntax/insert-stmt.html.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
Changes to Doc/Extra/Core/syntax/join-clause.html.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
93
94
95
96
97
98
99
100
101
102
103
</div>
<h1 align='center'>join-clause</h1>
<div class='imgcontainer'>
<img alt="syntax diagram join-clause" src="../images/syntax/join-clause.gif"></img><br>

Used by:&nbsp;&nbsp; <a href='./select-core.html'>select-core</a>&nbsp;&nbsp; <a href='./select-stmt.html'>select-stmt</a>&nbsp;&nbsp; <a href='./table-or-subquery.html'>table-or-subquery</a><br></br>
References:&nbsp;&nbsp; <a href='./join-constraint.html'>join-constraint</a>&nbsp;&nbsp; <a href='./join-operator.html'>join-operator</a>&nbsp;&nbsp; <a href='./table-or-subquery.html'>table-or-subquery</a><br></br>
See also:&nbsp;&nbsp; <a href='../lang_UPSERT.html'>lang_UPSERT.html</a>&nbsp;&nbsp; <a href='../lang_aggfunc.html'>lang_aggfunc.html</a>&nbsp;&nbsp; <a href='../lang_altertable.html'>lang_altertable.html</a>&nbsp;&nbsp; <a href='../lang_attach.html'>lang_attach.html</a>&nbsp;&nbsp; <a href='../lang_createindex.html'>lang_createindex.html</a>&nbsp;&nbsp; <a href='../lang_createtable.html'>lang_createtable.html</a>&nbsp;&nbsp; <a href='../lang_createtrigger.html'>lang_createtrigger.html</a>&nbsp;&nbsp; <a href='../lang_createview.html'>lang_createview.html</a>&nbsp;&nbsp; <a href='../lang_delete.html'>lang_delete.html</a>&nbsp;&nbsp; <a href='../lang_expr.html'>lang_expr.html</a>&nbsp;&nbsp; <a href='../lang_insert.html'>lang_insert.html</a>&nbsp;&nbsp; <a href='../lang_select.html'>lang_select.html</a>&nbsp;&nbsp; <a href='../lang_update.html'>lang_update.html</a>&nbsp;&nbsp; <a href='../lang_with.html'>lang_with.html</a>&nbsp;&nbsp; <a href='../partialindex.html'>partialindex.html</a>
</div>









|



93
94
95
96
97
98
99
100
101
102
103
</div>
<h1 align='center'>join-clause</h1>
<div class='imgcontainer'>
<img alt="syntax diagram join-clause" src="../images/syntax/join-clause.gif"></img><br>

Used by:&nbsp;&nbsp; <a href='./select-core.html'>select-core</a>&nbsp;&nbsp; <a href='./select-stmt.html'>select-stmt</a>&nbsp;&nbsp; <a href='./table-or-subquery.html'>table-or-subquery</a><br></br>
References:&nbsp;&nbsp; <a href='./join-constraint.html'>join-constraint</a>&nbsp;&nbsp; <a href='./join-operator.html'>join-operator</a>&nbsp;&nbsp; <a href='./table-or-subquery.html'>table-or-subquery</a><br></br>
See also:&nbsp;&nbsp; <a href='../lang_aggfunc.html'>lang_aggfunc.html</a>&nbsp;&nbsp; <a href='../lang_altertable.html'>lang_altertable.html</a>&nbsp;&nbsp; <a href='../lang_attach.html'>lang_attach.html</a>&nbsp;&nbsp; <a href='../lang_createindex.html'>lang_createindex.html</a>&nbsp;&nbsp; <a href='../lang_createtable.html'>lang_createtable.html</a>&nbsp;&nbsp; <a href='../lang_createtrigger.html'>lang_createtrigger.html</a>&nbsp;&nbsp; <a href='../lang_createview.html'>lang_createview.html</a>&nbsp;&nbsp; <a href='../lang_delete.html'>lang_delete.html</a>&nbsp;&nbsp; <a href='../lang_expr.html'>lang_expr.html</a>&nbsp;&nbsp; <a href='../lang_insert.html'>lang_insert.html</a>&nbsp;&nbsp; <a href='../lang_select.html'>lang_select.html</a>&nbsp;&nbsp; <a href='../lang_update.html'>lang_update.html</a>&nbsp;&nbsp; <a href='../lang_upsert.html'>lang_upsert.html</a>&nbsp;&nbsp; <a href='../lang_with.html'>lang_with.html</a>&nbsp;&nbsp; <a href='../partialindex.html'>partialindex.html</a>
</div>


Changes to Doc/Extra/Core/syntax/join-constraint.html.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
93
94
95
96
97
98
99
100
101
102
103
</div>
<h1 align='center'>join-constraint</h1>
<div class='imgcontainer'>
<img alt="syntax diagram join-constraint" src="../images/syntax/join-constraint.gif"></img><br>

Used by:&nbsp;&nbsp; <a href='./join-clause.html'>join-clause</a><br></br>
References:&nbsp;&nbsp; <a href='./expr.html'>expr</a><br></br>
See also:&nbsp;&nbsp; <a href='../lang_UPSERT.html'>lang_UPSERT.html</a>&nbsp;&nbsp; <a href='../lang_aggfunc.html'>lang_aggfunc.html</a>&nbsp;&nbsp; <a href='../lang_altertable.html'>lang_altertable.html</a>&nbsp;&nbsp; <a href='../lang_attach.html'>lang_attach.html</a>&nbsp;&nbsp; <a href='../lang_createindex.html'>lang_createindex.html</a>&nbsp;&nbsp; <a href='../lang_createtable.html'>lang_createtable.html</a>&nbsp;&nbsp; <a href='../lang_createtrigger.html'>lang_createtrigger.html</a>&nbsp;&nbsp; <a href='../lang_createview.html'>lang_createview.html</a>&nbsp;&nbsp; <a href='../lang_delete.html'>lang_delete.html</a>&nbsp;&nbsp; <a href='../lang_expr.html'>lang_expr.html</a>&nbsp;&nbsp; <a href='../lang_insert.html'>lang_insert.html</a>&nbsp;&nbsp; <a href='../lang_select.html'>lang_select.html</a>&nbsp;&nbsp; <a href='../lang_update.html'>lang_update.html</a>&nbsp;&nbsp; <a href='../lang_with.html'>lang_with.html</a>&nbsp;&nbsp; <a href='../partialindex.html'>partialindex.html</a>
</div>









|



93
94
95
96
97
98
99
100
101
102
103
</div>
<h1 align='center'>join-constraint</h1>
<div class='imgcontainer'>
<img alt="syntax diagram join-constraint" src="../images/syntax/join-constraint.gif"></img><br>

Used by:&nbsp;&nbsp; <a href='./join-clause.html'>join-clause</a><br></br>
References:&nbsp;&nbsp; <a href='./expr.html'>expr</a><br></br>
See also:&nbsp;&nbsp; <a href='../lang_aggfunc.html'>lang_aggfunc.html</a>&nbsp;&nbsp; <a href='../lang_altertable.html'>lang_altertable.html</a>&nbsp;&nbsp; <a href='../lang_attach.html'>lang_attach.html</a>&nbsp;&nbsp; <a href='../lang_createindex.html'>lang_createindex.html</a>&nbsp;&nbsp; <a href='../lang_createtable.html'>lang_createtable.html</a>&nbsp;&nbsp; <a href='../lang_createtrigger.html'>lang_createtrigger.html</a>&nbsp;&nbsp; <a href='../lang_createview.html'>lang_createview.html</a>&nbsp;&nbsp; <a href='../lang_delete.html'>lang_delete.html</a>&nbsp;&nbsp; <a href='../lang_expr.html'>lang_expr.html</a>&nbsp;&nbsp; <a href='../lang_insert.html'>lang_insert.html</a>&nbsp;&nbsp; <a href='../lang_select.html'>lang_select.html</a>&nbsp;&nbsp; <a href='../lang_update.html'>lang_update.html</a>&nbsp;&nbsp; <a href='../lang_upsert.html'>lang_upsert.html</a>&nbsp;&nbsp; <a href='../lang_with.html'>lang_with.html</a>&nbsp;&nbsp; <a href='../partialindex.html'>partialindex.html</a>
</div>


Changes to Doc/Extra/Core/syntax/join-operator.html.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
92
93
94
95
96
97
98
99
100
101
102
</script>
</div>
<h1 align='center'>join-operator</h1>
<div class='imgcontainer'>
<img alt="syntax diagram join-operator" src="../images/syntax/join-operator.gif"></img><br>

Used by:&nbsp;&nbsp; <a href='./join-clause.html'>join-clause</a><br></br>
See also:&nbsp;&nbsp; <a href='../lang_UPSERT.html'>lang_UPSERT.html</a>&nbsp;&nbsp; <a href='../lang_aggfunc.html'>lang_aggfunc.html</a>&nbsp;&nbsp; <a href='../lang_altertable.html'>lang_altertable.html</a>&nbsp;&nbsp; <a href='../lang_attach.html'>lang_attach.html</a>&nbsp;&nbsp; <a href='../lang_createindex.html'>lang_createindex.html</a>&nbsp;&nbsp; <a href='../lang_createtable.html'>lang_createtable.html</a>&nbsp;&nbsp; <a href='../lang_createtrigger.html'>lang_createtrigger.html</a>&nbsp;&nbsp; <a href='../lang_createview.html'>lang_createview.html</a>&nbsp;&nbsp; <a href='../lang_delete.html'>lang_delete.html</a>&nbsp;&nbsp; <a href='../lang_expr.html'>lang_expr.html</a>&nbsp;&nbsp; <a href='../lang_insert.html'>lang_insert.html</a>&nbsp;&nbsp; <a href='../lang_select.html'>lang_select.html</a>&nbsp;&nbsp; <a href='../lang_update.html'>lang_update.html</a>&nbsp;&nbsp; <a href='../lang_with.html'>lang_with.html</a>&nbsp;&nbsp; <a href='../partialindex.html'>partialindex.html</a>
</div>









|



92
93
94
95
96
97
98
99
100
101
102
</script>
</div>
<h1 align='center'>join-operator</h1>
<div class='imgcontainer'>
<img alt="syntax diagram join-operator" src="../images/syntax/join-operator.gif"></img><br>

Used by:&nbsp;&nbsp; <a href='./join-clause.html'>join-clause</a><br></br>
See also:&nbsp;&nbsp; <a href='../lang_aggfunc.html'>lang_aggfunc.html</a>&nbsp;&nbsp; <a href='../lang_altertable.html'>lang_altertable.html</a>&nbsp;&nbsp; <a href='../lang_attach.html'>lang_attach.html</a>&nbsp;&nbsp; <a href='../lang_createindex.html'>lang_createindex.html</a>&nbsp;&nbsp; <a href='../lang_createtable.html'>lang_createtable.html</a>&nbsp;&nbsp; <a href='../lang_createtrigger.html'>lang_createtrigger.html</a>&nbsp;&nbsp; <a href='../lang_createview.html'>lang_createview.html</a>&nbsp;&nbsp; <a href='../lang_delete.html'>lang_delete.html</a>&nbsp;&nbsp; <a href='../lang_expr.html'>lang_expr.html</a>&nbsp;&nbsp; <a href='../lang_insert.html'>lang_insert.html</a>&nbsp;&nbsp; <a href='../lang_select.html'>lang_select.html</a>&nbsp;&nbsp; <a href='../lang_update.html'>lang_update.html</a>&nbsp;&nbsp; <a href='../lang_upsert.html'>lang_upsert.html</a>&nbsp;&nbsp; <a href='../lang_with.html'>lang_with.html</a>&nbsp;&nbsp; <a href='../partialindex.html'>partialindex.html</a>
</div>


Changes to Doc/Extra/Core/syntax/literal-value.html.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
92
93
94
95
96
97
98
99
100
101
102
</script>
</div>
<h1 align='center'>literal-value</h1>
<div class='imgcontainer'>
<img alt="syntax diagram literal-value" src="../images/syntax/literal-value.gif"></img><br>

Used by:&nbsp;&nbsp; <a href='./column-constraint.html'>column-constraint</a>&nbsp;&nbsp; <a href='./expr.html'>expr</a><br></br>
See also:&nbsp;&nbsp; <a href='../lang_UPSERT.html'>lang_UPSERT.html</a>&nbsp;&nbsp; <a href='../lang_aggfunc.html'>lang_aggfunc.html</a>&nbsp;&nbsp; <a href='../lang_altertable.html'>lang_altertable.html</a>&nbsp;&nbsp; <a href='../lang_attach.html'>lang_attach.html</a>&nbsp;&nbsp; <a href='../lang_createindex.html'>lang_createindex.html</a>&nbsp;&nbsp; <a href='../lang_createtable.html'>lang_createtable.html</a>&nbsp;&nbsp; <a href='../lang_createtrigger.html'>lang_createtrigger.html</a>&nbsp;&nbsp; <a href='../lang_createview.html'>lang_createview.html</a>&nbsp;&nbsp; <a href='../lang_delete.html'>lang_delete.html</a>&nbsp;&nbsp; <a href='../lang_expr.html'>lang_expr.html</a>&nbsp;&nbsp; <a href='../lang_insert.html'>lang_insert.html</a>&nbsp;&nbsp; <a href='../lang_select.html'>lang_select.html</a>&nbsp;&nbsp; <a href='../lang_update.html'>lang_update.html</a>&nbsp;&nbsp; <a href='../lang_with.html'>lang_with.html</a>&nbsp;&nbsp; <a href='../partialindex.html'>partialindex.html</a>
</div>









|



92
93
94
95
96
97
98
99
100
101
102
</script>
</div>
<h1 align='center'>literal-value</h1>
<div class='imgcontainer'>
<img alt="syntax diagram literal-value" src="../images/syntax/literal-value.gif"></img><br>

Used by:&nbsp;&nbsp; <a href='./column-constraint.html'>column-constraint</a>&nbsp;&nbsp; <a href='./expr.html'>expr</a><br></br>
See also:&nbsp;&nbsp; <a href='../lang_aggfunc.html'>lang_aggfunc.html</a>&nbsp;&nbsp; <a href='../lang_altertable.html'>lang_altertable.html</a>&nbsp;&nbsp; <a href='../lang_attach.html'>lang_attach.html</a>&nbsp;&nbsp; <a href='../lang_createindex.html'>lang_createindex.html</a>&nbsp;&nbsp; <a href='../lang_createtable.html'>lang_createtable.html</a>&nbsp;&nbsp; <a href='../lang_createtrigger.html'>lang_createtrigger.html</a>&nbsp;&nbsp; <a href='../lang_createview.html'>lang_createview.html</a>&nbsp;&nbsp; <a href='../lang_delete.html'>lang_delete.html</a>&nbsp;&nbsp; <a href='../lang_expr.html'>lang_expr.html</a>&nbsp;&nbsp; <a href='../lang_insert.html'>lang_insert.html</a>&nbsp;&nbsp; <a href='../lang_select.html'>lang_select.html</a>&nbsp;&nbsp; <a href='../lang_update.html'>lang_update.html</a>&nbsp;&nbsp; <a href='../lang_upsert.html'>lang_upsert.html</a>&nbsp;&nbsp; <a href='../lang_with.html'>lang_with.html</a>&nbsp;&nbsp; <a href='../partialindex.html'>partialindex.html</a>
</div>


Changes to Doc/Extra/Core/syntax/numeric-literal.html.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
Changes to Doc/Extra/Core/syntax/ordering-term.html.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
93
94
95
96
97
98
99
100
101
102
103
</div>
<h1 align='center'>ordering-term</h1>
<div class='imgcontainer'>
<img alt="syntax diagram ordering-term" src="../images/syntax/ordering-term.gif"></img><br>

Used by:&nbsp;&nbsp; <a href='./compound-select-stmt.html'>compound-select-stmt</a>&nbsp;&nbsp; <a href='./delete-stmt-limited.html'>delete-stmt-limited</a>&nbsp;&nbsp; <a href='./factored-select-stmt.html'>factored-select-stmt</a>&nbsp;&nbsp; <a href='./over-clause.html'>over-clause</a>&nbsp;&nbsp; <a href='./select-stmt.html'>select-stmt</a>&nbsp;&nbsp; <a href='./simple-select-stmt.html'>simple-select-stmt</a>&nbsp;&nbsp; <a href='./update-stmt-limited.html'>update-stmt-limited</a>&nbsp;&nbsp; <a href='./window-defn.html'>window-defn</a><br></br>
References:&nbsp;&nbsp; <a href='./expr.html'>expr</a><br></br>
See also:&nbsp;&nbsp; <a href='../lang_UPSERT.html'>lang_UPSERT.html</a>&nbsp;&nbsp; <a href='../lang_aggfunc.html'>lang_aggfunc.html</a>&nbsp;&nbsp; <a href='../lang_altertable.html'>lang_altertable.html</a>&nbsp;&nbsp; <a href='../lang_attach.html'>lang_attach.html</a>&nbsp;&nbsp; <a href='../lang_createindex.html'>lang_createindex.html</a>&nbsp;&nbsp; <a href='../lang_createtable.html'>lang_createtable.html</a>&nbsp;&nbsp; <a href='../lang_createtrigger.html'>lang_createtrigger.html</a>&nbsp;&nbsp; <a href='../lang_createview.html'>lang_createview.html</a>&nbsp;&nbsp; <a href='../lang_delete.html'>lang_delete.html</a>&nbsp;&nbsp; <a href='../lang_expr.html'>lang_expr.html</a>&nbsp;&nbsp; <a href='../lang_insert.html'>lang_insert.html</a>&nbsp;&nbsp; <a href='../lang_select.html'>lang_select.html</a>&nbsp;&nbsp; <a href='../lang_update.html'>lang_update.html</a>&nbsp;&nbsp; <a href='../lang_with.html'>lang_with.html</a>&nbsp;&nbsp; <a href='../partialindex.html'>partialindex.html</a>
</div>









|



93
94
95
96
97
98
99
100
101
102
103
</div>
<h1 align='center'>ordering-term</h1>
<div class='imgcontainer'>
<img alt="syntax diagram ordering-term" src="../images/syntax/ordering-term.gif"></img><br>

Used by:&nbsp;&nbsp; <a href='./compound-select-stmt.html'>compound-select-stmt</a>&nbsp;&nbsp; <a href='./delete-stmt-limited.html'>delete-stmt-limited</a>&nbsp;&nbsp; <a href='./factored-select-stmt.html'>factored-select-stmt</a>&nbsp;&nbsp; <a href='./over-clause.html'>over-clause</a>&nbsp;&nbsp; <a href='./select-stmt.html'>select-stmt</a>&nbsp;&nbsp; <a href='./simple-select-stmt.html'>simple-select-stmt</a>&nbsp;&nbsp; <a href='./update-stmt-limited.html'>update-stmt-limited</a>&nbsp;&nbsp; <a href='./window-defn.html'>window-defn</a><br></br>
References:&nbsp;&nbsp; <a href='./expr.html'>expr</a><br></br>
See also:&nbsp;&nbsp; <a href='../lang_aggfunc.html'>lang_aggfunc.html</a>&nbsp;&nbsp; <a href='../lang_altertable.html'>lang_altertable.html</a>&nbsp;&nbsp; <a href='../lang_attach.html'>lang_attach.html</a>&nbsp;&nbsp; <a href='../lang_createindex.html'>lang_createindex.html</a>&nbsp;&nbsp; <a href='../lang_createtable.html'>lang_createtable.html</a>&nbsp;&nbsp; <a href='../lang_createtrigger.html'>lang_createtrigger.html</a>&nbsp;&nbsp; <a href='../lang_createview.html'>lang_createview.html</a>&nbsp;&nbsp; <a href='../lang_delete.html'>lang_delete.html</a>&nbsp;&nbsp; <a href='../lang_expr.html'>lang_expr.html</a>&nbsp;&nbsp; <a href='../lang_insert.html'>lang_insert.html</a>&nbsp;&nbsp; <a href='../lang_select.html'>lang_select.html</a>&nbsp;&nbsp; <a href='../lang_update.html'>lang_update.html</a>&nbsp;&nbsp; <a href='../lang_upsert.html'>lang_upsert.html</a>&nbsp;&nbsp; <a href='../lang_with.html'>lang_with.html</a>&nbsp;&nbsp; <a href='../partialindex.html'>partialindex.html</a>
</div>


Changes to Doc/Extra/Core/syntax/pragma-stmt.html.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
Changes to Doc/Extra/Core/syntax/pragma-value.html.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
Changes to Doc/Extra/Core/syntax/qualified-table-name.html.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
Changes to Doc/Extra/Core/syntax/raise-function.html.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
92
93
94
95
96
97
98
99
100
101
102
</script>
</div>
<h1 align='center'>raise-function</h1>
<div class='imgcontainer'>
<img alt="syntax diagram raise-function" src="../images/syntax/raise-function.gif"></img><br>

Used by:&nbsp;&nbsp; <a href='./expr.html'>expr</a><br></br>
See also:&nbsp;&nbsp; <a href='../lang_UPSERT.html'>lang_UPSERT.html</a>&nbsp;&nbsp; <a href='../lang_aggfunc.html'>lang_aggfunc.html</a>&nbsp;&nbsp; <a href='../lang_altertable.html'>lang_altertable.html</a>&nbsp;&nbsp; <a href='../lang_attach.html'>lang_attach.html</a>&nbsp;&nbsp; <a href='../lang_createindex.html'>lang_createindex.html</a>&nbsp;&nbsp; <a href='../lang_createtable.html'>lang_createtable.html</a>&nbsp;&nbsp; <a href='../lang_createtrigger.html'>lang_createtrigger.html</a>&nbsp;&nbsp; <a href='../lang_createview.html'>lang_createview.html</a>&nbsp;&nbsp; <a href='../lang_delete.html'>lang_delete.html</a>&nbsp;&nbsp; <a href='../lang_expr.html'>lang_expr.html</a>&nbsp;&nbsp; <a href='../lang_insert.html'>lang_insert.html</a>&nbsp;&nbsp; <a href='../lang_select.html'>lang_select.html</a>&nbsp;&nbsp; <a href='../lang_update.html'>lang_update.html</a>&nbsp;&nbsp; <a href='../lang_with.html'>lang_with.html</a>&nbsp;&nbsp; <a href='../partialindex.html'>partialindex.html</a>
</div>









|



92
93
94
95
96
97
98
99
100
101
102
</script>
</div>
<h1 align='center'>raise-function</h1>
<div class='imgcontainer'>
<img alt="syntax diagram raise-function" src="../images/syntax/raise-function.gif"></img><br>

Used by:&nbsp;&nbsp; <a href='./expr.html'>expr</a><br></br>
See also:&nbsp;&nbsp; <a href='../lang_aggfunc.html'>lang_aggfunc.html</a>&nbsp;&nbsp; <a href='../lang_altertable.html'>lang_altertable.html</a>&nbsp;&nbsp; <a href='../lang_attach.html'>lang_attach.html</a>&nbsp;&nbsp; <a href='../lang_createindex.html'>lang_createindex.html</a>&nbsp;&nbsp; <a href='../lang_createtable.html'>lang_createtable.html</a>&nbsp;&nbsp; <a href='../lang_createtrigger.html'>lang_createtrigger.html</a>&nbsp;&nbsp; <a href='../lang_createview.html'>lang_createview.html</a>&nbsp;&nbsp; <a href='../lang_delete.html'>lang_delete.html</a>&nbsp;&nbsp; <a href='../lang_expr.html'>lang_expr.html</a>&nbsp;&nbsp; <a href='../lang_insert.html'>lang_insert.html</a>&nbsp;&nbsp; <a href='../lang_select.html'>lang_select.html</a>&nbsp;&nbsp; <a href='../lang_update.html'>lang_update.html</a>&nbsp;&nbsp; <a href='../lang_upsert.html'>lang_upsert.html</a>&nbsp;&nbsp; <a href='../lang_with.html'>lang_with.html</a>&nbsp;&nbsp; <a href='../partialindex.html'>partialindex.html</a>
</div>


Changes to Doc/Extra/Core/syntax/recursive-cte.html.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
Changes to Doc/Extra/Core/syntax/reindex-stmt.html.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
Changes to Doc/Extra/Core/syntax/release-stmt.html.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
Changes to Doc/Extra/Core/syntax/result-column.html.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
93
94
95
96
97
98
99
100
101
102
103
</div>
<h1 align='center'>result-column</h1>
<div class='imgcontainer'>
<img alt="syntax diagram result-column" src="../images/syntax/result-column.gif"></img><br>

Used by:&nbsp;&nbsp; <a href='./select-core.html'>select-core</a>&nbsp;&nbsp; <a href='./select-stmt.html'>select-stmt</a><br></br>
References:&nbsp;&nbsp; <a href='./expr.html'>expr</a><br></br>
See also:&nbsp;&nbsp; <a href='../lang_UPSERT.html'>lang_UPSERT.html</a>&nbsp;&nbsp; <a href='../lang_aggfunc.html'>lang_aggfunc.html</a>&nbsp;&nbsp; <a href='../lang_altertable.html'>lang_altertable.html</a>&nbsp;&nbsp; <a href='../lang_attach.html'>lang_attach.html</a>&nbsp;&nbsp; <a href='../lang_createindex.html'>lang_createindex.html</a>&nbsp;&nbsp; <a href='../lang_createtable.html'>lang_createtable.html</a>&nbsp;&nbsp; <a href='../lang_createtrigger.html'>lang_createtrigger.html</a>&nbsp;&nbsp; <a href='../lang_createview.html'>lang_createview.html</a>&nbsp;&nbsp; <a href='../lang_delete.html'>lang_delete.html</a>&nbsp;&nbsp; <a href='../lang_expr.html'>lang_expr.html</a>&nbsp;&nbsp; <a href='../lang_insert.html'>lang_insert.html</a>&nbsp;&nbsp; <a href='../lang_select.html'>lang_select.html</a>&nbsp;&nbsp; <a href='../lang_update.html'>lang_update.html</a>&nbsp;&nbsp; <a href='../lang_with.html'>lang_with.html</a>&nbsp;&nbsp; <a href='../partialindex.html'>partialindex.html</a>
</div>









|



93
94
95
96
97
98
99
100
101
102
103
</div>
<h1 align='center'>result-column</h1>
<div class='imgcontainer'>
<img alt="syntax diagram result-column" src="../images/syntax/result-column.gif"></img><br>

Used by:&nbsp;&nbsp; <a href='./select-core.html'>select-core</a>&nbsp;&nbsp; <a href='./select-stmt.html'>select-stmt</a><br></br>
References:&nbsp;&nbsp; <a href='./expr.html'>expr</a><br></br>
See also:&nbsp;&nbsp; <a href='../lang_aggfunc.html'>lang_aggfunc.html</a>&nbsp;&nbsp; <a href='../lang_altertable.html'>lang_altertable.html</a>&nbsp;&nbsp; <a href='../lang_attach.html'>lang_attach.html</a>&nbsp;&nbsp; <a href='../lang_createindex.html'>lang_createindex.html</a>&nbsp;&nbsp; <a href='../lang_createtable.html'>lang_createtable.html</a>&nbsp;&nbsp; <a href='../lang_createtrigger.html'>lang_createtrigger.html</a>&nbsp;&nbsp; <a href='../lang_createview.html'>lang_createview.html</a>&nbsp;&nbsp; <a href='../lang_delete.html'>lang_delete.html</a>&nbsp;&nbsp; <a href='../lang_expr.html'>lang_expr.html</a>&nbsp;&nbsp; <a href='../lang_insert.html'>lang_insert.html</a>&nbsp;&nbsp; <a href='../lang_select.html'>lang_select.html</a>&nbsp;&nbsp; <a href='../lang_update.html'>lang_update.html</a>&nbsp;&nbsp; <a href='../lang_upsert.html'>lang_upsert.html</a>&nbsp;&nbsp; <a href='../lang_with.html'>lang_with.html</a>&nbsp;&nbsp; <a href='../partialindex.html'>partialindex.html</a>
</div>


Changes to Doc/Extra/Core/syntax/rollback-stmt.html.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
Changes to Doc/Extra/Core/syntax/savepoint-stmt.html.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
Changes to Doc/Extra/Core/syntax/select-core.html.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
Changes to Doc/Extra/Core/syntax/select-stmt.html.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
93
94
95
96
97
98
99
100
101
102
103
</div>
<h1 align='center'>select-stmt</h1>
<div class='imgcontainer'>
<img alt="syntax diagram select-stmt" src="../images/syntax/select-stmt.gif"></img><br>

Used by:&nbsp;&nbsp; <a href='./common-table-expression.html'>common-table-expression</a>&nbsp;&nbsp; <a href='./create-table-stmt.html'>create-table-stmt</a>&nbsp;&nbsp; <a href='./create-trigger-stmt.html'>create-trigger-stmt</a>&nbsp;&nbsp; <a href='./create-view-stmt.html'>create-view-stmt</a>&nbsp;&nbsp; <a href='./expr.html'>expr</a>&nbsp;&nbsp; <a href='./insert-stmt.html'>insert-stmt</a>&nbsp;&nbsp; <a href='./sql-stmt.html'>sql-stmt</a>&nbsp;&nbsp; <a href='./table-or-subquery.html'>table-or-subquery</a>&nbsp;&nbsp; <a href='./with-clause.html'>with-clause</a><br></br>
References:&nbsp;&nbsp; <a href='./common-table-expression.html'>common-table-expression</a>&nbsp;&nbsp; <a href='./compound-operator.html'>compound-operator</a>&nbsp;&nbsp; <a href='./expr.html'>expr</a>&nbsp;&nbsp; <a href='./join-clause.html'>join-clause</a>&nbsp;&nbsp; <a href='./ordering-term.html'>ordering-term</a>&nbsp;&nbsp; <a href='./result-column.html'>result-column</a>&nbsp;&nbsp; <a href='./table-or-subquery.html'>table-or-subquery</a>&nbsp;&nbsp; <a href='./window-defn.html'>window-defn</a><br></br>
See also:&nbsp;&nbsp; <a href='../lang_UPSERT.html'>lang_UPSERT.html</a>&nbsp;&nbsp; <a href='../lang_aggfunc.html'>lang_aggfunc.html</a>&nbsp;&nbsp; <a href='../lang_altertable.html'>lang_altertable.html</a>&nbsp;&nbsp; <a href='../lang_attach.html'>lang_attach.html</a>&nbsp;&nbsp; <a href='../lang_createindex.html'>lang_createindex.html</a>&nbsp;&nbsp; <a href='../lang_createtable.html'>lang_createtable.html</a>&nbsp;&nbsp; <a href='../lang_createtrigger.html'>lang_createtrigger.html</a>&nbsp;&nbsp; <a href='../lang_createview.html'>lang_createview.html</a>&nbsp;&nbsp; <a href='../lang_delete.html'>lang_delete.html</a>&nbsp;&nbsp; <a href='../lang_expr.html'>lang_expr.html</a>&nbsp;&nbsp; <a href='../lang_insert.html'>lang_insert.html</a>&nbsp;&nbsp; <a href='../lang_select.html'>lang_select.html</a>&nbsp;&nbsp; <a href='../lang_update.html'>lang_update.html</a>&nbsp;&nbsp; <a href='../lang_with.html'>lang_with.html</a>&nbsp;&nbsp; <a href='../partialindex.html'>partialindex.html</a>
</div>









|



93
94
95
96
97
98
99
100
101
102
103
</div>
<h1 align='center'>select-stmt</h1>
<div class='imgcontainer'>
<img alt="syntax diagram select-stmt" src="../images/syntax/select-stmt.gif"></img><br>

Used by:&nbsp;&nbsp; <a href='./common-table-expression.html'>common-table-expression</a>&nbsp;&nbsp; <a href='./create-table-stmt.html'>create-table-stmt</a>&nbsp;&nbsp; <a href='./create-trigger-stmt.html'>create-trigger-stmt</a>&nbsp;&nbsp; <a href='./create-view-stmt.html'>create-view-stmt</a>&nbsp;&nbsp; <a href='./expr.html'>expr</a>&nbsp;&nbsp; <a href='./insert-stmt.html'>insert-stmt</a>&nbsp;&nbsp; <a href='./sql-stmt.html'>sql-stmt</a>&nbsp;&nbsp; <a href='./table-or-subquery.html'>table-or-subquery</a>&nbsp;&nbsp; <a href='./with-clause.html'>with-clause</a><br></br>
References:&nbsp;&nbsp; <a href='./common-table-expression.html'>common-table-expression</a>&nbsp;&nbsp; <a href='./compound-operator.html'>compound-operator</a>&nbsp;&nbsp; <a href='./expr.html'>expr</a>&nbsp;&nbsp; <a href='./join-clause.html'>join-clause</a>&nbsp;&nbsp; <a href='./ordering-term.html'>ordering-term</a>&nbsp;&nbsp; <a href='./result-column.html'>result-column</a>&nbsp;&nbsp; <a href='./table-or-subquery.html'>table-or-subquery</a>&nbsp;&nbsp; <a href='./window-defn.html'>window-defn</a><br></br>
See also:&nbsp;&nbsp; <a href='../lang_aggfunc.html'>lang_aggfunc.html</a>&nbsp;&nbsp; <a href='../lang_altertable.html'>lang_altertable.html</a>&nbsp;&nbsp; <a href='../lang_attach.html'>lang_attach.html</a>&nbsp;&nbsp; <a href='../lang_createindex.html'>lang_createindex.html</a>&nbsp;&nbsp; <a href='../lang_createtable.html'>lang_createtable.html</a>&nbsp;&nbsp; <a href='../lang_createtrigger.html'>lang_createtrigger.html</a>&nbsp;&nbsp; <a href='../lang_createview.html'>lang_createview.html</a>&nbsp;&nbsp; <a href='../lang_delete.html'>lang_delete.html</a>&nbsp;&nbsp; <a href='../lang_expr.html'>lang_expr.html</a>&nbsp;&nbsp; <a href='../lang_insert.html'>lang_insert.html</a>&nbsp;&nbsp; <a href='../lang_select.html'>lang_select.html</a>&nbsp;&nbsp; <a href='../lang_update.html'>lang_update.html</a>&nbsp;&nbsp; <a href='../lang_upsert.html'>lang_upsert.html</a>&nbsp;&nbsp; <a href='../lang_with.html'>lang_with.html</a>&nbsp;&nbsp; <a href='../partialindex.html'>partialindex.html</a>
</div>


Changes to Doc/Extra/Core/syntax/signed-number.html.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
92
93
94
95
96
97
98
99
100
101
102
</script>
</div>
<h1 align='center'>signed-number</h1>
<div class='imgcontainer'>
<img alt="syntax diagram signed-number" src="../images/syntax/signed-number.gif"></img><br>

Used by:&nbsp;&nbsp; <a href='./column-constraint.html'>column-constraint</a>&nbsp;&nbsp; <a href='./pragma-value.html'>pragma-value</a>&nbsp;&nbsp; <a href='./type-name.html'>type-name</a><br></br>
See also:&nbsp;&nbsp; <a href='../lang_UPSERT.html'>lang_UPSERT.html</a>&nbsp;&nbsp; <a href='../lang_aggfunc.html'>lang_aggfunc.html</a>&nbsp;&nbsp; <a href='../lang_altertable.html'>lang_altertable.html</a>&nbsp;&nbsp; <a href='../lang_attach.html'>lang_attach.html</a>&nbsp;&nbsp; <a href='../lang_createindex.html'>lang_createindex.html</a>&nbsp;&nbsp; <a href='../lang_createtable.html'>lang_createtable.html</a>&nbsp;&nbsp; <a href='../lang_createtrigger.html'>lang_createtrigger.html</a>&nbsp;&nbsp; <a href='../lang_createview.html'>lang_createview.html</a>&nbsp;&nbsp; <a href='../lang_delete.html'>lang_delete.html</a>&nbsp;&nbsp; <a href='../lang_expr.html'>lang_expr.html</a>&nbsp;&nbsp; <a href='../lang_insert.html'>lang_insert.html</a>&nbsp;&nbsp; <a href='../lang_select.html'>lang_select.html</a>&nbsp;&nbsp; <a href='../lang_update.html'>lang_update.html</a>&nbsp;&nbsp; <a href='../lang_with.html'>lang_with.html</a>&nbsp;&nbsp; <a href='../partialindex.html'>partialindex.html</a>&nbsp;&nbsp; <a href='../pragma.html'>pragma.html</a>
</div>









|



92
93
94
95
96
97
98
99
100
101
102
</script>
</div>
<h1 align='center'>signed-number</h1>
<div class='imgcontainer'>
<img alt="syntax diagram signed-number" src="../images/syntax/signed-number.gif"></img><br>

Used by:&nbsp;&nbsp; <a href='./column-constraint.html'>column-constraint</a>&nbsp;&nbsp; <a href='./pragma-value.html'>pragma-value</a>&nbsp;&nbsp; <a href='./type-name.html'>type-name</a><br></br>
See also:&nbsp;&nbsp; <a href='../lang_aggfunc.html'>lang_aggfunc.html</a>&nbsp;&nbsp; <a href='../lang_altertable.html'>lang_altertable.html</a>&nbsp;&nbsp; <a href='../lang_attach.html'>lang_attach.html</a>&nbsp;&nbsp; <a href='../lang_createindex.html'>lang_createindex.html</a>&nbsp;&nbsp; <a href='../lang_createtable.html'>lang_createtable.html</a>&nbsp;&nbsp; <a href='../lang_createtrigger.html'>lang_createtrigger.html</a>&nbsp;&nbsp; <a href='../lang_createview.html'>lang_createview.html</a>&nbsp;&nbsp; <a href='../lang_delete.html'>lang_delete.html</a>&nbsp;&nbsp; <a href='../lang_expr.html'>lang_expr.html</a>&nbsp;&nbsp; <a href='../lang_insert.html'>lang_insert.html</a>&nbsp;&nbsp; <a href='../lang_select.html'>lang_select.html</a>&nbsp;&nbsp; <a href='../lang_update.html'>lang_update.html</a>&nbsp;&nbsp; <a href='../lang_upsert.html'>lang_upsert.html</a>&nbsp;&nbsp; <a href='../lang_with.html'>lang_with.html</a>&nbsp;&nbsp; <a href='../partialindex.html'>partialindex.html</a>&nbsp;&nbsp; <a href='../pragma.html'>pragma.html</a>
</div>


Changes to Doc/Extra/Core/syntax/simple-select-stmt.html.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
Changes to Doc/Extra/Core/syntax/sql-stmt-list.html.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
Changes to Doc/Extra/Core/syntax/sql-stmt.html.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
Changes to Doc/Extra/Core/syntax/table-constraint.html.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
Changes to Doc/Extra/Core/syntax/table-or-subquery.html.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
93
94
95
96
97
98
99
100
101
102
103
</div>
<h1 align='center'>table-or-subquery</h1>
<div class='imgcontainer'>
<img alt="syntax diagram table-or-subquery" src="../images/syntax/table-or-subquery.gif"></img><br>

Used by:&nbsp;&nbsp; <a href='./join-clause.html'>join-clause</a>&nbsp;&nbsp; <a href='./select-core.html'>select-core</a>&nbsp;&nbsp; <a href='./select-stmt.html'>select-stmt</a><br></br>
References:&nbsp;&nbsp; <a href='./expr.html'>expr</a>&nbsp;&nbsp; <a href='./join-clause.html'>join-clause</a>&nbsp;&nbsp; <a href='./select-stmt.html'>select-stmt</a><br></br>
See also:&nbsp;&nbsp; <a href='../lang_UPSERT.html'>lang_UPSERT.html</a>&nbsp;&nbsp; <a href='../lang_aggfunc.html'>lang_aggfunc.html</a>&nbsp;&nbsp; <a href='../lang_altertable.html'>lang_altertable.html</a>&nbsp;&nbsp; <a href='../lang_attach.html'>lang_attach.html</a>&nbsp;&nbsp; <a href='../lang_createindex.html'>lang_createindex.html</a>&nbsp;&nbsp; <a href='../lang_createtable.html'>lang_createtable.html</a>&nbsp;&nbsp; <a href='../lang_createtrigger.html'>lang_createtrigger.html</a>&nbsp;&nbsp; <a href='../lang_createview.html'>lang_createview.html</a>&nbsp;&nbsp; <a href='../lang_delete.html'>lang_delete.html</a>&nbsp;&nbsp; <a href='../lang_expr.html'>lang_expr.html</a>&nbsp;&nbsp; <a href='../lang_insert.html'>lang_insert.html</a>&nbsp;&nbsp; <a href='../lang_select.html'>lang_select.html</a>&nbsp;&nbsp; <a href='../lang_update.html'>lang_update.html</a>&nbsp;&nbsp; <a href='../lang_with.html'>lang_with.html</a>&nbsp;&nbsp; <a href='../partialindex.html'>partialindex.html</a>
</div>









|



93
94
95
96
97
98
99
100
101
102
103
</div>
<h1 align='center'>table-or-subquery</h1>
<div class='imgcontainer'>
<img alt="syntax diagram table-or-subquery" src="../images/syntax/table-or-subquery.gif"></img><br>

Used by:&nbsp;&nbsp; <a href='./join-clause.html'>join-clause</a>&nbsp;&nbsp; <a href='./select-core.html'>select-core</a>&nbsp;&nbsp; <a href='./select-stmt.html'>select-stmt</a><br></br>
References:&nbsp;&nbsp; <a href='./expr.html'>expr</a>&nbsp;&nbsp; <a href='./join-clause.html'>join-clause</a>&nbsp;&nbsp; <a href='./select-stmt.html'>select-stmt</a><br></br>
See also:&nbsp;&nbsp; <a href='../lang_aggfunc.html'>lang_aggfunc.html</a>&nbsp;&nbsp; <a href='../lang_altertable.html'>lang_altertable.html</a>&nbsp;&nbsp; <a href='../lang_attach.html'>lang_attach.html</a>&nbsp;&nbsp; <a href='../lang_createindex.html'>lang_createindex.html</a>&nbsp;&nbsp; <a href='../lang_createtable.html'>lang_createtable.html</a>&nbsp;&nbsp; <a href='../lang_createtrigger.html'>lang_createtrigger.html</a>&nbsp;&nbsp; <a href='../lang_createview.html'>lang_createview.html</a>&nbsp;&nbsp; <a href='../lang_delete.html'>lang_delete.html</a>&nbsp;&nbsp; <a href='../lang_expr.html'>lang_expr.html</a>&nbsp;&nbsp; <a href='../lang_insert.html'>lang_insert.html</a>&nbsp;&nbsp; <a href='../lang_select.html'>lang_select.html</a>&nbsp;&nbsp; <a href='../lang_update.html'>lang_update.html</a>&nbsp;&nbsp; <a href='../lang_upsert.html'>lang_upsert.html</a>&nbsp;&nbsp; <a href='../lang_with.html'>lang_with.html</a>&nbsp;&nbsp; <a href='../partialindex.html'>partialindex.html</a>
</div>


Changes to Doc/Extra/Core/syntax/type-name.html.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
93
94
95
96
97
98
99
100
101
102
103
</div>
<h1 align='center'>type-name</h1>
<div class='imgcontainer'>
<img alt="syntax diagram type-name" src="../images/syntax/type-name.gif"></img><br>

Used by:&nbsp;&nbsp; <a href='./column-def.html'>column-def</a>&nbsp;&nbsp; <a href='./expr.html'>expr</a><br></br>
References:&nbsp;&nbsp; <a href='./signed-number.html'>signed-number</a><br></br>
See also:&nbsp;&nbsp; <a href='../lang_UPSERT.html'>lang_UPSERT.html</a>&nbsp;&nbsp; <a href='../lang_aggfunc.html'>lang_aggfunc.html</a>&nbsp;&nbsp; <a href='../lang_altertable.html'>lang_altertable.html</a>&nbsp;&nbsp; <a href='../lang_attach.html'>lang_attach.html</a>&nbsp;&nbsp; <a href='../lang_createindex.html'>lang_createindex.html</a>&nbsp;&nbsp; <a href='../lang_createtable.html'>lang_createtable.html</a>&nbsp;&nbsp; <a href='../lang_createtrigger.html'>lang_createtrigger.html</a>&nbsp;&nbsp; <a href='../lang_createview.html'>lang_createview.html</a>&nbsp;&nbsp; <a href='../lang_delete.html'>lang_delete.html</a>&nbsp;&nbsp; <a href='../lang_expr.html'>lang_expr.html</a>&nbsp;&nbsp; <a href='../lang_insert.html'>lang_insert.html</a>&nbsp;&nbsp; <a href='../lang_select.html'>lang_select.html</a>&nbsp;&nbsp; <a href='../lang_update.html'>lang_update.html</a>&nbsp;&nbsp; <a href='../lang_with.html'>lang_with.html</a>&nbsp;&nbsp; <a href='../partialindex.html'>partialindex.html</a>
</div>









|



93
94
95
96
97
98
99
100
101
102
103
</div>
<h1 align='center'>type-name</h1>
<div class='imgcontainer'>
<img alt="syntax diagram type-name" src="../images/syntax/type-name.gif"></img><br>

Used by:&nbsp;&nbsp; <a href='./column-def.html'>column-def</a>&nbsp;&nbsp; <a href='./expr.html'>expr</a><br></br>
References:&nbsp;&nbsp; <a href='./signed-number.html'>signed-number</a><br></br>
See also:&nbsp;&nbsp; <a href='../lang_aggfunc.html'>lang_aggfunc.html</a>&nbsp;&nbsp; <a href='../lang_altertable.html'>lang_altertable.html</a>&nbsp;&nbsp; <a href='../lang_attach.html'>lang_attach.html</a>&nbsp;&nbsp; <a href='../lang_createindex.html'>lang_createindex.html</a>&nbsp;&nbsp; <a href='../lang_createtable.html'>lang_createtable.html</a>&nbsp;&nbsp; <a href='../lang_createtrigger.html'>lang_createtrigger.html</a>&nbsp;&nbsp; <a href='../lang_createview.html'>lang_createview.html</a>&nbsp;&nbsp; <a href='../lang_delete.html'>lang_delete.html</a>&nbsp;&nbsp; <a href='../lang_expr.html'>lang_expr.html</a>&nbsp;&nbsp; <a href='../lang_insert.html'>lang_insert.html</a>&nbsp;&nbsp; <a href='../lang_select.html'>lang_select.html</a>&nbsp;&nbsp; <a href='../lang_update.html'>lang_update.html</a>&nbsp;&nbsp; <a href='../lang_upsert.html'>lang_upsert.html</a>&nbsp;&nbsp; <a href='../lang_with.html'>lang_with.html</a>&nbsp;&nbsp; <a href='../partialindex.html'>partialindex.html</a>
</div>


Changes to Doc/Extra/Core/syntax/update-stmt-limited.html.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
Changes to Doc/Extra/Core/syntax/update-stmt.html.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
Changes to Doc/Extra/Core/syntax/vacuum-stmt.html.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
Changes to Doc/Extra/Core/syntax/with-clause.html.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
Changes to Doc/Extra/Core/syntaxdiagrams.html.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
See also:&nbsp;&nbsp; <a href="lang_createindex.html">lang_createindex.html</a>&nbsp;&nbsp; <a href="partialindex.html">partialindex.html</a>
</div>

<a name="indexed-column"></a><h4>indexed-column:</h4><div class='imgcontainer'>
<img src="images/syntax/indexed-column.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#create-index-stmt">create-index-stmt</a>&nbsp;&nbsp; <a href="#table-constraint">table-constraint</a>&nbsp;&nbsp; <a href="#upsert-clause">upsert-clause</a><br></br>
References:&nbsp;&nbsp; <a href="#expr">expr</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_UPSERT.html">lang_UPSERT.html</a>&nbsp;&nbsp; <a href="lang_createindex.html">lang_createindex.html</a>&nbsp;&nbsp; <a href="lang_createtable.html">lang_createtable.html</a>&nbsp;&nbsp; <a href="lang_createtable.html#primkeyconst">lang_createtable.html#primkeyconst</a>&nbsp;&nbsp; <a href="lang_createtable.html#uniqueconst">lang_createtable.html#uniqueconst</a>&nbsp;&nbsp; <a href="lang_createtrigger.html">lang_createtrigger.html</a>&nbsp;&nbsp; <a href="lang_insert.html">lang_insert.html</a>&nbsp;&nbsp; <a href="partialindex.html">partialindex.html</a>
</div>

<a name="create-table-stmt"></a><h4>create-table-stmt:</h4><div class='imgcontainer'>
<img src="images/syntax/create-table-stmt.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#sql-stmt">sql-stmt</a><br></br>
References:&nbsp;&nbsp; <a href="#column-def">column-def</a>&nbsp;&nbsp; <a href="#select-stmt">select-stmt</a>&nbsp;&nbsp; <a href="#table-constraint">table-constraint</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_createtable.html">lang_createtable.html</a>
</div>

<a name="column-def"></a><h4>column-def:</h4><div class='imgcontainer'>
<img src="images/syntax/column-def.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#alter-table-stmt">alter-table-stmt</a>&nbsp;&nbsp; <a href="#create-table-stmt">create-table-stmt</a><br></br>
References:&nbsp;&nbsp; <a href="#column-constraint">column-constraint</a>&nbsp;&nbsp; <a href="#type-name">type-name</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_altertable.html">lang_altertable.html</a>&nbsp;&nbsp; <a href="lang_altertable.html#altertabaddcol">lang_altertable.html#altertabaddcol</a>&nbsp;&nbsp; <a href="lang_createtable.html">lang_createtable.html</a>&nbsp;&nbsp; <a href="lang_createtable.html#tablecoldef">lang_createtable.html#tablecoldef</a>
</div>

<a name="type-name"></a><h4>type-name:</h4><div class='imgcontainer'>
<img src="images/syntax/type-name.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#column-def">column-def</a>&nbsp;&nbsp; <a href="#expr">expr</a><br></br>
References:&nbsp;&nbsp; <a href="#signed-number">signed-number</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_UPSERT.html">lang_UPSERT.html</a>&nbsp;&nbsp; <a href="lang_aggfunc.html">lang_aggfunc.html</a>&nbsp;&nbsp; <a href="lang_altertable.html">lang_altertable.html</a>&nbsp;&nbsp; <a href="lang_attach.html">lang_attach.html</a>&nbsp;&nbsp; <a href="lang_createindex.html">lang_createindex.html</a>&nbsp;&nbsp; <a href="lang_createtable.html">lang_createtable.html</a>&nbsp;&nbsp; <a href="lang_createtrigger.html">lang_createtrigger.html</a>&nbsp;&nbsp; <a href="lang_createview.html">lang_createview.html</a>&nbsp;&nbsp; <a href="lang_delete.html">lang_delete.html</a>&nbsp;&nbsp; <a href="lang_expr.html">lang_expr.html</a>&nbsp;&nbsp; <a href="lang_insert.html">lang_insert.html</a>&nbsp;&nbsp; <a href="lang_select.html">lang_select.html</a>&nbsp;&nbsp; <a href="lang_select.html#compound">lang_select.html#compound</a>&nbsp;&nbsp; <a href="lang_select.html#simpleselect">lang_select.html#simpleselect</a>&nbsp;&nbsp; <a href="lang_update.html">lang_update.html</a>&nbsp;&nbsp; <a href="lang_with.html">lang_with.html</a>&nbsp;&nbsp; <a href="partialindex.html">partialindex.html</a>
</div>

<a name="column-constraint"></a><h4>column-constraint:</h4><div class='imgcontainer'>
<img src="images/syntax/column-constraint.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#column-def">column-def</a><br></br>
References:&nbsp;&nbsp; <a href="#conflict-clause">conflict-clause</a>&nbsp;&nbsp; <a href="#expr">expr</a>&nbsp;&nbsp; <a href="#foreign-key-clause">foreign-key-clause</a>&nbsp;&nbsp; <a href="#literal-value">literal-value</a>&nbsp;&nbsp; <a href="#signed-number">signed-number</a><br></br>
See also:&nbsp;&nbsp; <a href="gencol.html">gencol.html</a>&nbsp;&nbsp; <a href="lang_altertable.html">lang_altertable.html</a>&nbsp;&nbsp; <a href="lang_createtable.html">lang_createtable.html</a>&nbsp;&nbsp; <a href="lang_createtable.html#tablecoldef">lang_createtable.html#tablecoldef</a>
</div>

<a name="signed-number"></a><h4>signed-number:</h4><div class='imgcontainer'>
<img src="images/syntax/signed-number.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#column-constraint">column-constraint</a>&nbsp;&nbsp; <a href="#pragma-value">pragma-value</a>&nbsp;&nbsp; <a href="#type-name">type-name</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_UPSERT.html">lang_UPSERT.html</a>&nbsp;&nbsp; <a href="lang_aggfunc.html">lang_aggfunc.html</a>&nbsp;&nbsp; <a href="lang_altertable.html">lang_altertable.html</a>&nbsp;&nbsp; <a href="lang_attach.html">lang_attach.html</a>&nbsp;&nbsp; <a href="lang_createindex.html">lang_createindex.html</a>&nbsp;&nbsp; <a href="lang_createtable.html">lang_createtable.html</a>&nbsp;&nbsp; <a href="lang_createtrigger.html">lang_createtrigger.html</a>&nbsp;&nbsp; <a href="lang_createview.html">lang_createview.html</a>&nbsp;&nbsp; <a href="lang_delete.html">lang_delete.html</a>&nbsp;&nbsp; <a href="lang_expr.html">lang_expr.html</a>&nbsp;&nbsp; <a href="lang_insert.html">lang_insert.html</a>&nbsp;&nbsp; <a href="lang_select.html">lang_select.html</a>&nbsp;&nbsp; <a href="lang_select.html#compound">lang_select.html#compound</a>&nbsp;&nbsp; <a href="lang_select.html#simpleselect">lang_select.html#simpleselect</a>&nbsp;&nbsp; <a href="lang_update.html">lang_update.html</a>&nbsp;&nbsp; <a href="lang_with.html">lang_with.html</a>&nbsp;&nbsp; <a href="partialindex.html">partialindex.html</a>&nbsp;&nbsp; <a href="pragma.html#syntax">pragma.html#syntax</a>
</div>

<a name="table-constraint"></a><h4>table-constraint:</h4><div class='imgcontainer'>
<img src="images/syntax/table-constraint.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#create-table-stmt">create-table-stmt</a><br></br>
References:&nbsp;&nbsp; <a href="#conflict-clause">conflict-clause</a>&nbsp;&nbsp; <a href="#expr">expr</a>&nbsp;&nbsp; <a href="#foreign-key-clause">foreign-key-clause</a>&nbsp;&nbsp; <a href="#indexed-column">indexed-column</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_createtable.html">lang_createtable.html</a>&nbsp;&nbsp; <a href="lang_createtable.html#primkeyconst">lang_createtable.html#primkeyconst</a>&nbsp;&nbsp; <a href="lang_createtable.html#tablecoldef">lang_createtable.html#tablecoldef</a>&nbsp;&nbsp; <a href="lang_createtable.html#uniqueconst">lang_createtable.html#uniqueconst</a>







|




















|












|







166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
See also:&nbsp;&nbsp; <a href="lang_createindex.html">lang_createindex.html</a>&nbsp;&nbsp; <a href="partialindex.html">partialindex.html</a>
</div>

<a name="indexed-column"></a><h4>indexed-column:</h4><div class='imgcontainer'>
<img src="images/syntax/indexed-column.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#create-index-stmt">create-index-stmt</a>&nbsp;&nbsp; <a href="#table-constraint">table-constraint</a>&nbsp;&nbsp; <a href="#upsert-clause">upsert-clause</a><br></br>
References:&nbsp;&nbsp; <a href="#expr">expr</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_createindex.html">lang_createindex.html</a>&nbsp;&nbsp; <a href="lang_createtable.html">lang_createtable.html</a>&nbsp;&nbsp; <a href="lang_createtable.html#primkeyconst">lang_createtable.html#primkeyconst</a>&nbsp;&nbsp; <a href="lang_createtable.html#uniqueconst">lang_createtable.html#uniqueconst</a>&nbsp;&nbsp; <a href="lang_createtrigger.html">lang_createtrigger.html</a>&nbsp;&nbsp; <a href="lang_insert.html">lang_insert.html</a>&nbsp;&nbsp; <a href="lang_upsert.html">lang_upsert.html</a>&nbsp;&nbsp; <a href="partialindex.html">partialindex.html</a>
</div>

<a name="create-table-stmt"></a><h4>create-table-stmt:</h4><div class='imgcontainer'>
<img src="images/syntax/create-table-stmt.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#sql-stmt">sql-stmt</a><br></br>
References:&nbsp;&nbsp; <a href="#column-def">column-def</a>&nbsp;&nbsp; <a href="#select-stmt">select-stmt</a>&nbsp;&nbsp; <a href="#table-constraint">table-constraint</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_createtable.html">lang_createtable.html</a>
</div>

<a name="column-def"></a><h4>column-def:</h4><div class='imgcontainer'>
<img src="images/syntax/column-def.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#alter-table-stmt">alter-table-stmt</a>&nbsp;&nbsp; <a href="#create-table-stmt">create-table-stmt</a><br></br>
References:&nbsp;&nbsp; <a href="#column-constraint">column-constraint</a>&nbsp;&nbsp; <a href="#type-name">type-name</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_altertable.html">lang_altertable.html</a>&nbsp;&nbsp; <a href="lang_altertable.html#altertabaddcol">lang_altertable.html#altertabaddcol</a>&nbsp;&nbsp; <a href="lang_createtable.html">lang_createtable.html</a>&nbsp;&nbsp; <a href="lang_createtable.html#tablecoldef">lang_createtable.html#tablecoldef</a>
</div>

<a name="type-name"></a><h4>type-name:</h4><div class='imgcontainer'>
<img src="images/syntax/type-name.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#column-def">column-def</a>&nbsp;&nbsp; <a href="#expr">expr</a><br></br>
References:&nbsp;&nbsp; <a href="#signed-number">signed-number</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_aggfunc.html">lang_aggfunc.html</a>&nbsp;&nbsp; <a href="lang_altertable.html">lang_altertable.html</a>&nbsp;&nbsp; <a href="lang_attach.html">lang_attach.html</a>&nbsp;&nbsp; <a href="lang_createindex.html">lang_createindex.html</a>&nbsp;&nbsp; <a href="lang_createtable.html">lang_createtable.html</a>&nbsp;&nbsp; <a href="lang_createtrigger.html">lang_createtrigger.html</a>&nbsp;&nbsp; <a href="lang_createview.html">lang_createview.html</a>&nbsp;&nbsp; <a href="lang_delete.html">lang_delete.html</a>&nbsp;&nbsp; <a href="lang_expr.html">lang_expr.html</a>&nbsp;&nbsp; <a href="lang_insert.html">lang_insert.html</a>&nbsp;&nbsp; <a href="lang_select.html">lang_select.html</a>&nbsp;&nbsp; <a href="lang_select.html#compound">lang_select.html#compound</a>&nbsp;&nbsp; <a href="lang_select.html#simpleselect">lang_select.html#simpleselect</a>&nbsp;&nbsp; <a href="lang_update.html">lang_update.html</a>&nbsp;&nbsp; <a href="lang_upsert.html">lang_upsert.html</a>&nbsp;&nbsp; <a href="lang_with.html">lang_with.html</a>&nbsp;&nbsp; <a href="partialindex.html">partialindex.html</a>
</div>

<a name="column-constraint"></a><h4>column-constraint:</h4><div class='imgcontainer'>
<img src="images/syntax/column-constraint.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#column-def">column-def</a><br></br>
References:&nbsp;&nbsp; <a href="#conflict-clause">conflict-clause</a>&nbsp;&nbsp; <a href="#expr">expr</a>&nbsp;&nbsp; <a href="#foreign-key-clause">foreign-key-clause</a>&nbsp;&nbsp; <a href="#literal-value">literal-value</a>&nbsp;&nbsp; <a href="#signed-number">signed-number</a><br></br>
See also:&nbsp;&nbsp; <a href="gencol.html">gencol.html</a>&nbsp;&nbsp; <a href="lang_altertable.html">lang_altertable.html</a>&nbsp;&nbsp; <a href="lang_createtable.html">lang_createtable.html</a>&nbsp;&nbsp; <a href="lang_createtable.html#tablecoldef">lang_createtable.html#tablecoldef</a>
</div>

<a name="signed-number"></a><h4>signed-number:</h4><div class='imgcontainer'>
<img src="images/syntax/signed-number.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#column-constraint">column-constraint</a>&nbsp;&nbsp; <a href="#pragma-value">pragma-value</a>&nbsp;&nbsp; <a href="#type-name">type-name</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_aggfunc.html">lang_aggfunc.html</a>&nbsp;&nbsp; <a href="lang_altertable.html">lang_altertable.html</a>&nbsp;&nbsp; <a href="lang_attach.html">lang_attach.html</a>&nbsp;&nbsp; <a href="lang_createindex.html">lang_createindex.html</a>&nbsp;&nbsp; <a href="lang_createtable.html">lang_createtable.html</a>&nbsp;&nbsp; <a href="lang_createtrigger.html">lang_createtrigger.html</a>&nbsp;&nbsp; <a href="lang_createview.html">lang_createview.html</a>&nbsp;&nbsp; <a href="lang_delete.html">lang_delete.html</a>&nbsp;&nbsp; <a href="lang_expr.html">lang_expr.html</a>&nbsp;&nbsp; <a href="lang_insert.html">lang_insert.html</a>&nbsp;&nbsp; <a href="lang_select.html">lang_select.html</a>&nbsp;&nbsp; <a href="lang_select.html#compound">lang_select.html#compound</a>&nbsp;&nbsp; <a href="lang_select.html#simpleselect">lang_select.html#simpleselect</a>&nbsp;&nbsp; <a href="lang_update.html">lang_update.html</a>&nbsp;&nbsp; <a href="lang_upsert.html">lang_upsert.html</a>&nbsp;&nbsp; <a href="lang_with.html">lang_with.html</a>&nbsp;&nbsp; <a href="partialindex.html">partialindex.html</a>&nbsp;&nbsp; <a href="pragma.html#syntax">pragma.html#syntax</a>
</div>

<a name="table-constraint"></a><h4>table-constraint:</h4><div class='imgcontainer'>
<img src="images/syntax/table-constraint.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#create-table-stmt">create-table-stmt</a><br></br>
References:&nbsp;&nbsp; <a href="#conflict-clause">conflict-clause</a>&nbsp;&nbsp; <a href="#expr">expr</a>&nbsp;&nbsp; <a href="#foreign-key-clause">foreign-key-clause</a>&nbsp;&nbsp; <a href="#indexed-column">indexed-column</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_createtable.html">lang_createtable.html</a>&nbsp;&nbsp; <a href="lang_createtable.html#primkeyconst">lang_createtable.html#primkeyconst</a>&nbsp;&nbsp; <a href="lang_createtable.html#tablecoldef">lang_createtable.html#tablecoldef</a>&nbsp;&nbsp; <a href="lang_createtable.html#uniqueconst">lang_createtable.html#uniqueconst</a>
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
See also:&nbsp;&nbsp; <a href="lang_with.html#recursivecte">lang_with.html#recursivecte</a>
</div>

<a name="common-table-expression"></a><h4>common-table-expression:</h4><div class='imgcontainer'>
<img src="images/syntax/common-table-expression.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#compound-select-stmt">compound-select-stmt</a>&nbsp;&nbsp; <a href="#factored-select-stmt">factored-select-stmt</a>&nbsp;&nbsp; <a href="#select-stmt">select-stmt</a>&nbsp;&nbsp; <a href="#simple-select-stmt">simple-select-stmt</a><br></br>
References:&nbsp;&nbsp; <a href="#select-stmt">select-stmt</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_UPSERT.html">lang_UPSERT.html</a>&nbsp;&nbsp; <a href="lang_aggfunc.html">lang_aggfunc.html</a>&nbsp;&nbsp; <a href="lang_altertable.html">lang_altertable.html</a>&nbsp;&nbsp; <a href="lang_attach.html">lang_attach.html</a>&nbsp;&nbsp; <a href="lang_createindex.html">lang_createindex.html</a>&nbsp;&nbsp; <a href="lang_createtable.html">lang_createtable.html</a>&nbsp;&nbsp; <a href="lang_createtrigger.html">lang_createtrigger.html</a>&nbsp;&nbsp; <a href="lang_createview.html">lang_createview.html</a>&nbsp;&nbsp; <a href="lang_delete.html">lang_delete.html</a>&nbsp;&nbsp; <a href="lang_expr.html">lang_expr.html</a>&nbsp;&nbsp; <a href="lang_insert.html">lang_insert.html</a>&nbsp;&nbsp; <a href="lang_select.html">lang_select.html</a>&nbsp;&nbsp; <a href="lang_select.html#compound">lang_select.html#compound</a>&nbsp;&nbsp; <a href="lang_select.html#simpleselect">lang_select.html#simpleselect</a>&nbsp;&nbsp; <a href="lang_update.html">lang_update.html</a>&nbsp;&nbsp; <a href="lang_with.html">lang_with.html</a>&nbsp;&nbsp; <a href="partialindex.html">partialindex.html</a>
</div>

<a name="delete-stmt"></a><h4>delete-stmt:</h4><div class='imgcontainer'>
<img src="images/syntax/delete-stmt.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#create-trigger-stmt">create-trigger-stmt</a>&nbsp;&nbsp; <a href="#sql-stmt">sql-stmt</a><br></br>
References:&nbsp;&nbsp; <a href="#expr">expr</a>&nbsp;&nbsp; <a href="#qualified-table-name">qualified-table-name</a>&nbsp;&nbsp; <a href="#with-clause">with-clause</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_createtrigger.html">lang_createtrigger.html</a>&nbsp;&nbsp; <a href="lang_delete.html">lang_delete.html</a>







|







265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
See also:&nbsp;&nbsp; <a href="lang_with.html#recursivecte">lang_with.html#recursivecte</a>
</div>

<a name="common-table-expression"></a><h4>common-table-expression:</h4><div class='imgcontainer'>
<img src="images/syntax/common-table-expression.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#compound-select-stmt">compound-select-stmt</a>&nbsp;&nbsp; <a href="#factored-select-stmt">factored-select-stmt</a>&nbsp;&nbsp; <a href="#select-stmt">select-stmt</a>&nbsp;&nbsp; <a href="#simple-select-stmt">simple-select-stmt</a><br></br>
References:&nbsp;&nbsp; <a href="#select-stmt">select-stmt</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_aggfunc.html">lang_aggfunc.html</a>&nbsp;&nbsp; <a href="lang_altertable.html">lang_altertable.html</a>&nbsp;&nbsp; <a href="lang_attach.html">lang_attach.html</a>&nbsp;&nbsp; <a href="lang_createindex.html">lang_createindex.html</a>&nbsp;&nbsp; <a href="lang_createtable.html">lang_createtable.html</a>&nbsp;&nbsp; <a href="lang_createtrigger.html">lang_createtrigger.html</a>&nbsp;&nbsp; <a href="lang_createview.html">lang_createview.html</a>&nbsp;&nbsp; <a href="lang_delete.html">lang_delete.html</a>&nbsp;&nbsp; <a href="lang_expr.html">lang_expr.html</a>&nbsp;&nbsp; <a href="lang_insert.html">lang_insert.html</a>&nbsp;&nbsp; <a href="lang_select.html">lang_select.html</a>&nbsp;&nbsp; <a href="lang_select.html#compound">lang_select.html#compound</a>&nbsp;&nbsp; <a href="lang_select.html#simpleselect">lang_select.html#simpleselect</a>&nbsp;&nbsp; <a href="lang_update.html">lang_update.html</a>&nbsp;&nbsp; <a href="lang_upsert.html">lang_upsert.html</a>&nbsp;&nbsp; <a href="lang_with.html">lang_with.html</a>&nbsp;&nbsp; <a href="partialindex.html">partialindex.html</a>
</div>

<a name="delete-stmt"></a><h4>delete-stmt:</h4><div class='imgcontainer'>
<img src="images/syntax/delete-stmt.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#create-trigger-stmt">create-trigger-stmt</a>&nbsp;&nbsp; <a href="#sql-stmt">sql-stmt</a><br></br>
References:&nbsp;&nbsp; <a href="#expr">expr</a>&nbsp;&nbsp; <a href="#qualified-table-name">qualified-table-name</a>&nbsp;&nbsp; <a href="#with-clause">with-clause</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_createtrigger.html">lang_createtrigger.html</a>&nbsp;&nbsp; <a href="lang_delete.html">lang_delete.html</a>
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
See also:&nbsp;&nbsp; <a href="lang_dropview.html">lang_dropview.html</a>
</div>

<a name="expr"></a><h4>expr:</h4><div class='imgcontainer'>
<img src="images/syntax/expr.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#aggregate-function-invocation">aggregate-function-invocation</a>&nbsp;&nbsp; <a href="#attach-stmt">attach-stmt</a>&nbsp;&nbsp; <a href="#column-constraint">column-constraint</a>&nbsp;&nbsp; <a href="#compound-select-stmt">compound-select-stmt</a>&nbsp;&nbsp; <a href="#create-index-stmt">create-index-stmt</a>&nbsp;&nbsp; <a href="#create-trigger-stmt">create-trigger-stmt</a>&nbsp;&nbsp; <a href="#delete-stmt">delete-stmt</a>&nbsp;&nbsp; <a href="#delete-stmt-limited">delete-stmt-limited</a>&nbsp;&nbsp; <a href="#factored-select-stmt">factored-select-stmt</a>&nbsp;&nbsp; <a href="#filter-clause">filter-clause</a>&nbsp;&nbsp; <a href="#frame-spec">frame-spec</a>&nbsp;&nbsp; <a href="#indexed-column">indexed-column</a>&nbsp;&nbsp; <a href="#insert-stmt">insert-stmt</a>&nbsp;&nbsp; <a href="#join-constraint">join-constraint</a>&nbsp;&nbsp; <a href="#ordering-term">ordering-term</a>&nbsp;&nbsp; <a href="#over-clause">over-clause</a>&nbsp;&nbsp; <a href="#result-column">result-column</a>&nbsp;&nbsp; <a href="#select-core">select-core</a>&nbsp;&nbsp; <a href="#select-stmt">select-stmt</a>&nbsp;&nbsp; <a href="#simple-function-invocation">simple-function-invocation</a>&nbsp;&nbsp; <a href="#simple-select-stmt">simple-select-stmt</a>&nbsp;&nbsp; <a href="#table-constraint">table-constraint</a>&nbsp;&nbsp; <a href="#table-or-subquery">table-or-subquery</a>&nbsp;&nbsp; <a href="#update-stmt">update-stmt</a>&nbsp;&nbsp; <a href="#update-stmt-limited">update-stmt-limited</a>&nbsp;&nbsp; <a href="#upsert-clause">upsert-clause</a>&nbsp;&nbsp; <a href="#window-defn">window-defn</a>&nbsp;&nbsp; <a href="#window-function-invocation">window-function-invocation</a><br></br>
References:&nbsp;&nbsp; <a href="#filter-clause">filter-clause</a>&nbsp;&nbsp; <a href="#literal-value">literal-value</a>&nbsp;&nbsp; <a href="#over-clause">over-clause</a>&nbsp;&nbsp; <a href="#raise-function">raise-function</a>&nbsp;&nbsp; <a href="#select-stmt">select-stmt</a>&nbsp;&nbsp; <a href="#type-name">type-name</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_UPSERT.html">lang_UPSERT.html</a>&nbsp;&nbsp; <a href="lang_aggfunc.html">lang_aggfunc.html</a>&nbsp;&nbsp; <a href="lang_altertable.html">lang_altertable.html</a>&nbsp;&nbsp; <a href="lang_attach.html">lang_attach.html</a>&nbsp;&nbsp; <a href="lang_createindex.html">lang_createindex.html</a>&nbsp;&nbsp; <a href="lang_createtable.html">lang_createtable.html</a>&nbsp;&nbsp; <a href="lang_createtrigger.html">lang_createtrigger.html</a>&nbsp;&nbsp; <a href="lang_createview.html">lang_createview.html</a>&nbsp;&nbsp; <a href="lang_delete.html">lang_delete.html</a>&nbsp;&nbsp; <a href="lang_expr.html">lang_expr.html</a>&nbsp;&nbsp; <a href="lang_insert.html">lang_insert.html</a>&nbsp;&nbsp; <a href="lang_select.html">lang_select.html</a>&nbsp;&nbsp; <a href="lang_select.html#compound">lang_select.html#compound</a>&nbsp;&nbsp; <a href="lang_select.html#simpleselect">lang_select.html#simpleselect</a>&nbsp;&nbsp; <a href="lang_update.html">lang_update.html</a>&nbsp;&nbsp; <a href="lang_with.html">lang_with.html</a>&nbsp;&nbsp; <a href="partialindex.html">partialindex.html</a>
</div>

<a name="raise-function"></a><h4>raise-function:</h4><div class='imgcontainer'>
<img src="images/syntax/raise-function.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#expr">expr</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_UPSERT.html">lang_UPSERT.html</a>&nbsp;&nbsp; <a href="lang_aggfunc.html">lang_aggfunc.html</a>&nbsp;&nbsp; <a href="lang_altertable.html">lang_altertable.html</a>&nbsp;&nbsp; <a href="lang_attach.html">lang_attach.html</a>&nbsp;&nbsp; <a href="lang_createindex.html">lang_createindex.html</a>&nbsp;&nbsp; <a href="lang_createtable.html">lang_createtable.html</a>&nbsp;&nbsp; <a href="lang_createtrigger.html">lang_createtrigger.html</a>&nbsp;&nbsp; <a href="lang_createtrigger.html#raise">lang_createtrigger.html#raise</a>&nbsp;&nbsp; <a href="lang_createview.html">lang_createview.html</a>&nbsp;&nbsp; <a href="lang_delete.html">lang_delete.html</a>&nbsp;&nbsp; <a href="lang_expr.html">lang_expr.html</a>&nbsp;&nbsp; <a href="lang_insert.html">lang_insert.html</a>&nbsp;&nbsp; <a href="lang_select.html">lang_select.html</a>&nbsp;&nbsp; <a href="lang_select.html#compound">lang_select.html#compound</a>&nbsp;&nbsp; <a href="lang_select.html#simpleselect">lang_select.html#simpleselect</a>&nbsp;&nbsp; <a href="lang_update.html">lang_update.html</a>&nbsp;&nbsp; <a href="lang_with.html">lang_with.html</a>&nbsp;&nbsp; <a href="partialindex.html">partialindex.html</a>
</div>

<a name="literal-value"></a><h4>literal-value:</h4><div class='imgcontainer'>
<img src="images/syntax/literal-value.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#column-constraint">column-constraint</a>&nbsp;&nbsp; <a href="#expr">expr</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_UPSERT.html">lang_UPSERT.html</a>&nbsp;&nbsp; <a href="lang_aggfunc.html">lang_aggfunc.html</a>&nbsp;&nbsp; <a href="lang_altertable.html">lang_altertable.html</a>&nbsp;&nbsp; <a href="lang_attach.html">lang_attach.html</a>&nbsp;&nbsp; <a href="lang_createindex.html">lang_createindex.html</a>&nbsp;&nbsp; <a href="lang_createtable.html">lang_createtable.html</a>&nbsp;&nbsp; <a href="lang_createtrigger.html">lang_createtrigger.html</a>&nbsp;&nbsp; <a href="lang_createview.html">lang_createview.html</a>&nbsp;&nbsp; <a href="lang_delete.html">lang_delete.html</a>&nbsp;&nbsp; <a href="lang_expr.html">lang_expr.html</a>&nbsp;&nbsp; <a href="lang_insert.html">lang_insert.html</a>&nbsp;&nbsp; <a href="lang_select.html">lang_select.html</a>&nbsp;&nbsp; <a href="lang_select.html#compound">lang_select.html#compound</a>&nbsp;&nbsp; <a href="lang_select.html#simpleselect">lang_select.html#simpleselect</a>&nbsp;&nbsp; <a href="lang_update.html">lang_update.html</a>&nbsp;&nbsp; <a href="lang_with.html">lang_with.html</a>&nbsp;&nbsp; <a href="partialindex.html">partialindex.html</a>
</div>

<a name="numeric-literal"></a><h4>numeric-literal:</h4><div class='imgcontainer'>
<img src="images/syntax/numeric-literal.gif"></img><br></br><br></br>
See also:&nbsp;&nbsp; <a href="lang_expr.html#litvalue">lang_expr.html#litvalue</a>
</div>

<a name="insert-stmt"></a><h4>insert-stmt:</h4><div class='imgcontainer'>
<img src="images/syntax/insert-stmt.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#create-trigger-stmt">create-trigger-stmt</a>&nbsp;&nbsp; <a href="#sql-stmt">sql-stmt</a><br></br>
References:&nbsp;&nbsp; <a href="#expr">expr</a>&nbsp;&nbsp; <a href="#select-stmt">select-stmt</a>&nbsp;&nbsp; <a href="#upsert-clause">upsert-clause</a>&nbsp;&nbsp; <a href="#with-clause">with-clause</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_createtrigger.html">lang_createtrigger.html</a>&nbsp;&nbsp; <a href="lang_insert.html">lang_insert.html</a>
</div>

<a name="upsert-clause"></a><h4>upsert-clause:</h4><div class='imgcontainer'>
<img src="images/syntax/upsert-clause.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#insert-stmt">insert-stmt</a><br></br>
References:&nbsp;&nbsp; <a href="#column-name-list">column-name-list</a>&nbsp;&nbsp; <a href="#expr">expr</a>&nbsp;&nbsp; <a href="#indexed-column">indexed-column</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_UPSERT.html">lang_UPSERT.html</a>&nbsp;&nbsp; <a href="lang_createtrigger.html">lang_createtrigger.html</a>&nbsp;&nbsp; <a href="lang_insert.html">lang_insert.html</a>
</div>

<a name="pragma-stmt"></a><h4>pragma-stmt:</h4><div class='imgcontainer'>
<img src="images/syntax/pragma-stmt.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#sql-stmt">sql-stmt</a><br></br>
References:&nbsp;&nbsp; <a href="#pragma-value">pragma-value</a><br></br>
See also:&nbsp;&nbsp; <a href="pragma.html#syntax">pragma.html#syntax</a>







|





|





|


















|







316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
See also:&nbsp;&nbsp; <a href="lang_dropview.html">lang_dropview.html</a>
</div>

<a name="expr"></a><h4>expr:</h4><div class='imgcontainer'>
<img src="images/syntax/expr.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#aggregate-function-invocation">aggregate-function-invocation</a>&nbsp;&nbsp; <a href="#attach-stmt">attach-stmt</a>&nbsp;&nbsp; <a href="#column-constraint">column-constraint</a>&nbsp;&nbsp; <a href="#compound-select-stmt">compound-select-stmt</a>&nbsp;&nbsp; <a href="#create-index-stmt">create-index-stmt</a>&nbsp;&nbsp; <a href="#create-trigger-stmt">create-trigger-stmt</a>&nbsp;&nbsp; <a href="#delete-stmt">delete-stmt</a>&nbsp;&nbsp; <a href="#delete-stmt-limited">delete-stmt-limited</a>&nbsp;&nbsp; <a href="#factored-select-stmt">factored-select-stmt</a>&nbsp;&nbsp; <a href="#filter-clause">filter-clause</a>&nbsp;&nbsp; <a href="#frame-spec">frame-spec</a>&nbsp;&nbsp; <a href="#indexed-column">indexed-column</a>&nbsp;&nbsp; <a href="#insert-stmt">insert-stmt</a>&nbsp;&nbsp; <a href="#join-constraint">join-constraint</a>&nbsp;&nbsp; <a href="#ordering-term">ordering-term</a>&nbsp;&nbsp; <a href="#over-clause">over-clause</a>&nbsp;&nbsp; <a href="#result-column">result-column</a>&nbsp;&nbsp; <a href="#select-core">select-core</a>&nbsp;&nbsp; <a href="#select-stmt">select-stmt</a>&nbsp;&nbsp; <a href="#simple-function-invocation">simple-function-invocation</a>&nbsp;&nbsp; <a href="#simple-select-stmt">simple-select-stmt</a>&nbsp;&nbsp; <a href="#table-constraint">table-constraint</a>&nbsp;&nbsp; <a href="#table-or-subquery">table-or-subquery</a>&nbsp;&nbsp; <a href="#update-stmt">update-stmt</a>&nbsp;&nbsp; <a href="#update-stmt-limited">update-stmt-limited</a>&nbsp;&nbsp; <a href="#upsert-clause">upsert-clause</a>&nbsp;&nbsp; <a href="#window-defn">window-defn</a>&nbsp;&nbsp; <a href="#window-function-invocation">window-function-invocation</a><br></br>
References:&nbsp;&nbsp; <a href="#filter-clause">filter-clause</a>&nbsp;&nbsp; <a href="#literal-value">literal-value</a>&nbsp;&nbsp; <a href="#over-clause">over-clause</a>&nbsp;&nbsp; <a href="#raise-function">raise-function</a>&nbsp;&nbsp; <a href="#select-stmt">select-stmt</a>&nbsp;&nbsp; <a href="#type-name">type-name</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_aggfunc.html">lang_aggfunc.html</a>&nbsp;&nbsp; <a href="lang_altertable.html">lang_altertable.html</a>&nbsp;&nbsp; <a href="lang_attach.html">lang_attach.html</a>&nbsp;&nbsp; <a href="lang_createindex.html">lang_createindex.html</a>&nbsp;&nbsp; <a href="lang_createtable.html">lang_createtable.html</a>&nbsp;&nbsp; <a href="lang_createtrigger.html">lang_createtrigger.html</a>&nbsp;&nbsp; <a href="lang_createview.html">lang_createview.html</a>&nbsp;&nbsp; <a href="lang_delete.html">lang_delete.html</a>&nbsp;&nbsp; <a href="lang_expr.html">lang_expr.html</a>&nbsp;&nbsp; <a href="lang_insert.html">lang_insert.html</a>&nbsp;&nbsp; <a href="lang_select.html">lang_select.html</a>&nbsp;&nbsp; <a href="lang_select.html#compound">lang_select.html#compound</a>&nbsp;&nbsp; <a href="lang_select.html#simpleselect">lang_select.html#simpleselect</a>&nbsp;&nbsp; <a href="lang_update.html">lang_update.html</a>&nbsp;&nbsp; <a href="lang_upsert.html">lang_upsert.html</a>&nbsp;&nbsp; <a href="lang_with.html">lang_with.html</a>&nbsp;&nbsp; <a href="partialindex.html">partialindex.html</a>
</div>

<a name="raise-function"></a><h4>raise-function:</h4><div class='imgcontainer'>
<img src="images/syntax/raise-function.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#expr">expr</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_aggfunc.html">lang_aggfunc.html</a>&nbsp;&nbsp; <a href="lang_altertable.html">lang_altertable.html</a>&nbsp;&nbsp; <a href="lang_attach.html">lang_attach.html</a>&nbsp;&nbsp; <a href="lang_createindex.html">lang_createindex.html</a>&nbsp;&nbsp; <a href="lang_createtable.html">lang_createtable.html</a>&nbsp;&nbsp; <a href="lang_createtrigger.html">lang_createtrigger.html</a>&nbsp;&nbsp; <a href="lang_createtrigger.html#raise">lang_createtrigger.html#raise</a>&nbsp;&nbsp; <a href="lang_createview.html">lang_createview.html</a>&nbsp;&nbsp; <a href="lang_delete.html">lang_delete.html</a>&nbsp;&nbsp; <a href="lang_expr.html">lang_expr.html</a>&nbsp;&nbsp; <a href="lang_insert.html">lang_insert.html</a>&nbsp;&nbsp; <a href="lang_select.html">lang_select.html</a>&nbsp;&nbsp; <a href="lang_select.html#compound">lang_select.html#compound</a>&nbsp;&nbsp; <a href="lang_select.html#simpleselect">lang_select.html#simpleselect</a>&nbsp;&nbsp; <a href="lang_update.html">lang_update.html</a>&nbsp;&nbsp; <a href="lang_upsert.html">lang_upsert.html</a>&nbsp;&nbsp; <a href="lang_with.html">lang_with.html</a>&nbsp;&nbsp; <a href="partialindex.html">partialindex.html</a>
</div>

<a name="literal-value"></a><h4>literal-value:</h4><div class='imgcontainer'>
<img src="images/syntax/literal-value.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#column-constraint">column-constraint</a>&nbsp;&nbsp; <a href="#expr">expr</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_aggfunc.html">lang_aggfunc.html</a>&nbsp;&nbsp; <a href="lang_altertable.html">lang_altertable.html</a>&nbsp;&nbsp; <a href="lang_attach.html">lang_attach.html</a>&nbsp;&nbsp; <a href="lang_createindex.html">lang_createindex.html</a>&nbsp;&nbsp; <a href="lang_createtable.html">lang_createtable.html</a>&nbsp;&nbsp; <a href="lang_createtrigger.html">lang_createtrigger.html</a>&nbsp;&nbsp; <a href="lang_createview.html">lang_createview.html</a>&nbsp;&nbsp; <a href="lang_delete.html">lang_delete.html</a>&nbsp;&nbsp; <a href="lang_expr.html">lang_expr.html</a>&nbsp;&nbsp; <a href="lang_insert.html">lang_insert.html</a>&nbsp;&nbsp; <a href="lang_select.html">lang_select.html</a>&nbsp;&nbsp; <a href="lang_select.html#compound">lang_select.html#compound</a>&nbsp;&nbsp; <a href="lang_select.html#simpleselect">lang_select.html#simpleselect</a>&nbsp;&nbsp; <a href="lang_update.html">lang_update.html</a>&nbsp;&nbsp; <a href="lang_upsert.html">lang_upsert.html</a>&nbsp;&nbsp; <a href="lang_with.html">lang_with.html</a>&nbsp;&nbsp; <a href="partialindex.html">partialindex.html</a>
</div>

<a name="numeric-literal"></a><h4>numeric-literal:</h4><div class='imgcontainer'>
<img src="images/syntax/numeric-literal.gif"></img><br></br><br></br>
See also:&nbsp;&nbsp; <a href="lang_expr.html#litvalue">lang_expr.html#litvalue</a>
</div>

<a name="insert-stmt"></a><h4>insert-stmt:</h4><div class='imgcontainer'>
<img src="images/syntax/insert-stmt.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#create-trigger-stmt">create-trigger-stmt</a>&nbsp;&nbsp; <a href="#sql-stmt">sql-stmt</a><br></br>
References:&nbsp;&nbsp; <a href="#expr">expr</a>&nbsp;&nbsp; <a href="#select-stmt">select-stmt</a>&nbsp;&nbsp; <a href="#upsert-clause">upsert-clause</a>&nbsp;&nbsp; <a href="#with-clause">with-clause</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_createtrigger.html">lang_createtrigger.html</a>&nbsp;&nbsp; <a href="lang_insert.html">lang_insert.html</a>
</div>

<a name="upsert-clause"></a><h4>upsert-clause:</h4><div class='imgcontainer'>
<img src="images/syntax/upsert-clause.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#insert-stmt">insert-stmt</a><br></br>
References:&nbsp;&nbsp; <a href="#column-name-list">column-name-list</a>&nbsp;&nbsp; <a href="#expr">expr</a>&nbsp;&nbsp; <a href="#indexed-column">indexed-column</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_createtrigger.html">lang_createtrigger.html</a>&nbsp;&nbsp; <a href="lang_insert.html">lang_insert.html</a>&nbsp;&nbsp; <a href="lang_upsert.html">lang_upsert.html</a>
</div>

<a name="pragma-stmt"></a><h4>pragma-stmt:</h4><div class='imgcontainer'>
<img src="images/syntax/pragma-stmt.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#sql-stmt">sql-stmt</a><br></br>
References:&nbsp;&nbsp; <a href="#pragma-value">pragma-value</a><br></br>
See also:&nbsp;&nbsp; <a href="pragma.html#syntax">pragma.html#syntax</a>
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
See also:&nbsp;&nbsp; <a href="lang_reindex.html">lang_reindex.html</a>
</div>

<a name="select-stmt"></a><h4>select-stmt:</h4><div class='imgcontainer'>
<img src="images/syntax/select-stmt.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#common-table-expression">common-table-expression</a>&nbsp;&nbsp; <a href="#create-table-stmt">create-table-stmt</a>&nbsp;&nbsp; <a href="#create-trigger-stmt">create-trigger-stmt</a>&nbsp;&nbsp; <a href="#create-view-stmt">create-view-stmt</a>&nbsp;&nbsp; <a href="#expr">expr</a>&nbsp;&nbsp; <a href="#insert-stmt">insert-stmt</a>&nbsp;&nbsp; <a href="#sql-stmt">sql-stmt</a>&nbsp;&nbsp; <a href="#table-or-subquery">table-or-subquery</a>&nbsp;&nbsp; <a href="#with-clause">with-clause</a><br></br>
References:&nbsp;&nbsp; <a href="#common-table-expression">common-table-expression</a>&nbsp;&nbsp; <a href="#compound-operator">compound-operator</a>&nbsp;&nbsp; <a href="#expr">expr</a>&nbsp;&nbsp; <a href="#join-clause">join-clause</a>&nbsp;&nbsp; <a href="#ordering-term">ordering-term</a>&nbsp;&nbsp; <a href="#result-column">result-column</a>&nbsp;&nbsp; <a href="#table-or-subquery">table-or-subquery</a>&nbsp;&nbsp; <a href="#window-defn">window-defn</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_UPSERT.html">lang_UPSERT.html</a>&nbsp;&nbsp; <a href="lang_aggfunc.html">lang_aggfunc.html</a>&nbsp;&nbsp; <a href="lang_altertable.html">lang_altertable.html</a>&nbsp;&nbsp; <a href="lang_attach.html">lang_attach.html</a>&nbsp;&nbsp; <a href="lang_createindex.html">lang_createindex.html</a>&nbsp;&nbsp; <a href="lang_createtable.html">lang_createtable.html</a>&nbsp;&nbsp; <a href="lang_createtrigger.html">lang_createtrigger.html</a>&nbsp;&nbsp; <a href="lang_createview.html">lang_createview.html</a>&nbsp;&nbsp; <a href="lang_delete.html">lang_delete.html</a>&nbsp;&nbsp; <a href="lang_expr.html">lang_expr.html</a>&nbsp;&nbsp; <a href="lang_insert.html">lang_insert.html</a>&nbsp;&nbsp; <a href="lang_select.html">lang_select.html</a>&nbsp;&nbsp; <a href="lang_select.html#compound">lang_select.html#compound</a>&nbsp;&nbsp; <a href="lang_select.html#simpleselect">lang_select.html#simpleselect</a>&nbsp;&nbsp; <a href="lang_update.html">lang_update.html</a>&nbsp;&nbsp; <a href="lang_with.html">lang_with.html</a>&nbsp;&nbsp; <a href="lang_with.html#recursivecte">lang_with.html#recursivecte</a>&nbsp;&nbsp; <a href="partialindex.html">partialindex.html</a>
</div>

<a name="join-clause"></a><h4>join-clause:</h4><div class='imgcontainer'>
<img src="images/syntax/join-clause.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#select-core">select-core</a>&nbsp;&nbsp; <a href="#select-stmt">select-stmt</a>&nbsp;&nbsp; <a href="#table-or-subquery">table-or-subquery</a><br></br>
References:&nbsp;&nbsp; <a href="#join-constraint">join-constraint</a>&nbsp;&nbsp; <a href="#join-operator">join-operator</a>&nbsp;&nbsp; <a href="#table-or-subquery">table-or-subquery</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_UPSERT.html">lang_UPSERT.html</a>&nbsp;&nbsp; <a href="lang_aggfunc.html">lang_aggfunc.html</a>&nbsp;&nbsp; <a href="lang_altertable.html">lang_altertable.html</a>&nbsp;&nbsp; <a href="lang_attach.html">lang_attach.html</a>&nbsp;&nbsp; <a href="lang_createindex.html">lang_createindex.html</a>&nbsp;&nbsp; <a href="lang_createtable.html">lang_createtable.html</a>&nbsp;&nbsp; <a href="lang_createtrigger.html">lang_createtrigger.html</a>&nbsp;&nbsp; <a href="lang_createview.html">lang_createview.html</a>&nbsp;&nbsp; <a href="lang_delete.html">lang_delete.html</a>&nbsp;&nbsp; <a href="lang_expr.html">lang_expr.html</a>&nbsp;&nbsp; <a href="lang_insert.html">lang_insert.html</a>&nbsp;&nbsp; <a href="lang_select.html">lang_select.html</a>&nbsp;&nbsp; <a href="lang_select.html#compound">lang_select.html#compound</a>&nbsp;&nbsp; <a href="lang_select.html#simpleselect">lang_select.html#simpleselect</a>&nbsp;&nbsp; <a href="lang_update.html">lang_update.html</a>&nbsp;&nbsp; <a href="lang_with.html">lang_with.html</a>&nbsp;&nbsp; <a href="partialindex.html">partialindex.html</a>
</div>

<a name="select-core"></a><h4>select-core:</h4><div class='imgcontainer'>
<img src="images/syntax/select-core.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#compound-select-stmt">compound-select-stmt</a>&nbsp;&nbsp; <a href="#factored-select-stmt">factored-select-stmt</a>&nbsp;&nbsp; <a href="#simple-select-stmt">simple-select-stmt</a><br></br>
References:&nbsp;&nbsp; <a href="#expr">expr</a>&nbsp;&nbsp; <a href="#join-clause">join-clause</a>&nbsp;&nbsp; <a href="#result-column">result-column</a>&nbsp;&nbsp; <a href="#table-or-subquery">table-or-subquery</a>&nbsp;&nbsp; <a href="#window-defn">window-defn</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_select.html">lang_select.html</a>&nbsp;&nbsp; <a href="lang_select.html#compound">lang_select.html#compound</a>&nbsp;&nbsp; <a href="lang_select.html#simpleselect">lang_select.html#simpleselect</a>







|






|







374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
See also:&nbsp;&nbsp; <a href="lang_reindex.html">lang_reindex.html</a>
</div>

<a name="select-stmt"></a><h4>select-stmt:</h4><div class='imgcontainer'>
<img src="images/syntax/select-stmt.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#common-table-expression">common-table-expression</a>&nbsp;&nbsp; <a href="#create-table-stmt">create-table-stmt</a>&nbsp;&nbsp; <a href="#create-trigger-stmt">create-trigger-stmt</a>&nbsp;&nbsp; <a href="#create-view-stmt">create-view-stmt</a>&nbsp;&nbsp; <a href="#expr">expr</a>&nbsp;&nbsp; <a href="#insert-stmt">insert-stmt</a>&nbsp;&nbsp; <a href="#sql-stmt">sql-stmt</a>&nbsp;&nbsp; <a href="#table-or-subquery">table-or-subquery</a>&nbsp;&nbsp; <a href="#with-clause">with-clause</a><br></br>
References:&nbsp;&nbsp; <a href="#common-table-expression">common-table-expression</a>&nbsp;&nbsp; <a href="#compound-operator">compound-operator</a>&nbsp;&nbsp; <a href="#expr">expr</a>&nbsp;&nbsp; <a href="#join-clause">join-clause</a>&nbsp;&nbsp; <a href="#ordering-term">ordering-term</a>&nbsp;&nbsp; <a href="#result-column">result-column</a>&nbsp;&nbsp; <a href="#table-or-subquery">table-or-subquery</a>&nbsp;&nbsp; <a href="#window-defn">window-defn</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_aggfunc.html">lang_aggfunc.html</a>&nbsp;&nbsp; <a href="lang_altertable.html">lang_altertable.html</a>&nbsp;&nbsp; <a href="lang_attach.html">lang_attach.html</a>&nbsp;&nbsp; <a href="lang_createindex.html">lang_createindex.html</a>&nbsp;&nbsp; <a href="lang_createtable.html">lang_createtable.html</a>&nbsp;&nbsp; <a href="lang_createtrigger.html">lang_createtrigger.html</a>&nbsp;&nbsp; <a href="lang_createview.html">lang_createview.html</a>&nbsp;&nbsp; <a href="lang_delete.html">lang_delete.html</a>&nbsp;&nbsp; <a href="lang_expr.html">lang_expr.html</a>&nbsp;&nbsp; <a href="lang_insert.html">lang_insert.html</a>&nbsp;&nbsp; <a href="lang_select.html">lang_select.html</a>&nbsp;&nbsp; <a href="lang_select.html#compound">lang_select.html#compound</a>&nbsp;&nbsp; <a href="lang_select.html#simpleselect">lang_select.html#simpleselect</a>&nbsp;&nbsp; <a href="lang_update.html">lang_update.html</a>&nbsp;&nbsp; <a href="lang_upsert.html">lang_upsert.html</a>&nbsp;&nbsp; <a href="lang_with.html">lang_with.html</a>&nbsp;&nbsp; <a href="lang_with.html#recursivecte">lang_with.html#recursivecte</a>&nbsp;&nbsp; <a href="partialindex.html">partialindex.html</a>
</div>

<a name="join-clause"></a><h4>join-clause:</h4><div class='imgcontainer'>
<img src="images/syntax/join-clause.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#select-core">select-core</a>&nbsp;&nbsp; <a href="#select-stmt">select-stmt</a>&nbsp;&nbsp; <a href="#table-or-subquery">table-or-subquery</a><br></br>
References:&nbsp;&nbsp; <a href="#join-constraint">join-constraint</a>&nbsp;&nbsp; <a href="#join-operator">join-operator</a>&nbsp;&nbsp; <a href="#table-or-subquery">table-or-subquery</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_aggfunc.html">lang_aggfunc.html</a>&nbsp;&nbsp; <a href="lang_altertable.html">lang_altertable.html</a>&nbsp;&nbsp; <a href="lang_attach.html">lang_attach.html</a>&nbsp;&nbsp; <a href="lang_createindex.html">lang_createindex.html</a>&nbsp;&nbsp; <a href="lang_createtable.html">lang_createtable.html</a>&nbsp;&nbsp; <a href="lang_createtrigger.html">lang_createtrigger.html</a>&nbsp;&nbsp; <a href="lang_createview.html">lang_createview.html</a>&nbsp;&nbsp; <a href="lang_delete.html">lang_delete.html</a>&nbsp;&nbsp; <a href="lang_expr.html">lang_expr.html</a>&nbsp;&nbsp; <a href="lang_insert.html">lang_insert.html</a>&nbsp;&nbsp; <a href="lang_select.html">lang_select.html</a>&nbsp;&nbsp; <a href="lang_select.html#compound">lang_select.html#compound</a>&nbsp;&nbsp; <a href="lang_select.html#simpleselect">lang_select.html#simpleselect</a>&nbsp;&nbsp; <a href="lang_update.html">lang_update.html</a>&nbsp;&nbsp; <a href="lang_upsert.html">lang_upsert.html</a>&nbsp;&nbsp; <a href="lang_with.html">lang_with.html</a>&nbsp;&nbsp; <a href="partialindex.html">partialindex.html</a>
</div>

<a name="select-core"></a><h4>select-core:</h4><div class='imgcontainer'>
<img src="images/syntax/select-core.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#compound-select-stmt">compound-select-stmt</a>&nbsp;&nbsp; <a href="#factored-select-stmt">factored-select-stmt</a>&nbsp;&nbsp; <a href="#simple-select-stmt">simple-select-stmt</a><br></br>
References:&nbsp;&nbsp; <a href="#expr">expr</a>&nbsp;&nbsp; <a href="#join-clause">join-clause</a>&nbsp;&nbsp; <a href="#result-column">result-column</a>&nbsp;&nbsp; <a href="#table-or-subquery">table-or-subquery</a>&nbsp;&nbsp; <a href="#window-defn">window-defn</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_select.html">lang_select.html</a>&nbsp;&nbsp; <a href="lang_select.html#compound">lang_select.html#compound</a>&nbsp;&nbsp; <a href="lang_select.html#simpleselect">lang_select.html#simpleselect</a>
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
See also:&nbsp;&nbsp; <a href="lang_select.html#compound">lang_select.html#compound</a>
</div>

<a name="table-or-subquery"></a><h4>table-or-subquery:</h4><div class='imgcontainer'>
<img src="images/syntax/table-or-subquery.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#join-clause">join-clause</a>&nbsp;&nbsp; <a href="#select-core">select-core</a>&nbsp;&nbsp; <a href="#select-stmt">select-stmt</a><br></br>
References:&nbsp;&nbsp; <a href="#expr">expr</a>&nbsp;&nbsp; <a href="#join-clause">join-clause</a>&nbsp;&nbsp; <a href="#select-stmt">select-stmt</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_UPSERT.html">lang_UPSERT.html</a>&nbsp;&nbsp; <a href="lang_aggfunc.html">lang_aggfunc.html</a>&nbsp;&nbsp; <a href="lang_altertable.html">lang_altertable.html</a>&nbsp;&nbsp; <a href="lang_attach.html">lang_attach.html</a>&nbsp;&nbsp; <a href="lang_createindex.html">lang_createindex.html</a>&nbsp;&nbsp; <a href="lang_createtable.html">lang_createtable.html</a>&nbsp;&nbsp; <a href="lang_createtrigger.html">lang_createtrigger.html</a>&nbsp;&nbsp; <a href="lang_createview.html">lang_createview.html</a>&nbsp;&nbsp; <a href="lang_delete.html">lang_delete.html</a>&nbsp;&nbsp; <a href="lang_expr.html">lang_expr.html</a>&nbsp;&nbsp; <a href="lang_insert.html">lang_insert.html</a>&nbsp;&nbsp; <a href="lang_select.html">lang_select.html</a>&nbsp;&nbsp; <a href="lang_select.html#compound">lang_select.html#compound</a>&nbsp;&nbsp; <a href="lang_select.html#simpleselect">lang_select.html#simpleselect</a>&nbsp;&nbsp; <a href="lang_update.html">lang_update.html</a>&nbsp;&nbsp; <a href="lang_with.html">lang_with.html</a>&nbsp;&nbsp; <a href="partialindex.html">partialindex.html</a>
</div>

<a name="result-column"></a><h4>result-column:</h4><div class='imgcontainer'>
<img src="images/syntax/result-column.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#select-core">select-core</a>&nbsp;&nbsp; <a href="#select-stmt">select-stmt</a><br></br>
References:&nbsp;&nbsp; <a href="#expr">expr</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_UPSERT.html">lang_UPSERT.html</a>&nbsp;&nbsp; <a href="lang_aggfunc.html">lang_aggfunc.html</a>&nbsp;&nbsp; <a href="lang_altertable.html">lang_altertable.html</a>&nbsp;&nbsp; <a href="lang_attach.html">lang_attach.html</a>&nbsp;&nbsp; <a href="lang_createindex.html">lang_createindex.html</a>&nbsp;&nbsp; <a href="lang_createtable.html">lang_createtable.html</a>&nbsp;&nbsp; <a href="lang_createtrigger.html">lang_createtrigger.html</a>&nbsp;&nbsp; <a href="lang_createview.html">lang_createview.html</a>&nbsp;&nbsp; <a href="lang_delete.html">lang_delete.html</a>&nbsp;&nbsp; <a href="lang_expr.html">lang_expr.html</a>&nbsp;&nbsp; <a href="lang_insert.html">lang_insert.html</a>&nbsp;&nbsp; <a href="lang_select.html">lang_select.html</a>&nbsp;&nbsp; <a href="lang_select.html#compound">lang_select.html#compound</a>&nbsp;&nbsp; <a href="lang_select.html#simpleselect">lang_select.html#simpleselect</a>&nbsp;&nbsp; <a href="lang_update.html">lang_update.html</a>&nbsp;&nbsp; <a href="lang_with.html">lang_with.html</a>&nbsp;&nbsp; <a href="partialindex.html">partialindex.html</a>
</div>

<a name="join-operator"></a><h4>join-operator:</h4><div class='imgcontainer'>
<img src="images/syntax/join-operator.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#join-clause">join-clause</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_UPSERT.html">lang_UPSERT.html</a>&nbsp;&nbsp; <a href="lang_aggfunc.html">lang_aggfunc.html</a>&nbsp;&nbsp; <a href="lang_altertable.html">lang_altertable.html</a>&nbsp;&nbsp; <a href="lang_attach.html">lang_attach.html</a>&nbsp;&nbsp; <a href="lang_createindex.html">lang_createindex.html</a>&nbsp;&nbsp; <a href="lang_createtable.html">lang_createtable.html</a>&nbsp;&nbsp; <a href="lang_createtrigger.html">lang_createtrigger.html</a>&nbsp;&nbsp; <a href="lang_createview.html">lang_createview.html</a>&nbsp;&nbsp; <a href="lang_delete.html">lang_delete.html</a>&nbsp;&nbsp; <a href="lang_expr.html">lang_expr.html</a>&nbsp;&nbsp; <a href="lang_insert.html">lang_insert.html</a>&nbsp;&nbsp; <a href="lang_select.html">lang_select.html</a>&nbsp;&nbsp; <a href="lang_select.html#compound">lang_select.html#compound</a>&nbsp;&nbsp; <a href="lang_select.html#fromclause">lang_select.html#fromclause</a>&nbsp;&nbsp; <a href="lang_select.html#simpleselect">lang_select.html#simpleselect</a>&nbsp;&nbsp; <a href="lang_update.html">lang_update.html</a>&nbsp;&nbsp; <a href="lang_with.html">lang_with.html</a>&nbsp;&nbsp; <a href="partialindex.html">partialindex.html</a>
</div>

<a name="join-constraint"></a><h4>join-constraint:</h4><div class='imgcontainer'>
<img src="images/syntax/join-constraint.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#join-clause">join-clause</a><br></br>
References:&nbsp;&nbsp; <a href="#expr">expr</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_UPSERT.html">lang_UPSERT.html</a>&nbsp;&nbsp; <a href="lang_aggfunc.html">lang_aggfunc.html</a>&nbsp;&nbsp; <a href="lang_altertable.html">lang_altertable.html</a>&nbsp;&nbsp; <a href="lang_attach.html">lang_attach.html</a>&nbsp;&nbsp; <a href="lang_createindex.html">lang_createindex.html</a>&nbsp;&nbsp; <a href="lang_createtable.html">lang_createtable.html</a>&nbsp;&nbsp; <a href="lang_createtrigger.html">lang_createtrigger.html</a>&nbsp;&nbsp; <a href="lang_createview.html">lang_createview.html</a>&nbsp;&nbsp; <a href="lang_delete.html">lang_delete.html</a>&nbsp;&nbsp; <a href="lang_expr.html">lang_expr.html</a>&nbsp;&nbsp; <a href="lang_insert.html">lang_insert.html</a>&nbsp;&nbsp; <a href="lang_select.html">lang_select.html</a>&nbsp;&nbsp; <a href="lang_select.html#compound">lang_select.html#compound</a>&nbsp;&nbsp; <a href="lang_select.html#fromclause">lang_select.html#fromclause</a>&nbsp;&nbsp; <a href="lang_select.html#simpleselect">lang_select.html#simpleselect</a>&nbsp;&nbsp; <a href="lang_update.html">lang_update.html</a>&nbsp;&nbsp; <a href="lang_with.html">lang_with.html</a>&nbsp;&nbsp; <a href="partialindex.html">partialindex.html</a>
</div>

<a name="ordering-term"></a><h4>ordering-term:</h4><div class='imgcontainer'>
<img src="images/syntax/ordering-term.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#compound-select-stmt">compound-select-stmt</a>&nbsp;&nbsp; <a href="#delete-stmt-limited">delete-stmt-limited</a>&nbsp;&nbsp; <a href="#factored-select-stmt">factored-select-stmt</a>&nbsp;&nbsp; <a href="#over-clause">over-clause</a>&nbsp;&nbsp; <a href="#select-stmt">select-stmt</a>&nbsp;&nbsp; <a href="#simple-select-stmt">simple-select-stmt</a>&nbsp;&nbsp; <a href="#update-stmt-limited">update-stmt-limited</a>&nbsp;&nbsp; <a href="#window-defn">window-defn</a><br></br>
References:&nbsp;&nbsp; <a href="#expr">expr</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_UPSERT.html">lang_UPSERT.html</a>&nbsp;&nbsp; <a href="lang_aggfunc.html">lang_aggfunc.html</a>&nbsp;&nbsp; <a href="lang_altertable.html">lang_altertable.html</a>&nbsp;&nbsp; <a href="lang_attach.html">lang_attach.html</a>&nbsp;&nbsp; <a href="lang_createindex.html">lang_createindex.html</a>&nbsp;&nbsp; <a href="lang_createtable.html">lang_createtable.html</a>&nbsp;&nbsp; <a href="lang_createtrigger.html">lang_createtrigger.html</a>&nbsp;&nbsp; <a href="lang_createview.html">lang_createview.html</a>&nbsp;&nbsp; <a href="lang_delete.html">lang_delete.html</a>&nbsp;&nbsp; <a href="lang_expr.html">lang_expr.html</a>&nbsp;&nbsp; <a href="lang_insert.html">lang_insert.html</a>&nbsp;&nbsp; <a href="lang_select.html">lang_select.html</a>&nbsp;&nbsp; <a href="lang_select.html#compound">lang_select.html#compound</a>&nbsp;&nbsp; <a href="lang_select.html#simpleselect">lang_select.html#simpleselect</a>&nbsp;&nbsp; <a href="lang_update.html">lang_update.html</a>&nbsp;&nbsp; <a href="lang_with.html">lang_with.html</a>&nbsp;&nbsp; <a href="partialindex.html">partialindex.html</a>
</div>

<a name="compound-operator"></a><h4>compound-operator:</h4><div class='imgcontainer'>
<img src="images/syntax/compound-operator.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#factored-select-stmt">factored-select-stmt</a>&nbsp;&nbsp; <a href="#select-stmt">select-stmt</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_UPSERT.html">lang_UPSERT.html</a>&nbsp;&nbsp; <a href="lang_aggfunc.html">lang_aggfunc.html</a>&nbsp;&nbsp; <a href="lang_altertable.html">lang_altertable.html</a>&nbsp;&nbsp; <a href="lang_attach.html">lang_attach.html</a>&nbsp;&nbsp; <a href="lang_createindex.html">lang_createindex.html</a>&nbsp;&nbsp; <a href="lang_createtable.html">lang_createtable.html</a>&nbsp;&nbsp; <a href="lang_createtrigger.html">lang_createtrigger.html</a>&nbsp;&nbsp; <a href="lang_createview.html">lang_createview.html</a>&nbsp;&nbsp; <a href="lang_delete.html">lang_delete.html</a>&nbsp;&nbsp; <a href="lang_expr.html">lang_expr.html</a>&nbsp;&nbsp; <a href="lang_insert.html">lang_insert.html</a>&nbsp;&nbsp; <a href="lang_select.html">lang_select.html</a>&nbsp;&nbsp; <a href="lang_select.html#compound">lang_select.html#compound</a>&nbsp;&nbsp; <a href="lang_select.html#simpleselect">lang_select.html#simpleselect</a>&nbsp;&nbsp; <a href="lang_update.html">lang_update.html</a>&nbsp;&nbsp; <a href="lang_with.html">lang_with.html</a>&nbsp;&nbsp; <a href="lang_with.html#recursivecte">lang_with.html#recursivecte</a>&nbsp;&nbsp; <a href="partialindex.html">partialindex.html</a>
</div>

<a name="update-stmt"></a><h4>update-stmt:</h4><div class='imgcontainer'>
<img src="images/syntax/update-stmt.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#create-trigger-stmt">create-trigger-stmt</a>&nbsp;&nbsp; <a href="#sql-stmt">sql-stmt</a><br></br>
References:&nbsp;&nbsp; <a href="#column-name-list">column-name-list</a>&nbsp;&nbsp; <a href="#expr">expr</a>&nbsp;&nbsp; <a href="#qualified-table-name">qualified-table-name</a>&nbsp;&nbsp; <a href="#with-clause">with-clause</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_createtrigger.html">lang_createtrigger.html</a>&nbsp;&nbsp; <a href="lang_update.html">lang_update.html</a>
</div>

<a name="column-name-list"></a><h4>column-name-list:</h4><div class='imgcontainer'>
<img src="images/syntax/column-name-list.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#update-stmt">update-stmt</a>&nbsp;&nbsp; <a href="#update-stmt-limited">update-stmt-limited</a>&nbsp;&nbsp; <a href="#upsert-clause">upsert-clause</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_UPSERT.html">lang_UPSERT.html</a>&nbsp;&nbsp; <a href="lang_createtrigger.html">lang_createtrigger.html</a>&nbsp;&nbsp; <a href="lang_insert.html">lang_insert.html</a>&nbsp;&nbsp; <a href="lang_update.html">lang_update.html</a>
</div>

<a name="update-stmt-limited"></a><h4>update-stmt-limited:</h4><div class='imgcontainer'>
<img src="images/syntax/update-stmt-limited.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#sql-stmt">sql-stmt</a><br></br>
References:&nbsp;&nbsp; <a href="#column-name-list">column-name-list</a>&nbsp;&nbsp; <a href="#expr">expr</a>&nbsp;&nbsp; <a href="#ordering-term">ordering-term</a>&nbsp;&nbsp; <a href="#qualified-table-name">qualified-table-name</a>&nbsp;&nbsp; <a href="#with-clause">with-clause</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_update.html">lang_update.html</a>







|






|





|






|






|





|












|







413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
See also:&nbsp;&nbsp; <a href="lang_select.html#compound">lang_select.html#compound</a>
</div>

<a name="table-or-subquery"></a><h4>table-or-subquery:</h4><div class='imgcontainer'>
<img src="images/syntax/table-or-subquery.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#join-clause">join-clause</a>&nbsp;&nbsp; <a href="#select-core">select-core</a>&nbsp;&nbsp; <a href="#select-stmt">select-stmt</a><br></br>
References:&nbsp;&nbsp; <a href="#expr">expr</a>&nbsp;&nbsp; <a href="#join-clause">join-clause</a>&nbsp;&nbsp; <a href="#select-stmt">select-stmt</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_aggfunc.html">lang_aggfunc.html</a>&nbsp;&nbsp; <a href="lang_altertable.html">lang_altertable.html</a>&nbsp;&nbsp; <a href="lang_attach.html">lang_attach.html</a>&nbsp;&nbsp; <a href="lang_createindex.html">lang_createindex.html</a>&nbsp;&nbsp; <a href="lang_createtable.html">lang_createtable.html</a>&nbsp;&nbsp; <a href="lang_createtrigger.html">lang_createtrigger.html</a>&nbsp;&nbsp; <a href="lang_createview.html">lang_createview.html</a>&nbsp;&nbsp; <a href="lang_delete.html">lang_delete.html</a>&nbsp;&nbsp; <a href="lang_expr.html">lang_expr.html</a>&nbsp;&nbsp; <a href="lang_insert.html">lang_insert.html</a>&nbsp;&nbsp; <a href="lang_select.html">lang_select.html</a>&nbsp;&nbsp; <a href="lang_select.html#compound">lang_select.html#compound</a>&nbsp;&nbsp; <a href="lang_select.html#simpleselect">lang_select.html#simpleselect</a>&nbsp;&nbsp; <a href="lang_update.html">lang_update.html</a>&nbsp;&nbsp; <a href="lang_upsert.html">lang_upsert.html</a>&nbsp;&nbsp; <a href="lang_with.html">lang_with.html</a>&nbsp;&nbsp; <a href="partialindex.html">partialindex.html</a>
</div>

<a name="result-column"></a><h4>result-column:</h4><div class='imgcontainer'>
<img src="images/syntax/result-column.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#select-core">select-core</a>&nbsp;&nbsp; <a href="#select-stmt">select-stmt</a><br></br>
References:&nbsp;&nbsp; <a href="#expr">expr</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_aggfunc.html">lang_aggfunc.html</a>&nbsp;&nbsp; <a href="lang_altertable.html">lang_altertable.html</a>&nbsp;&nbsp; <a href="lang_attach.html">lang_attach.html</a>&nbsp;&nbsp; <a href="lang_createindex.html">lang_createindex.html</a>&nbsp;&nbsp; <a href="lang_createtable.html">lang_createtable.html</a>&nbsp;&nbsp; <a href="lang_createtrigger.html">lang_createtrigger.html</a>&nbsp;&nbsp; <a href="lang_createview.html">lang_createview.html</a>&nbsp;&nbsp; <a href="lang_delete.html">lang_delete.html</a>&nbsp;&nbsp; <a href="lang_expr.html">lang_expr.html</a>&nbsp;&nbsp; <a href="lang_insert.html">lang_insert.html</a>&nbsp;&nbsp; <a href="lang_select.html">lang_select.html</a>&nbsp;&nbsp; <a href="lang_select.html#compound">lang_select.html#compound</a>&nbsp;&nbsp; <a href="lang_select.html#simpleselect">lang_select.html#simpleselect</a>&nbsp;&nbsp; <a href="lang_update.html">lang_update.html</a>&nbsp;&nbsp; <a href="lang_upsert.html">lang_upsert.html</a>&nbsp;&nbsp; <a href="lang_with.html">lang_with.html</a>&nbsp;&nbsp; <a href="partialindex.html">partialindex.html</a>
</div>

<a name="join-operator"></a><h4>join-operator:</h4><div class='imgcontainer'>
<img src="images/syntax/join-operator.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#join-clause">join-clause</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_aggfunc.html">lang_aggfunc.html</a>&nbsp;&nbsp; <a href="lang_altertable.html">lang_altertable.html</a>&nbsp;&nbsp; <a href="lang_attach.html">lang_attach.html</a>&nbsp;&nbsp; <a href="lang_createindex.html">lang_createindex.html</a>&nbsp;&nbsp; <a href="lang_createtable.html">lang_createtable.html</a>&nbsp;&nbsp; <a href="lang_createtrigger.html">lang_createtrigger.html</a>&nbsp;&nbsp; <a href="lang_createview.html">lang_createview.html</a>&nbsp;&nbsp; <a href="lang_delete.html">lang_delete.html</a>&nbsp;&nbsp; <a href="lang_expr.html">lang_expr.html</a>&nbsp;&nbsp; <a href="lang_insert.html">lang_insert.html</a>&nbsp;&nbsp; <a href="lang_select.html">lang_select.html</a>&nbsp;&nbsp; <a href="lang_select.html#compound">lang_select.html#compound</a>&nbsp;&nbsp; <a href="lang_select.html#fromclause">lang_select.html#fromclause</a>&nbsp;&nbsp; <a href="lang_select.html#simpleselect">lang_select.html#simpleselect</a>&nbsp;&nbsp; <a href="lang_update.html">lang_update.html</a>&nbsp;&nbsp; <a href="lang_upsert.html">lang_upsert.html</a>&nbsp;&nbsp; <a href="lang_with.html">lang_with.html</a>&nbsp;&nbsp; <a href="partialindex.html">partialindex.html</a>
</div>

<a name="join-constraint"></a><h4>join-constraint:</h4><div class='imgcontainer'>
<img src="images/syntax/join-constraint.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#join-clause">join-clause</a><br></br>
References:&nbsp;&nbsp; <a href="#expr">expr</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_aggfunc.html">lang_aggfunc.html</a>&nbsp;&nbsp; <a href="lang_altertable.html">lang_altertable.html</a>&nbsp;&nbsp; <a href="lang_attach.html">lang_attach.html</a>&nbsp;&nbsp; <a href="lang_createindex.html">lang_createindex.html</a>&nbsp;&nbsp; <a href="lang_createtable.html">lang_createtable.html</a>&nbsp;&nbsp; <a href="lang_createtrigger.html">lang_createtrigger.html</a>&nbsp;&nbsp; <a href="lang_createview.html">lang_createview.html</a>&nbsp;&nbsp; <a href="lang_delete.html">lang_delete.html</a>&nbsp;&nbsp; <a href="lang_expr.html">lang_expr.html</a>&nbsp;&nbsp; <a href="lang_insert.html">lang_insert.html</a>&nbsp;&nbsp; <a href="lang_select.html">lang_select.html</a>&nbsp;&nbsp; <a href="lang_select.html#compound">lang_select.html#compound</a>&nbsp;&nbsp; <a href="lang_select.html#fromclause">lang_select.html#fromclause</a>&nbsp;&nbsp; <a href="lang_select.html#simpleselect">lang_select.html#simpleselect</a>&nbsp;&nbsp; <a href="lang_update.html">lang_update.html</a>&nbsp;&nbsp; <a href="lang_upsert.html">lang_upsert.html</a>&nbsp;&nbsp; <a href="lang_with.html">lang_with.html</a>&nbsp;&nbsp; <a href="partialindex.html">partialindex.html</a>
</div>

<a name="ordering-term"></a><h4>ordering-term:</h4><div class='imgcontainer'>
<img src="images/syntax/ordering-term.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#compound-select-stmt">compound-select-stmt</a>&nbsp;&nbsp; <a href="#delete-stmt-limited">delete-stmt-limited</a>&nbsp;&nbsp; <a href="#factored-select-stmt">factored-select-stmt</a>&nbsp;&nbsp; <a href="#over-clause">over-clause</a>&nbsp;&nbsp; <a href="#select-stmt">select-stmt</a>&nbsp;&nbsp; <a href="#simple-select-stmt">simple-select-stmt</a>&nbsp;&nbsp; <a href="#update-stmt-limited">update-stmt-limited</a>&nbsp;&nbsp; <a href="#window-defn">window-defn</a><br></br>
References:&nbsp;&nbsp; <a href="#expr">expr</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_aggfunc.html">lang_aggfunc.html</a>&nbsp;&nbsp; <a href="lang_altertable.html">lang_altertable.html</a>&nbsp;&nbsp; <a href="lang_attach.html">lang_attach.html</a>&nbsp;&nbsp; <a href="lang_createindex.html">lang_createindex.html</a>&nbsp;&nbsp; <a href="lang_createtable.html">lang_createtable.html</a>&nbsp;&nbsp; <a href="lang_createtrigger.html">lang_createtrigger.html</a>&nbsp;&nbsp; <a href="lang_createview.html">lang_createview.html</a>&nbsp;&nbsp; <a href="lang_delete.html">lang_delete.html</a>&nbsp;&nbsp; <a href="lang_expr.html">lang_expr.html</a>&nbsp;&nbsp; <a href="lang_insert.html">lang_insert.html</a>&nbsp;&nbsp; <a href="lang_select.html">lang_select.html</a>&nbsp;&nbsp; <a href="lang_select.html#compound">lang_select.html#compound</a>&nbsp;&nbsp; <a href="lang_select.html#simpleselect">lang_select.html#simpleselect</a>&nbsp;&nbsp; <a href="lang_update.html">lang_update.html</a>&nbsp;&nbsp; <a href="lang_upsert.html">lang_upsert.html</a>&nbsp;&nbsp; <a href="lang_with.html">lang_with.html</a>&nbsp;&nbsp; <a href="partialindex.html">partialindex.html</a>
</div>

<a name="compound-operator"></a><h4>compound-operator:</h4><div class='imgcontainer'>
<img src="images/syntax/compound-operator.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#factored-select-stmt">factored-select-stmt</a>&nbsp;&nbsp; <a href="#select-stmt">select-stmt</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_aggfunc.html">lang_aggfunc.html</a>&nbsp;&nbsp; <a href="lang_altertable.html">lang_altertable.html</a>&nbsp;&nbsp; <a href="lang_attach.html">lang_attach.html</a>&nbsp;&nbsp; <a href="lang_createindex.html">lang_createindex.html</a>&nbsp;&nbsp; <a href="lang_createtable.html">lang_createtable.html</a>&nbsp;&nbsp; <a href="lang_createtrigger.html">lang_createtrigger.html</a>&nbsp;&nbsp; <a href="lang_createview.html">lang_createview.html</a>&nbsp;&nbsp; <a href="lang_delete.html">lang_delete.html</a>&nbsp;&nbsp; <a href="lang_expr.html">lang_expr.html</a>&nbsp;&nbsp; <a href="lang_insert.html">lang_insert.html</a>&nbsp;&nbsp; <a href="lang_select.html">lang_select.html</a>&nbsp;&nbsp; <a href="lang_select.html#compound">lang_select.html#compound</a>&nbsp;&nbsp; <a href="lang_select.html#simpleselect">lang_select.html#simpleselect</a>&nbsp;&nbsp; <a href="lang_update.html">lang_update.html</a>&nbsp;&nbsp; <a href="lang_upsert.html">lang_upsert.html</a>&nbsp;&nbsp; <a href="lang_with.html">lang_with.html</a>&nbsp;&nbsp; <a href="lang_with.html#recursivecte">lang_with.html#recursivecte</a>&nbsp;&nbsp; <a href="partialindex.html">partialindex.html</a>
</div>

<a name="update-stmt"></a><h4>update-stmt:</h4><div class='imgcontainer'>
<img src="images/syntax/update-stmt.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#create-trigger-stmt">create-trigger-stmt</a>&nbsp;&nbsp; <a href="#sql-stmt">sql-stmt</a><br></br>
References:&nbsp;&nbsp; <a href="#column-name-list">column-name-list</a>&nbsp;&nbsp; <a href="#expr">expr</a>&nbsp;&nbsp; <a href="#qualified-table-name">qualified-table-name</a>&nbsp;&nbsp; <a href="#with-clause">with-clause</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_createtrigger.html">lang_createtrigger.html</a>&nbsp;&nbsp; <a href="lang_update.html">lang_update.html</a>
</div>

<a name="column-name-list"></a><h4>column-name-list:</h4><div class='imgcontainer'>
<img src="images/syntax/column-name-list.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#update-stmt">update-stmt</a>&nbsp;&nbsp; <a href="#update-stmt-limited">update-stmt-limited</a>&nbsp;&nbsp; <a href="#upsert-clause">upsert-clause</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_createtrigger.html">lang_createtrigger.html</a>&nbsp;&nbsp; <a href="lang_insert.html">lang_insert.html</a>&nbsp;&nbsp; <a href="lang_update.html">lang_update.html</a>&nbsp;&nbsp; <a href="lang_upsert.html">lang_upsert.html</a>
</div>

<a name="update-stmt-limited"></a><h4>update-stmt-limited:</h4><div class='imgcontainer'>
<img src="images/syntax/update-stmt-limited.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#sql-stmt">sql-stmt</a><br></br>
References:&nbsp;&nbsp; <a href="#column-name-list">column-name-list</a>&nbsp;&nbsp; <a href="#expr">expr</a>&nbsp;&nbsp; <a href="#ordering-term">ordering-term</a>&nbsp;&nbsp; <a href="#qualified-table-name">qualified-table-name</a>&nbsp;&nbsp; <a href="#with-clause">with-clause</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_update.html">lang_update.html</a>
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
See also:&nbsp;&nbsp; <a href="lang_comment.html">lang_comment.html</a>
</div>

<a name="filter-clause"></a><h4>filter-clause:</h4><div class='imgcontainer'>
<img src="images/syntax/filter-clause.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#aggregate-function-invocation">aggregate-function-invocation</a>&nbsp;&nbsp; <a href="#expr">expr</a>&nbsp;&nbsp; <a href="#window-function-invocation">window-function-invocation</a><br></br>
References:&nbsp;&nbsp; <a href="#expr">expr</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_UPSERT.html">lang_UPSERT.html</a>&nbsp;&nbsp; <a href="lang_aggfunc.html">lang_aggfunc.html</a>&nbsp;&nbsp; <a href="lang_altertable.html">lang_altertable.html</a>&nbsp;&nbsp; <a href="lang_attach.html">lang_attach.html</a>&nbsp;&nbsp; <a href="lang_createindex.html">lang_createindex.html</a>&nbsp;&nbsp; <a href="lang_createtable.html">lang_createtable.html</a>&nbsp;&nbsp; <a href="lang_createtrigger.html">lang_createtrigger.html</a>&nbsp;&nbsp; <a href="lang_createview.html">lang_createview.html</a>&nbsp;&nbsp; <a href="lang_delete.html">lang_delete.html</a>&nbsp;&nbsp; <a href="lang_expr.html">lang_expr.html</a>&nbsp;&nbsp; <a href="lang_insert.html">lang_insert.html</a>&nbsp;&nbsp; <a href="lang_select.html">lang_select.html</a>&nbsp;&nbsp; <a href="lang_select.html#compound">lang_select.html#compound</a>&nbsp;&nbsp; <a href="lang_select.html#simpleselect">lang_select.html#simpleselect</a>&nbsp;&nbsp; <a href="lang_update.html">lang_update.html</a>&nbsp;&nbsp; <a href="lang_with.html">lang_with.html</a>&nbsp;&nbsp; <a href="partialindex.html">partialindex.html</a>
</div>

<a name="window-defn"></a><h4>window-defn:</h4><div class='imgcontainer'>
<img src="images/syntax/window-defn.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#select-core">select-core</a>&nbsp;&nbsp; <a href="#select-stmt">select-stmt</a>&nbsp;&nbsp; <a href="#window-function-invocation">window-function-invocation</a><br></br>
References:&nbsp;&nbsp; <a href="#expr">expr</a>&nbsp;&nbsp; <a href="#frame-spec">frame-spec</a>&nbsp;&nbsp; <a href="#ordering-term">ordering-term</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_UPSERT.html">lang_UPSERT.html</a>&nbsp;&nbsp; <a href="lang_aggfunc.html">lang_aggfunc.html</a>&nbsp;&nbsp; <a href="lang_altertable.html">lang_altertable.html</a>&nbsp;&nbsp; <a href="lang_attach.html">lang_attach.html</a>&nbsp;&nbsp; <a href="lang_createindex.html">lang_createindex.html</a>&nbsp;&nbsp; <a href="lang_createtable.html">lang_createtable.html</a>&nbsp;&nbsp; <a href="lang_createtrigger.html">lang_createtrigger.html</a>&nbsp;&nbsp; <a href="lang_createview.html">lang_createview.html</a>&nbsp;&nbsp; <a href="lang_delete.html">lang_delete.html</a>&nbsp;&nbsp; <a href="lang_expr.html">lang_expr.html</a>&nbsp;&nbsp; <a href="lang_insert.html">lang_insert.html</a>&nbsp;&nbsp; <a href="lang_select.html">lang_select.html</a>&nbsp;&nbsp; <a href="lang_select.html#compound">lang_select.html#compound</a>&nbsp;&nbsp; <a href="lang_select.html#simpleselect">lang_select.html#simpleselect</a>&nbsp;&nbsp; <a href="lang_update.html">lang_update.html</a>&nbsp;&nbsp; <a href="lang_with.html">lang_with.html</a>&nbsp;&nbsp; <a href="partialindex.html">partialindex.html</a>
</div>

<a name="over-clause"></a><h4>over-clause:</h4><div class='imgcontainer'>
<img src="images/syntax/over-clause.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#expr">expr</a><br></br>
References:&nbsp;&nbsp; <a href="#expr">expr</a>&nbsp;&nbsp; <a href="#frame-spec">frame-spec</a>&nbsp;&nbsp; <a href="#ordering-term">ordering-term</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_UPSERT.html">lang_UPSERT.html</a>&nbsp;&nbsp; <a href="lang_aggfunc.html">lang_aggfunc.html</a>&nbsp;&nbsp; <a href="lang_altertable.html">lang_altertable.html</a>&nbsp;&nbsp; <a href="lang_attach.html">lang_attach.html</a>&nbsp;&nbsp; <a href="lang_createindex.html">lang_createindex.html</a>&nbsp;&nbsp; <a href="lang_createtable.html">lang_createtable.html</a>&nbsp;&nbsp; <a href="lang_createtrigger.html">lang_createtrigger.html</a>&nbsp;&nbsp; <a href="lang_createview.html">lang_createview.html</a>&nbsp;&nbsp; <a href="lang_delete.html">lang_delete.html</a>&nbsp;&nbsp; <a href="lang_expr.html">lang_expr.html</a>&nbsp;&nbsp; <a href="lang_insert.html">lang_insert.html</a>&nbsp;&nbsp; <a href="lang_select.html">lang_select.html</a>&nbsp;&nbsp; <a href="lang_select.html#compound">lang_select.html#compound</a>&nbsp;&nbsp; <a href="lang_select.html#simpleselect">lang_select.html#simpleselect</a>&nbsp;&nbsp; <a href="lang_update.html">lang_update.html</a>&nbsp;&nbsp; <a href="lang_with.html">lang_with.html</a>&nbsp;&nbsp; <a href="partialindex.html">partialindex.html</a>
</div>

<a name="frame-spec"></a><h4>frame-spec:</h4><div class='imgcontainer'>
<img src="images/syntax/frame-spec.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#over-clause">over-clause</a>&nbsp;&nbsp; <a href="#window-defn">window-defn</a><br></br>
References:&nbsp;&nbsp; <a href="#expr">expr</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_UPSERT.html">lang_UPSERT.html</a>&nbsp;&nbsp; <a href="lang_aggfunc.html">lang_aggfunc.html</a>&nbsp;&nbsp; <a href="lang_altertable.html">lang_altertable.html</a>&nbsp;&nbsp; <a href="lang_attach.html">lang_attach.html</a>&nbsp;&nbsp; <a href="lang_createindex.html">lang_createindex.html</a>&nbsp;&nbsp; <a href="lang_createtable.html">lang_createtable.html</a>&nbsp;&nbsp; <a href="lang_createtrigger.html">lang_createtrigger.html</a>&nbsp;&nbsp; <a href="lang_createview.html">lang_createview.html</a>&nbsp;&nbsp; <a href="lang_delete.html">lang_delete.html</a>&nbsp;&nbsp; <a href="lang_expr.html">lang_expr.html</a>&nbsp;&nbsp; <a href="lang_insert.html">lang_insert.html</a>&nbsp;&nbsp; <a href="lang_select.html">lang_select.html</a>&nbsp;&nbsp; <a href="lang_select.html#compound">lang_select.html#compound</a>&nbsp;&nbsp; <a href="lang_select.html#simpleselect">lang_select.html#simpleselect</a>&nbsp;&nbsp; <a href="lang_update.html">lang_update.html</a>&nbsp;&nbsp; <a href="lang_with.html">lang_with.html</a>&nbsp;&nbsp; <a href="partialindex.html">partialindex.html</a>
</div>

<a name="simple-function-invocation"></a><h4>simple-function-invocation:</h4><div class='imgcontainer'>
<img src="images/syntax/simple-function-invocation.gif"></img><br></br><br></br>
References:&nbsp;&nbsp; <a href="#expr">expr</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_expr.html#booleanexpr">lang_expr.html#booleanexpr</a>
</div>







|






|






|






|







490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
See also:&nbsp;&nbsp; <a href="lang_comment.html">lang_comment.html</a>
</div>

<a name="filter-clause"></a><h4>filter-clause:</h4><div class='imgcontainer'>
<img src="images/syntax/filter-clause.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#aggregate-function-invocation">aggregate-function-invocation</a>&nbsp;&nbsp; <a href="#expr">expr</a>&nbsp;&nbsp; <a href="#window-function-invocation">window-function-invocation</a><br></br>
References:&nbsp;&nbsp; <a href="#expr">expr</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_aggfunc.html">lang_aggfunc.html</a>&nbsp;&nbsp; <a href="lang_altertable.html">lang_altertable.html</a>&nbsp;&nbsp; <a href="lang_attach.html">lang_attach.html</a>&nbsp;&nbsp; <a href="lang_createindex.html">lang_createindex.html</a>&nbsp;&nbsp; <a href="lang_createtable.html">lang_createtable.html</a>&nbsp;&nbsp; <a href="lang_createtrigger.html">lang_createtrigger.html</a>&nbsp;&nbsp; <a href="lang_createview.html">lang_createview.html</a>&nbsp;&nbsp; <a href="lang_delete.html">lang_delete.html</a>&nbsp;&nbsp; <a href="lang_expr.html">lang_expr.html</a>&nbsp;&nbsp; <a href="lang_insert.html">lang_insert.html</a>&nbsp;&nbsp; <a href="lang_select.html">lang_select.html</a>&nbsp;&nbsp; <a href="lang_select.html#compound">lang_select.html#compound</a>&nbsp;&nbsp; <a href="lang_select.html#simpleselect">lang_select.html#simpleselect</a>&nbsp;&nbsp; <a href="lang_update.html">lang_update.html</a>&nbsp;&nbsp; <a href="lang_upsert.html">lang_upsert.html</a>&nbsp;&nbsp; <a href="lang_with.html">lang_with.html</a>&nbsp;&nbsp; <a href="partialindex.html">partialindex.html</a>
</div>

<a name="window-defn"></a><h4>window-defn:</h4><div class='imgcontainer'>
<img src="images/syntax/window-defn.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#select-core">select-core</a>&nbsp;&nbsp; <a href="#select-stmt">select-stmt</a>&nbsp;&nbsp; <a href="#window-function-invocation">window-function-invocation</a><br></br>
References:&nbsp;&nbsp; <a href="#expr">expr</a>&nbsp;&nbsp; <a href="#frame-spec">frame-spec</a>&nbsp;&nbsp; <a href="#ordering-term">ordering-term</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_aggfunc.html">lang_aggfunc.html</a>&nbsp;&nbsp; <a href="lang_altertable.html">lang_altertable.html</a>&nbsp;&nbsp; <a href="lang_attach.html">lang_attach.html</a>&nbsp;&nbsp; <a href="lang_createindex.html">lang_createindex.html</a>&nbsp;&nbsp; <a href="lang_createtable.html">lang_createtable.html</a>&nbsp;&nbsp; <a href="lang_createtrigger.html">lang_createtrigger.html</a>&nbsp;&nbsp; <a href="lang_createview.html">lang_createview.html</a>&nbsp;&nbsp; <a href="lang_delete.html">lang_delete.html</a>&nbsp;&nbsp; <a href="lang_expr.html">lang_expr.html</a>&nbsp;&nbsp; <a href="lang_insert.html">lang_insert.html</a>&nbsp;&nbsp; <a href="lang_select.html">lang_select.html</a>&nbsp;&nbsp; <a href="lang_select.html#compound">lang_select.html#compound</a>&nbsp;&nbsp; <a href="lang_select.html#simpleselect">lang_select.html#simpleselect</a>&nbsp;&nbsp; <a href="lang_update.html">lang_update.html</a>&nbsp;&nbsp; <a href="lang_upsert.html">lang_upsert.html</a>&nbsp;&nbsp; <a href="lang_with.html">lang_with.html</a>&nbsp;&nbsp; <a href="partialindex.html">partialindex.html</a>
</div>

<a name="over-clause"></a><h4>over-clause:</h4><div class='imgcontainer'>
<img src="images/syntax/over-clause.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#expr">expr</a><br></br>
References:&nbsp;&nbsp; <a href="#expr">expr</a>&nbsp;&nbsp; <a href="#frame-spec">frame-spec</a>&nbsp;&nbsp; <a href="#ordering-term">ordering-term</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_aggfunc.html">lang_aggfunc.html</a>&nbsp;&nbsp; <a href="lang_altertable.html">lang_altertable.html</a>&nbsp;&nbsp; <a href="lang_attach.html">lang_attach.html</a>&nbsp;&nbsp; <a href="lang_createindex.html">lang_createindex.html</a>&nbsp;&nbsp; <a href="lang_createtable.html">lang_createtable.html</a>&nbsp;&nbsp; <a href="lang_createtrigger.html">lang_createtrigger.html</a>&nbsp;&nbsp; <a href="lang_createview.html">lang_createview.html</a>&nbsp;&nbsp; <a href="lang_delete.html">lang_delete.html</a>&nbsp;&nbsp; <a href="lang_expr.html">lang_expr.html</a>&nbsp;&nbsp; <a href="lang_insert.html">lang_insert.html</a>&nbsp;&nbsp; <a href="lang_select.html">lang_select.html</a>&nbsp;&nbsp; <a href="lang_select.html#compound">lang_select.html#compound</a>&nbsp;&nbsp; <a href="lang_select.html#simpleselect">lang_select.html#simpleselect</a>&nbsp;&nbsp; <a href="lang_update.html">lang_update.html</a>&nbsp;&nbsp; <a href="lang_upsert.html">lang_upsert.html</a>&nbsp;&nbsp; <a href="lang_with.html">lang_with.html</a>&nbsp;&nbsp; <a href="partialindex.html">partialindex.html</a>
</div>

<a name="frame-spec"></a><h4>frame-spec:</h4><div class='imgcontainer'>
<img src="images/syntax/frame-spec.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#over-clause">over-clause</a>&nbsp;&nbsp; <a href="#window-defn">window-defn</a><br></br>
References:&nbsp;&nbsp; <a href="#expr">expr</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_aggfunc.html">lang_aggfunc.html</a>&nbsp;&nbsp; <a href="lang_altertable.html">lang_altertable.html</a>&nbsp;&nbsp; <a href="lang_attach.html">lang_attach.html</a>&nbsp;&nbsp; <a href="lang_createindex.html">lang_createindex.html</a>&nbsp;&nbsp; <a href="lang_createtable.html">lang_createtable.html</a>&nbsp;&nbsp; <a href="lang_createtrigger.html">lang_createtrigger.html</a>&nbsp;&nbsp; <a href="lang_createview.html">lang_createview.html</a>&nbsp;&nbsp; <a href="lang_delete.html">lang_delete.html</a>&nbsp;&nbsp; <a href="lang_expr.html">lang_expr.html</a>&nbsp;&nbsp; <a href="lang_insert.html">lang_insert.html</a>&nbsp;&nbsp; <a href="lang_select.html">lang_select.html</a>&nbsp;&nbsp; <a href="lang_select.html#compound">lang_select.html#compound</a>&nbsp;&nbsp; <a href="lang_select.html#simpleselect">lang_select.html#simpleselect</a>&nbsp;&nbsp; <a href="lang_update.html">lang_update.html</a>&nbsp;&nbsp; <a href="lang_upsert.html">lang_upsert.html</a>&nbsp;&nbsp; <a href="lang_with.html">lang_with.html</a>&nbsp;&nbsp; <a href="partialindex.html">partialindex.html</a>
</div>

<a name="simple-function-invocation"></a><h4>simple-function-invocation:</h4><div class='imgcontainer'>
<img src="images/syntax/simple-function-invocation.gif"></img><br></br><br></br>
References:&nbsp;&nbsp; <a href="#expr">expr</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_expr.html#booleanexpr">lang_expr.html#booleanexpr</a>
</div>
Changes to Doc/Special/Core/vtab.html.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
the implementation must set *pRowid to the rowid of the newly inserted row; 
this will become the value returned by the <a href="c3ref/last_insert_rowid.html">sqlite3_last_insert_rowid()</a>
function. Setting this value in all the other cases is a harmless no-op;
the SQLite engine ignores the *pRowid return value if argc==1 or 
argv[1] is not an SQL NULL.

</p><p>Each call to xUpdate will fall into one of cases shown below.
Not that references to <b>argv&#91;i&#93</b> mean the SQL value
held within the argv&#91;i&#93; object, not the argv&#91;i&#93;
object itself.

</p><blockquote>
<dl>
<dt><b>argc = 1 <br> argv[0] &ne; NULL</b>
</dt><dd><p>







|







1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
the implementation must set *pRowid to the rowid of the newly inserted row; 
this will become the value returned by the <a href="c3ref/last_insert_rowid.html">sqlite3_last_insert_rowid()</a>
function. Setting this value in all the other cases is a harmless no-op;
the SQLite engine ignores the *pRowid return value if argc==1 or 
argv[1] is not an SQL NULL.

</p><p>Each call to xUpdate will fall into one of cases shown below.
Not that references to <b>argv&#91;i&#93;</b> mean the SQL value
held within the argv&#91;i&#93; object, not the argv&#91;i&#93;
object itself.

</p><blockquote>
<dl>
<dt><b>argc = 1 <br> argv[0] &ne; NULL</b>
</dt><dd><p>