System.Data.SQLite

Check-in [0622da663d]
Login

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

Overview
Comment:Merge updates from trunk.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | nugetChanges
Files: files | file ages | folders
SHA1: 0622da663d811bde5070b6c6be9aacbfc238ad7e
User & Date: mistachkin 2014-09-04 18:33:35.395
Context
2014-09-05
15:55
Fix typo in the NuGet MSBuild targets file. check-in: 3a9676e997 user: mistachkin tags: nugetChanges
2014-09-04
18:33
Merge updates from trunk. check-in: 0622da663d user: mistachkin tags: nugetChanges
18:32
More work on getting the design-time components to detect and use the EF6 enabled provider. Cherrypick of [30c1589da7] (check-in on wrong branch). check-in: c43018f34e user: mistachkin tags: trunk
17:45
More work on getting the design-time components to detect and use the EF6 enabled provider. check-in: 30c1589da7 user: mistachkin tags: nugetChanges
Changes
Unified Diff Ignore Whitespace Patch
Changes to Doc/Extra/Core/images/syntax/numeric-literal.gif.

cannot compute difference between binary files

Changes to Doc/Extra/Core/lang_altertable.html.
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
    </form>
    </div>
  </table>

<div class=startsearch></div>
  
<h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>ALTER TABLE</h2><p><b><a href="syntaxdiagrams.html#alter-table-stmt">alter-table-stmt:</a></b>
<button id='x729' onclick='hideorshow("x729","x730")'>hide</button></p>
 <blockquote id='x730'>
 <img alt="syntax diagram alter-table-stmt" src="images/syntax/alter-table-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#column-def">column-def:</a></b>
<button id='x731' onclick='hideorshow("x731","x732")'>show</button></p>
 <blockquote id='x732' style='display:none;'>
 <img alt="syntax diagram column-def" src="images/syntax/column-def.gif" />
<p><b><a href="syntaxdiagrams.html#column-constraint">column-constraint:</a></b>
<button id='x733' onclick='hideorshow("x733","x734")'>show</button></p>
 <blockquote id='x734' style='display:none;'>
 <img alt="syntax diagram column-constraint" src="images/syntax/column-constraint.gif" />
<p><b><a href="syntaxdiagrams.html#conflict-clause">conflict-clause:</a></b>
<button id='x735' onclick='hideorshow("x735","x736")'>show</button></p>
 <blockquote id='x736' style='display:none;'>
 <img alt="syntax diagram conflict-clause" src="images/syntax/conflict-clause.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#expr">expr:</a></b>
<button id='x737' onclick='hideorshow("x737","x738")'>show</button></p>
 <blockquote id='x738' style='display:none;'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntaxdiagrams.html#raise-function">raise-function:</a></b>
<button id='x739' onclick='hideorshow("x739","x740")'>show</button></p>
 <blockquote id='x740' style='display:none;'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#select-stmt">select-stmt:</a></b>
<button id='x741' onclick='hideorshow("x741","x742")'>show</button></p>
 <blockquote id='x742' style='display:none;'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#common-table-expression">common-table-expression:</a></b>
<button id='x743' onclick='hideorshow("x743","x744")'>show</button></p>
 <blockquote id='x744' style='display:none;'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#compound-operator">compound-operator:</a></b>
<button id='x745' onclick='hideorshow("x745","x746")'>show</button></p>
 <blockquote id='x746' style='display:none;'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-clause">join-clause:</a></b>
<button id='x747' onclick='hideorshow("x747","x748")'>show</button></p>
 <blockquote id='x748' style='display:none;'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntaxdiagrams.html#join-constraint">join-constraint:</a></b>
<button id='x749' onclick='hideorshow("x749","x750")'>show</button></p>
 <blockquote id='x750' style='display:none;'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-operator">join-operator:</a></b>
<button id='x751' onclick='hideorshow("x751","x752")'>show</button></p>
 <blockquote id='x752' style='display:none;'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#ordering-term">ordering-term:</a></b>
<button id='x753' onclick='hideorshow("x753","x754")'>show</button></p>
 <blockquote id='x754' style='display:none;'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#result-column">result-column:</a></b>
<button id='x755' onclick='hideorshow("x755","x756")'>show</button></p>
 <blockquote id='x756' style='display:none;'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#table-or-subquery">table-or-subquery:</a></b>
<button id='x757' onclick='hideorshow("x757","x758")'>show</button></p>
 <blockquote id='x758' style='display:none;'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</blockquote>
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#foreign-key-clause">foreign-key-clause:</a></b>
<button id='x759' onclick='hideorshow("x759","x760")'>show</button></p>
 <blockquote id='x760' style='display:none;'>
 <img alt="syntax diagram foreign-key-clause" src="images/syntax/foreign-key-clause.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#literal-value">literal-value:</a></b>
<button id='x761' onclick='hideorshow("x761","x762")'>show</button></p>
 <blockquote id='x762' style='display:none;'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#signed-number">signed-number:</a></b>
<button id='x763' onclick='hideorshow("x763","x764")'>show</button></p>
 <blockquote id='x764' style='display:none;'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#type-name">type-name:</a></b>
<button id='x765' onclick='hideorshow("x765","x766")'>show</button></p>
 <blockquote id='x766' style='display:none;'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntaxdiagrams.html#signed-number">signed-number:</a></b>
<button id='x767' onclick='hideorshow("x767","x768")'>show</button></p>
 <blockquote id='x768' style='display:none;'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</blockquote>
</blockquote>
</blockquote>
</blockquote>









|
|


|
|


|
|


|
|



|
|


|
|



|
|


|
|



|
|



|
|


|
|



|
|




|
|



|
|



|
|





|
|



|
|



|
|




|
|


|
|







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
    </form>
    </div>
  </table>

<div class=startsearch></div>
  
<h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>ALTER TABLE</h2><p><b><a href="syntaxdiagrams.html#alter-table-stmt">alter-table-stmt:</a></b>
<button id='x737' onclick='hideorshow("x737","x738")'>hide</button></p>
 <blockquote id='x738'>
 <img alt="syntax diagram alter-table-stmt" src="images/syntax/alter-table-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#column-def">column-def:</a></b>
<button id='x739' onclick='hideorshow("x739","x740")'>show</button></p>
 <blockquote id='x740' style='display:none;'>
 <img alt="syntax diagram column-def" src="images/syntax/column-def.gif" />
<p><b><a href="syntaxdiagrams.html#column-constraint">column-constraint:</a></b>
<button id='x741' onclick='hideorshow("x741","x742")'>show</button></p>
 <blockquote id='x742' style='display:none;'>
 <img alt="syntax diagram column-constraint" src="images/syntax/column-constraint.gif" />
<p><b><a href="syntaxdiagrams.html#conflict-clause">conflict-clause:</a></b>
<button id='x743' onclick='hideorshow("x743","x744")'>show</button></p>
 <blockquote id='x744' style='display:none;'>
 <img alt="syntax diagram conflict-clause" src="images/syntax/conflict-clause.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#expr">expr:</a></b>
<button id='x745' onclick='hideorshow("x745","x746")'>show</button></p>
 <blockquote id='x746' style='display:none;'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntaxdiagrams.html#raise-function">raise-function:</a></b>
<button id='x747' onclick='hideorshow("x747","x748")'>show</button></p>
 <blockquote id='x748' style='display:none;'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#select-stmt">select-stmt:</a></b>
<button id='x749' onclick='hideorshow("x749","x750")'>show</button></p>
 <blockquote id='x750' style='display:none;'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#common-table-expression">common-table-expression:</a></b>
<button id='x751' onclick='hideorshow("x751","x752")'>show</button></p>
 <blockquote id='x752' style='display:none;'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#compound-operator">compound-operator:</a></b>
<button id='x753' onclick='hideorshow("x753","x754")'>show</button></p>
 <blockquote id='x754' style='display:none;'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-clause">join-clause:</a></b>
<button id='x755' onclick='hideorshow("x755","x756")'>show</button></p>
 <blockquote id='x756' style='display:none;'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntaxdiagrams.html#join-constraint">join-constraint:</a></b>
<button id='x757' onclick='hideorshow("x757","x758")'>show</button></p>
 <blockquote id='x758' style='display:none;'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-operator">join-operator:</a></b>
<button id='x759' onclick='hideorshow("x759","x760")'>show</button></p>
 <blockquote id='x760' style='display:none;'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#ordering-term">ordering-term:</a></b>
<button id='x761' onclick='hideorshow("x761","x762")'>show</button></p>
 <blockquote id='x762' style='display:none;'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#result-column">result-column:</a></b>
<button id='x763' onclick='hideorshow("x763","x764")'>show</button></p>
 <blockquote id='x764' style='display:none;'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#table-or-subquery">table-or-subquery:</a></b>
<button id='x765' onclick='hideorshow("x765","x766")'>show</button></p>
 <blockquote id='x766' style='display:none;'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</blockquote>
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#foreign-key-clause">foreign-key-clause:</a></b>
<button id='x767' onclick='hideorshow("x767","x768")'>show</button></p>
 <blockquote id='x768' style='display:none;'>
 <img alt="syntax diagram foreign-key-clause" src="images/syntax/foreign-key-clause.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#literal-value">literal-value:</a></b>
<button id='x769' onclick='hideorshow("x769","x770")'>show</button></p>
 <blockquote id='x770' style='display:none;'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#signed-number">signed-number:</a></b>
<button id='x771' onclick='hideorshow("x771","x772")'>show</button></p>
 <blockquote id='x772' style='display:none;'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#type-name">type-name:</a></b>
<button id='x773' onclick='hideorshow("x773","x774")'>show</button></p>
 <blockquote id='x774' style='display:none;'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntaxdiagrams.html#signed-number">signed-number:</a></b>
<button id='x775' onclick='hideorshow("x775","x776")'>show</button></p>
 <blockquote id='x776' style='display:none;'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</blockquote>
</blockquote>
</blockquote>
</blockquote>


244
245
246
247
248
249
250











251
252
253
254
255
256
257
<p> If the table being renamed has triggers or indices, then these remain
attached to the table after it has been renamed.  However, if there are
any view definitions, or statements executed by triggers that refer to
the table being renamed, these are not automatically modified to use the new
table name. If this is required, the triggers or view definitions must be
dropped and recreated to use the new table name by hand.
</p>












<p>If <a href="foreignkeys.html">foreign key constraints</a> are 
<a href="pragma.html#pragma_foreign_keys">enabled</a> when a table is renamed, then any
<a href="syntaxdiagrams.html#foreign-key-clause">REFERENCES clauses</a> in any table (either the
table being renamed or some other table)
that refer to the table being renamed are modified to refer 
to the renamed table by its new name.







>
>
>
>
>
>
>
>
>
>
>







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
<p> If the table being renamed has triggers or indices, then these remain
attached to the table after it has been renamed.  However, if there are
any view definitions, or statements executed by triggers that refer to
the table being renamed, these are not automatically modified to use the new
table name. If this is required, the triggers or view definitions must be
dropped and recreated to use the new table name by hand.
</p>

<blockquote><table border="1" cellpadding="10">
<tr><td>
<em>Important Note:</em>
The 'ALTER TABLE ... RENAME TO ...' command does not update action
statements within triggers or SELECT statements within views.
If the table being renamed is referenced from within triggers or views,
then those triggers and views must be dropped and recreated separately
by the application.
</td></tr></table>
</blockquote>

<p>If <a href="foreignkeys.html">foreign key constraints</a> are 
<a href="pragma.html#pragma_foreign_keys">enabled</a> when a table is renamed, then any
<a href="syntaxdiagrams.html#foreign-key-clause">REFERENCES clauses</a> in any table (either the
table being renamed or some other table)
that refer to the table being renamed are modified to refer 
to the renamed table by its new name.
282
283
284
285
286
287
288
289

290























































































































<p> The execution time of the ALTER TABLE command is independent of
the amount of data in the table.  The ALTER TABLE command runs as quickly
on a table with 10 million rows as it does on a table with 1 row.
</p>

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


































































































































>

>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
<p> The execution time of the ALTER TABLE command is independent of
the amount of data in the table.  The ALTER TABLE command runs as quickly
on a table with 10 million rows as it does on a table with 1 row.
</p>

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

<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
"rename table" and "add column" 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>
Remember the format of all indexes and triggers associated with table X.
This information will be needed in step 7 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>
If foreign key constraints are enabled,
disable them using <a href="pragma.html#pragma_foreign_keys">PRAGMA foreign_keys=OFF</a>.

<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> and <a href="lang_createtrigger.html">CREATE TRIGGER</a> to reconstruct indexes and triggers
associated with table X.  Perhaps use the old format of the triggers and
indexes saved from step 1 above as a guide, making changes as appropriate
for the alteration.

<li><p>
If foreign key constraints were originally enabled (prior to
step 4) 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, and run
<a href="pragma.html#pragma_foreign_keys">PRAGMA foreign_keys=ON</a> to re-enable foreign key
constraints.

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

</ol>

<p>The procedure above is completely general and will work even if the
schema change causes the information stored in the table to change.
So the full 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,
renaming columns, or adding or removing or changing default values on
a column.

<ol>
<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 5 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 of 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.
</ol>

<p>It is important that both of the above procedures be run from within
a transaction to prevent other processes from accessing the database file
while the schema change is only partially complete.  

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





Changes to Doc/Extra/Core/lang_analyze.html.
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
    </form>
    </div>
  </table>

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


<p> The ANALYZE command gathers statistics about tables and
indices and stores the collected information
in <a href="fileformat2.html#intschema">internal tables</a> of the database where the query optimizer can







|
|







125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
    </form>
    </div>
  </table>

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


<p> The ANALYZE command gathers statistics about tables and
indices and stores the collected information
in <a href="fileformat2.html#intschema">internal tables</a> of the database where the query optimizer can
Changes to Doc/Extra/Core/lang_attach.html.
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
    </form>
    </div>
  </table>

<div class=startsearch></div>
  
<h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>ATTACH DATABASE</h2><p><b><a href="syntaxdiagrams.html#attach-stmt">attach-stmt:</a></b>
<button id='x771' onclick='hideorshow("x771","x772")'>hide</button></p>
 <blockquote id='x772'>
 <img alt="syntax diagram attach-stmt" src="images/syntax/attach-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#expr">expr:</a></b>
<button id='x773' onclick='hideorshow("x773","x774")'>show</button></p>
 <blockquote id='x774' style='display:none;'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntaxdiagrams.html#literal-value">literal-value:</a></b>
<button id='x775' onclick='hideorshow("x775","x776")'>show</button></p>
 <blockquote id='x776' style='display:none;'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#raise-function">raise-function:</a></b>
<button id='x777' onclick='hideorshow("x777","x778")'>show</button></p>
 <blockquote id='x778' style='display:none;'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#select-stmt">select-stmt:</a></b>
<button id='x779' onclick='hideorshow("x779","x780")'>show</button></p>
 <blockquote id='x780' style='display:none;'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#common-table-expression">common-table-expression:</a></b>
<button id='x781' onclick='hideorshow("x781","x782")'>show</button></p>
 <blockquote id='x782' style='display:none;'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#compound-operator">compound-operator:</a></b>
<button id='x783' onclick='hideorshow("x783","x784")'>show</button></p>
 <blockquote id='x784' style='display:none;'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-clause">join-clause:</a></b>
<button id='x785' onclick='hideorshow("x785","x786")'>show</button></p>
 <blockquote id='x786' style='display:none;'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntaxdiagrams.html#join-constraint">join-constraint:</a></b>
<button id='x787' onclick='hideorshow("x787","x788")'>show</button></p>
 <blockquote id='x788' style='display:none;'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-operator">join-operator:</a></b>
<button id='x789' onclick='hideorshow("x789","x790")'>show</button></p>
 <blockquote id='x790' style='display:none;'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#ordering-term">ordering-term:</a></b>
<button id='x791' onclick='hideorshow("x791","x792")'>show</button></p>
 <blockquote id='x792' style='display:none;'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#result-column">result-column:</a></b>
<button id='x793' onclick='hideorshow("x793","x794")'>show</button></p>
 <blockquote id='x794' style='display:none;'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#table-or-subquery">table-or-subquery:</a></b>
<button id='x795' onclick='hideorshow("x795","x796")'>show</button></p>
 <blockquote id='x796' style='display:none;'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#type-name">type-name:</a></b>
<button id='x797' onclick='hideorshow("x797","x798")'>show</button></p>
 <blockquote id='x798' style='display:none;'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntaxdiagrams.html#signed-number">signed-number:</a></b>
<button id='x799' onclick='hideorshow("x799","x800")'>show</button></p>
 <blockquote id='x800' style='display:none;'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</blockquote>
</blockquote>
</blockquote>
</blockquote>









|
|


|
|


|
|



|
|



|
|


|
|



|
|



|
|


|
|



|
|




|
|



|
|



|
|




|
|


|
|







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
    </form>
    </div>
  </table>

<div class=startsearch></div>
  
<h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>ATTACH DATABASE</h2><p><b><a href="syntaxdiagrams.html#attach-stmt">attach-stmt:</a></b>
<button id='x779' onclick='hideorshow("x779","x780")'>hide</button></p>
 <blockquote id='x780'>
 <img alt="syntax diagram attach-stmt" src="images/syntax/attach-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#expr">expr:</a></b>
<button id='x781' onclick='hideorshow("x781","x782")'>show</button></p>
 <blockquote id='x782' style='display:none;'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntaxdiagrams.html#literal-value">literal-value:</a></b>
<button id='x783' onclick='hideorshow("x783","x784")'>show</button></p>
 <blockquote id='x784' style='display:none;'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#raise-function">raise-function:</a></b>
<button id='x785' onclick='hideorshow("x785","x786")'>show</button></p>
 <blockquote id='x786' style='display:none;'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#select-stmt">select-stmt:</a></b>
<button id='x787' onclick='hideorshow("x787","x788")'>show</button></p>
 <blockquote id='x788' style='display:none;'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#common-table-expression">common-table-expression:</a></b>
<button id='x789' onclick='hideorshow("x789","x790")'>show</button></p>
 <blockquote id='x790' style='display:none;'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#compound-operator">compound-operator:</a></b>
<button id='x791' onclick='hideorshow("x791","x792")'>show</button></p>
 <blockquote id='x792' style='display:none;'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-clause">join-clause:</a></b>
<button id='x793' onclick='hideorshow("x793","x794")'>show</button></p>
 <blockquote id='x794' style='display:none;'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntaxdiagrams.html#join-constraint">join-constraint:</a></b>
<button id='x795' onclick='hideorshow("x795","x796")'>show</button></p>
 <blockquote id='x796' style='display:none;'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-operator">join-operator:</a></b>
<button id='x797' onclick='hideorshow("x797","x798")'>show</button></p>
 <blockquote id='x798' style='display:none;'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#ordering-term">ordering-term:</a></b>
<button id='x799' onclick='hideorshow("x799","x800")'>show</button></p>
 <blockquote id='x800' style='display:none;'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#result-column">result-column:</a></b>
<button id='x801' onclick='hideorshow("x801","x802")'>show</button></p>
 <blockquote id='x802' style='display:none;'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#table-or-subquery">table-or-subquery:</a></b>
<button id='x803' onclick='hideorshow("x803","x804")'>show</button></p>
 <blockquote id='x804' style='display:none;'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#type-name">type-name:</a></b>
<button id='x805' onclick='hideorshow("x805","x806")'>show</button></p>
 <blockquote id='x806' style='display:none;'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntaxdiagrams.html#signed-number">signed-number:</a></b>
<button id='x807' onclick='hideorshow("x807","x808")'>show</button></p>
 <blockquote id='x808' style='display:none;'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</blockquote>
</blockquote>
</blockquote>
</blockquote>


Changes to Doc/Extra/Core/lang_comment.html.
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
    </form>
    </div>
  </table>

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


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







|
|







125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
    </form>
    </div>
  </table>

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


<p>Comments are not SQL commands, but can occur within the text of
SQL queries passed to <a href="c3ref/prepare.html">sqlite3_prepare_v2()</a> and related interfaces.
Comments are treated as whitespace by the parser.
Changes to Doc/Extra/Core/lang_conflict.html.
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
    </form>
    </div>
  </table>

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


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

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

<p>The ON CONFLICT clause applies to UNIQUE and NOT NULL
constraints (and to PRIMARY KEY constraints which for the purposes 
of this section are the same thing as UNIQUE constraints).
The ON CONFLICT algorithm does not
apply to <a href="foreignkeys.html">FOREIGN KEY constraints</a>.
There are five conflict resolution algorithm choices:
ROLLBACK, ABORT, FAIL, IGNORE, and REPLACE.
The default conflict resolution algorithm is ABORT.  This
is what they mean:</p>








|
|

















|
|
<







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
    </form>
    </div>
  </table>

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


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

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

<p>The ON CONFLICT clause applies to <a href="lang_createtable.html#uniqueconst">UNIQUE</a>, <a href="lang_createtable.html#notnullconst">NOT NULL</a>,
<a href="lang_createtable.html#ckconst">CHECK</a>, and <a href="lang_createtable.html#primkeyconst">PRIMARY KEY</a> constraints.

The ON CONFLICT algorithm does not
apply to <a href="foreignkeys.html">FOREIGN KEY constraints</a>.
There are five conflict resolution algorithm choices:
ROLLBACK, ABORT, FAIL, IGNORE, and REPLACE.
The default conflict resolution algorithm is ABORT.  This
is what they mean:</p>

196
197
198
199
200
201
202

203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
of the SQL statement as if nothing went wrong.
Other rows before and after the row that
contained the constraint violation are inserted or updated
normally. No error is returned when the IGNORE conflict resolution
algorithm is used.</p></dd>

<dt><b>REPLACE</b></dt>

<dd><p> When a UNIQUE constraint violation occurs, the REPLACE algorithm
deletes pre-existing rows that are causing the constraint violation
prior to inserting or updating the current row and the command continues 
executing normally.
If a NOT NULL constraint violation occurs, the REPLACE conflict
resolution replaces the NULL value with
the default value for that column, or if the column has no default
value, then the ABORT algorithm is used.
If a CHECK constraint violation occurs, the REPLACE conflict resolution
algorithm always works like ABORT.</p>

<p>When the REPLACE conflict resolution strategy deletes rows in order to
satisfy a constraint, <a href="lang_createtrigger.html">delete triggers</a> fire if and only if
<a href="pragma.html#pragma_recursive_triggers">recursive triggers</a> are enabled.</p>

<p>The <a href="c3ref/update_hook.html">update hook</a> is not invoked for rows that







>
|



|



|







195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
of the SQL statement as if nothing went wrong.
Other rows before and after the row that
contained the constraint violation are inserted or updated
normally. No error is returned when the IGNORE conflict resolution
algorithm is used.</p></dd>

<dt><b>REPLACE</b></dt>
<dd><p> When a <a href="lang_createtable.html#uniqueconst">UNIQUE</a> or <a href="lang_createtable.html#primkeyconst">PRIMARY KEY</a> constraint violation occurs, 
the REPLACE algorithm
deletes pre-existing rows that are causing the constraint violation
prior to inserting or updating the current row and the command continues 
executing normally.
If a <a href="lang_createtable.html#notnullconst">NOT NULL</a> constraint violation occurs, the REPLACE conflict
resolution replaces the NULL value with
the default value for that column, or if the column has no default
value, then the ABORT algorithm is used.
If a <a href="lang_createtable.html#ckconst">CHECK</a> constraint violation occurs, the REPLACE conflict resolution
algorithm always works like ABORT.</p>

<p>When the REPLACE conflict resolution strategy deletes rows in order to
satisfy a constraint, <a href="lang_createtrigger.html">delete triggers</a> fire if and only if
<a href="pragma.html#pragma_recursive_triggers">recursive triggers</a> are enabled.</p>

<p>The <a href="c3ref/update_hook.html">update hook</a> is not invoked for rows that
Changes to Doc/Extra/Core/lang_corefunc.html.
232
233
234
235
236
237
238











239
240
241
242
243
244
245
  The likelihood(X) function is a no-op that the code generator
  optimizes away so that it consumes no CPU cycles during run-time
  (that is, during calls to <a href="c3ref/step.html">sqlite3_step()</a>).
  The purpose of the likelihood(X,Y) function is to provide a hint
  to the query planner that the argument X is a boolean that is
  true with a probability of approximately Y.
  The <a href="lang_corefunc.html#unlikely">unlikely(X)</a> function is short-hand for likelihood(X,0.0625).











</td></tr><tr><td valign="top" align="right" width="120"><a name="load_extension"></a>
load_extension(<i>X</i>)<br />load_extension(<i>X</i>,<i>Y</i>)</td><td valign="top">
  The load_extension(X,Y) function loads <a href="loadext.html">SQLite extensions</a> out of the shared
  library file named X using the entry point Y.  The result of load_extension()
  is always a NULL.  If Y is omitted then the default entry point name is used.
  The load_extension() function raises an exception if the extension fails to
  load or initialize correctly.







>
>
>
>
>
>
>
>
>
>
>







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
  The likelihood(X) function is a no-op that the code generator
  optimizes away so that it consumes no CPU cycles during run-time
  (that is, during calls to <a href="c3ref/step.html">sqlite3_step()</a>).
  The purpose of the likelihood(X,Y) function is to provide a hint
  to the query planner that the argument X is a boolean that is
  true with a probability of approximately Y.
  The <a href="lang_corefunc.html#unlikely">unlikely(X)</a> function is short-hand for likelihood(X,0.0625).
  The <a href="lang_corefunc.html#likely">likely(X)</a> function is short-hand for likelihood(X,0.9375).
</td></tr><tr><td valign="top" align="right" width="120"><a name="likely"></a>
likely(<i>X</i>)</td><td valign="top">
  The likely(X) function returns the argument X unchanged.
  The likely(X) function is a no-op that the code generator
  optimizes away so that it consumes no CPU cycles at
  run-time (that is, during calls to <a href="c3ref/step.html">sqlite3_step()</a>).
  The purpose of the likely(X) function is to provide a hint
  to the query planner that the argument X is a boolean value
  that is usually true. The likely(X) function is equivalent
  to <a href="lang_corefunc.html#likelihood">likelihood</a>(X,0.9375). See also: <a href="lang_corefunc.html#unlikely">unlikely(X)</a>.
</td></tr><tr><td valign="top" align="right" width="120"><a name="load_extension"></a>
load_extension(<i>X</i>)<br />load_extension(<i>X</i>,<i>Y</i>)</td><td valign="top">
  The load_extension(X,Y) function loads <a href="loadext.html">SQLite extensions</a> out of the shared
  library file named X using the entry point Y.  The result of load_extension()
  is always a NULL.  If Y is omitted then the default entry point name is used.
  The load_extension() function raises an exception if the extension fails to
  load or initialize correctly.
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
  maximum value, or return NULL if any argument is NULL. 
  The multi-argument max() function searches its arguments from left to right
  for an argument that defines a collating function and uses that collating
  function for all string comparisons.  If none of the arguments to max()
  define a collating function, then the BINARY collating function is used.
  Note that <b>max()</b> is a simple function when
  it has 2 or more arguments but operates as an
  <a href="lang_aggfunc.html#minggunc">aggregate function</a> if given only a single argument.
</td></tr><tr><td valign="top" align="right" width="120"><a name="minoreunc"></a>
min(<i>X</i>,<i>Y</i>,...)</td><td valign="top">
  The multi-argument min() function returns the argument with the
  minimum value.
  The multi-argument min() function searches its arguments from left to right
  for an argument that defines a collating function and uses that collating
  function for all string comparisons.  If none of the arguments to min()
  define a collating function, then the BINARY collating function is used.
  Note that <b>min()</b> is a simple function when
  it has 2 or more arguments but operates as an 
  <a href="lang_aggfunc.html#maxggunc">aggregate function</a> if given
  only a single argument.
</td></tr><tr><td valign="top" align="right" width="120"><a name="nullif"></a>
nullif(<i>X</i>,<i>Y</i>)</td><td valign="top">
  The nullif(X,Y) function returns its first argument if the arguments are
  different and NULL if the arguments are the same.  The nullif(X,Y) function
  searches its arguments from left to right for an argument that defines a
  collating function and uses that collating function for all string







|










|







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
  maximum value, or return NULL if any argument is NULL. 
  The multi-argument max() function searches its arguments from left to right
  for an argument that defines a collating function and uses that collating
  function for all string comparisons.  If none of the arguments to max()
  define a collating function, then the BINARY collating function is used.
  Note that <b>max()</b> is a simple function when
  it has 2 or more arguments but operates as an
  <a href="lang_aggfunc.html#maxggunc">aggregate function</a> if given only a single argument.
</td></tr><tr><td valign="top" align="right" width="120"><a name="minoreunc"></a>
min(<i>X</i>,<i>Y</i>,...)</td><td valign="top">
  The multi-argument min() function returns the argument with the
  minimum value.
  The multi-argument min() function searches its arguments from left to right
  for an argument that defines a collating function and uses that collating
  function for all string comparisons.  If none of the arguments to min()
  define a collating function, then the BINARY collating function is used.
  Note that <b>min()</b> is a simple function when
  it has 2 or more arguments but operates as an 
  <a href="lang_aggfunc.html#minggunc">aggregate function</a> if given
  only a single argument.
</td></tr><tr><td valign="top" align="right" width="120"><a name="nullif"></a>
nullif(<i>X</i>,<i>Y</i>)</td><td valign="top">
  The nullif(X,Y) function returns its first argument if the arguments are
  different and NULL if the arguments are the same.  The nullif(X,Y) function
  searches its arguments from left to right for an argument that defines a
  collating function and uses that collating function for all string
Changes to Doc/Extra/Core/lang_createindex.html.
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
    </form>
    </div>
  </table>

<div class=startsearch></div>
  
<h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>CREATE INDEX</h2><p><b><a href="syntaxdiagrams.html#create-index-stmt">create-index-stmt:</a></b>
<button id='x807' onclick='hideorshow("x807","x808")'>hide</button></p>
 <blockquote id='x808'>
 <img alt="syntax diagram create-index-stmt" src="images/syntax/create-index-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#expr">expr:</a></b>
<button id='x809' onclick='hideorshow("x809","x810")'>show</button></p>
 <blockquote id='x810' style='display:none;'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntaxdiagrams.html#literal-value">literal-value:</a></b>
<button id='x811' onclick='hideorshow("x811","x812")'>show</button></p>
 <blockquote id='x812' style='display:none;'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#raise-function">raise-function:</a></b>
<button id='x813' onclick='hideorshow("x813","x814")'>show</button></p>
 <blockquote id='x814' style='display:none;'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#select-stmt">select-stmt:</a></b>
<button id='x815' onclick='hideorshow("x815","x816")'>show</button></p>
 <blockquote id='x816' style='display:none;'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#common-table-expression">common-table-expression:</a></b>
<button id='x817' onclick='hideorshow("x817","x818")'>show</button></p>
 <blockquote id='x818' style='display:none;'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#compound-operator">compound-operator:</a></b>
<button id='x819' onclick='hideorshow("x819","x820")'>show</button></p>
 <blockquote id='x820' style='display:none;'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-clause">join-clause:</a></b>
<button id='x821' onclick='hideorshow("x821","x822")'>show</button></p>
 <blockquote id='x822' style='display:none;'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntaxdiagrams.html#join-constraint">join-constraint:</a></b>
<button id='x823' onclick='hideorshow("x823","x824")'>show</button></p>
 <blockquote id='x824' style='display:none;'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-operator">join-operator:</a></b>
<button id='x825' onclick='hideorshow("x825","x826")'>show</button></p>
 <blockquote id='x826' style='display:none;'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#ordering-term">ordering-term:</a></b>
<button id='x827' onclick='hideorshow("x827","x828")'>show</button></p>
 <blockquote id='x828' style='display:none;'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#result-column">result-column:</a></b>
<button id='x829' onclick='hideorshow("x829","x830")'>show</button></p>
 <blockquote id='x830' style='display:none;'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#table-or-subquery">table-or-subquery:</a></b>
<button id='x831' onclick='hideorshow("x831","x832")'>show</button></p>
 <blockquote id='x832' style='display:none;'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#type-name">type-name:</a></b>
<button id='x833' onclick='hideorshow("x833","x834")'>show</button></p>
 <blockquote id='x834' style='display:none;'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntaxdiagrams.html#signed-number">signed-number:</a></b>
<button id='x835' onclick='hideorshow("x835","x836")'>show</button></p>
 <blockquote id='x836' style='display:none;'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</blockquote>
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#indexed-column">indexed-column:</a></b>
<button id='x837' onclick='hideorshow("x837","x838")'>show</button></p>
 <blockquote id='x838' style='display:none;'>
 <img alt="syntax diagram indexed-column" src="images/syntax/indexed-column.gif" />
</blockquote>
</blockquote>


<p>The CREATE INDEX command consists of the keywords "CREATE INDEX" followed
by the name of the new index, the keyword "ON", the name of a previously







|
|


|
|


|
|



|
|



|
|


|
|



|
|



|
|


|
|



|
|




|
|



|
|



|
|




|
|


|
|





|
|







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
    </form>
    </div>
  </table>

<div class=startsearch></div>
  
<h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>CREATE INDEX</h2><p><b><a href="syntaxdiagrams.html#create-index-stmt">create-index-stmt:</a></b>
<button id='x823' onclick='hideorshow("x823","x824")'>hide</button></p>
 <blockquote id='x824'>
 <img alt="syntax diagram create-index-stmt" src="images/syntax/create-index-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#expr">expr:</a></b>
<button id='x825' onclick='hideorshow("x825","x826")'>show</button></p>
 <blockquote id='x826' style='display:none;'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntaxdiagrams.html#literal-value">literal-value:</a></b>
<button id='x827' onclick='hideorshow("x827","x828")'>show</button></p>
 <blockquote id='x828' style='display:none;'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#raise-function">raise-function:</a></b>
<button id='x829' onclick='hideorshow("x829","x830")'>show</button></p>
 <blockquote id='x830' style='display:none;'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#select-stmt">select-stmt:</a></b>
<button id='x831' onclick='hideorshow("x831","x832")'>show</button></p>
 <blockquote id='x832' style='display:none;'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#common-table-expression">common-table-expression:</a></b>
<button id='x833' onclick='hideorshow("x833","x834")'>show</button></p>
 <blockquote id='x834' style='display:none;'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#compound-operator">compound-operator:</a></b>
<button id='x835' onclick='hideorshow("x835","x836")'>show</button></p>
 <blockquote id='x836' style='display:none;'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-clause">join-clause:</a></b>
<button id='x837' onclick='hideorshow("x837","x838")'>show</button></p>
 <blockquote id='x838' style='display:none;'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntaxdiagrams.html#join-constraint">join-constraint:</a></b>
<button id='x839' onclick='hideorshow("x839","x840")'>show</button></p>
 <blockquote id='x840' style='display:none;'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-operator">join-operator:</a></b>
<button id='x841' onclick='hideorshow("x841","x842")'>show</button></p>
 <blockquote id='x842' style='display:none;'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#ordering-term">ordering-term:</a></b>
<button id='x843' onclick='hideorshow("x843","x844")'>show</button></p>
 <blockquote id='x844' style='display:none;'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#result-column">result-column:</a></b>
<button id='x845' onclick='hideorshow("x845","x846")'>show</button></p>
 <blockquote id='x846' style='display:none;'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#table-or-subquery">table-or-subquery:</a></b>
<button id='x847' onclick='hideorshow("x847","x848")'>show</button></p>
 <blockquote id='x848' style='display:none;'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#type-name">type-name:</a></b>
<button id='x849' onclick='hideorshow("x849","x850")'>show</button></p>
 <blockquote id='x850' style='display:none;'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntaxdiagrams.html#signed-number">signed-number:</a></b>
<button id='x851' onclick='hideorshow("x851","x852")'>show</button></p>
 <blockquote id='x852' style='display:none;'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</blockquote>
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#indexed-column">indexed-column:</a></b>
<button id='x853' onclick='hideorshow("x853","x854")'>show</button></p>
 <blockquote id='x854' style='display:none;'>
 <img alt="syntax diagram indexed-column" src="images/syntax/indexed-column.gif" />
</blockquote>
</blockquote>


<p>The CREATE INDEX command consists of the keywords "CREATE INDEX" followed
by the name of the new index, the keyword "ON", the name of a previously
Changes to Doc/Extra/Core/lang_createtable.html.
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
    </form>
    </div>
  </table>

<div class=startsearch></div>
  
<h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>CREATE TABLE</h2><p><b><a href="syntaxdiagrams.html#create-table-stmt">create-table-stmt:</a></b>
<button id='x839' onclick='hideorshow("x839","x840")'>hide</button></p>
 <blockquote id='x840'>
 <img alt="syntax diagram create-table-stmt" src="images/syntax/create-table-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#column-def">column-def:</a></b>
<button id='x841' onclick='hideorshow("x841","x842")'>show</button></p>
 <blockquote id='x842' style='display:none;'>
 <img alt="syntax diagram column-def" src="images/syntax/column-def.gif" />
<p><b><a href="syntaxdiagrams.html#column-constraint">column-constraint:</a></b>
<button id='x843' onclick='hideorshow("x843","x844")'>show</button></p>
 <blockquote id='x844' style='display:none;'>
 <img alt="syntax diagram column-constraint" src="images/syntax/column-constraint.gif" />
<p><b><a href="syntaxdiagrams.html#conflict-clause">conflict-clause:</a></b>
<button id='x845' onclick='hideorshow("x845","x846")'>show</button></p>
 <blockquote id='x846' style='display:none;'>
 <img alt="syntax diagram conflict-clause" src="images/syntax/conflict-clause.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#expr">expr:</a></b>
<button id='x847' onclick='hideorshow("x847","x848")'>show</button></p>
 <blockquote id='x848' style='display:none;'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntaxdiagrams.html#raise-function">raise-function:</a></b>
<button id='x849' onclick='hideorshow("x849","x850")'>show</button></p>
 <blockquote id='x850' style='display:none;'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#foreign-key-clause">foreign-key-clause:</a></b>
<button id='x851' onclick='hideorshow("x851","x852")'>show</button></p>
 <blockquote id='x852' style='display:none;'>
 <img alt="syntax diagram foreign-key-clause" src="images/syntax/foreign-key-clause.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#literal-value">literal-value:</a></b>
<button id='x853' onclick='hideorshow("x853","x854")'>show</button></p>
 <blockquote id='x854' style='display:none;'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#signed-number">signed-number:</a></b>
<button id='x855' onclick='hideorshow("x855","x856")'>show</button></p>
 <blockquote id='x856' style='display:none;'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#type-name">type-name:</a></b>
<button id='x857' onclick='hideorshow("x857","x858")'>show</button></p>
 <blockquote id='x858' style='display:none;'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntaxdiagrams.html#signed-number">signed-number:</a></b>
<button id='x859' onclick='hideorshow("x859","x860")'>show</button></p>
 <blockquote id='x860' style='display:none;'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</blockquote>
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#select-stmt">select-stmt:</a></b>
<button id='x861' onclick='hideorshow("x861","x862")'>show</button></p>
 <blockquote id='x862' style='display:none;'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#common-table-expression">common-table-expression:</a></b>
<button id='x863' onclick='hideorshow("x863","x864")'>show</button></p>
 <blockquote id='x864' style='display:none;'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#compound-operator">compound-operator:</a></b>
<button id='x865' onclick='hideorshow("x865","x866")'>show</button></p>
 <blockquote id='x866' style='display:none;'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#expr">expr:</a></b>
<button id='x867' onclick='hideorshow("x867","x868")'>show</button></p>
 <blockquote id='x868' style='display:none;'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntaxdiagrams.html#literal-value">literal-value:</a></b>
<button id='x869' onclick='hideorshow("x869","x870")'>show</button></p>
 <blockquote id='x870' style='display:none;'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#raise-function">raise-function:</a></b>
<button id='x871' onclick='hideorshow("x871","x872")'>show</button></p>
 <blockquote id='x872' style='display:none;'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />

</blockquote>
<p><b><a href="syntaxdiagrams.html#type-name">type-name:</a></b>
<button id='x873' onclick='hideorshow("x873","x874")'>show</button></p>
 <blockquote id='x874' style='display:none;'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntaxdiagrams.html#signed-number">signed-number:</a></b>
<button id='x875' onclick='hideorshow("x875","x876")'>show</button></p>
 <blockquote id='x876' style='display:none;'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</blockquote>
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-clause">join-clause:</a></b>
<button id='x877' onclick='hideorshow("x877","x878")'>show</button></p>
 <blockquote id='x878' style='display:none;'>







































 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntaxdiagrams.html#join-constraint">join-constraint:</a></b>
<button id='x879' onclick='hideorshow("x879","x880")'>show</button></p>
 <blockquote id='x880' style='display:none;'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-operator">join-operator:</a></b>
<button id='x881' onclick='hideorshow("x881","x882")'>show</button></p>
 <blockquote id='x882' style='display:none;'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#ordering-term">ordering-term:</a></b>
<button id='x883' onclick='hideorshow("x883","x884")'>show</button></p>
 <blockquote id='x884' style='display:none;'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#result-column">result-column:</a></b>
<button id='x885' onclick='hideorshow("x885","x886")'>show</button></p>
 <blockquote id='x886' style='display:none;'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#table-or-subquery">table-or-subquery:</a></b>
<button id='x887' onclick='hideorshow("x887","x888")'>show</button></p>
 <blockquote id='x888' style='display:none;'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#table-constraint">table-constraint:</a></b>
<button id='x889' onclick='hideorshow("x889","x890")'>show</button></p>
 <blockquote id='x890' style='display:none;'>
 <img alt="syntax diagram table-constraint" src="images/syntax/table-constraint.gif" />
<p><b><a href="syntaxdiagrams.html#conflict-clause">conflict-clause:</a></b>
<button id='x891' onclick='hideorshow("x891","x892")'>show</button></p>
 <blockquote id='x892' style='display:none;'>
 <img alt="syntax diagram conflict-clause" src="images/syntax/conflict-clause.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#expr">expr:</a></b>
<button id='x893' onclick='hideorshow("x893","x894")'>show</button></p>
 <blockquote id='x894' style='display:none;'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntaxdiagrams.html#literal-value">literal-value:</a></b>
<button id='x895' onclick='hideorshow("x895","x896")'>show</button></p>
 <blockquote id='x896' style='display:none;'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#raise-function">raise-function:</a></b>
<button id='x897' onclick='hideorshow("x897","x898")'>show</button></p>
 <blockquote id='x898' style='display:none;'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#type-name">type-name:</a></b>
<button id='x899' onclick='hideorshow("x899","x900")'>show</button></p>
 <blockquote id='x900' style='display:none;'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntaxdiagrams.html#signed-number">signed-number:</a></b>
<button id='x901' onclick='hideorshow("x901","x902")'>show</button></p>
 <blockquote id='x902' style='display:none;'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</blockquote>
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#foreign-key-clause">foreign-key-clause:</a></b>
<button id='x903' onclick='hideorshow("x903","x904")'>show</button></p>
 <blockquote id='x904' style='display:none;'>
 <img alt="syntax diagram foreign-key-clause" src="images/syntax/foreign-key-clause.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#indexed-column">indexed-column:</a></b>
<button id='x905' onclick='hideorshow("x905","x906")'>show</button></p>
 <blockquote id='x906' style='display:none;'>
 <img alt="syntax diagram indexed-column" src="images/syntax/indexed-column.gif" />
</blockquote>
</blockquote>
</blockquote>


<p>The "CREATE TABLE" command is used to create a new table in an SQLite 







|
|


|
|


|
|


|
|



|
|


|
|




|
|



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




|


|
>












|


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


|
|



|
|




|
|



|
|



|
|




|
|


|
|



|
|


|
|



|
|



|
|


|
|





|
|



|
|







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
    </form>
    </div>
  </table>

<div class=startsearch></div>
  
<h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>CREATE TABLE</h2><p><b><a href="syntaxdiagrams.html#create-table-stmt">create-table-stmt:</a></b>
<button id='x855' onclick='hideorshow("x855","x856")'>hide</button></p>
 <blockquote id='x856'>
 <img alt="syntax diagram create-table-stmt" src="images/syntax/create-table-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#column-def">column-def:</a></b>
<button id='x857' onclick='hideorshow("x857","x858")'>show</button></p>
 <blockquote id='x858' style='display:none;'>
 <img alt="syntax diagram column-def" src="images/syntax/column-def.gif" />
<p><b><a href="syntaxdiagrams.html#column-constraint">column-constraint:</a></b>
<button id='x859' onclick='hideorshow("x859","x860")'>show</button></p>
 <blockquote id='x860' style='display:none;'>
 <img alt="syntax diagram column-constraint" src="images/syntax/column-constraint.gif" />
<p><b><a href="syntaxdiagrams.html#conflict-clause">conflict-clause:</a></b>
<button id='x861' onclick='hideorshow("x861","x862")'>show</button></p>
 <blockquote id='x862' style='display:none;'>
 <img alt="syntax diagram conflict-clause" src="images/syntax/conflict-clause.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#expr">expr:</a></b>
<button id='x863' onclick='hideorshow("x863","x864")'>show</button></p>
 <blockquote id='x864' style='display:none;'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntaxdiagrams.html#raise-function">raise-function:</a></b>
<button id='x865' onclick='hideorshow("x865","x866")'>show</button></p>
 <blockquote id='x866' style='display:none;'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#foreign-key-clause">foreign-key-clause:</a></b>
<button id='x867' onclick='hideorshow("x867","x868")'>show</button></p>
 <blockquote id='x868' style='display:none;'>
 <img alt="syntax diagram foreign-key-clause" src="images/syntax/foreign-key-clause.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#literal-value">literal-value:</a></b>








































<button id='x869' onclick='hideorshow("x869","x870")'>show</button></p>
 <blockquote id='x870' style='display:none;'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#signed-number">signed-number:</a></b>
<button id='x871' onclick='hideorshow("x871","x872")'>show</button></p>
 <blockquote id='x872' style='display:none;'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#type-name">type-name:</a></b>
<button id='x873' onclick='hideorshow("x873","x874")'>show</button></p>
 <blockquote id='x874' style='display:none;'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntaxdiagrams.html#signed-number">signed-number:</a></b>
<button id='x875' onclick='hideorshow("x875","x876")'>show</button></p>
 <blockquote id='x876' style='display:none;'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</blockquote>
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#select-stmt">select-stmt:</a></b>
<button id='x877' onclick='hideorshow("x877","x878")'>show</button></p>
 <blockquote id='x878' style='display:none;'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#common-table-expression">common-table-expression:</a></b>
<button id='x879' onclick='hideorshow("x879","x880")'>show</button></p>
 <blockquote id='x880' style='display:none;'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#compound-operator">compound-operator:</a></b>
<button id='x881' onclick='hideorshow("x881","x882")'>show</button></p>
 <blockquote id='x882' style='display:none;'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#expr">expr:</a></b>
<button id='x883' onclick='hideorshow("x883","x884")'>show</button></p>
 <blockquote id='x884' style='display:none;'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntaxdiagrams.html#literal-value">literal-value:</a></b>
<button id='x885' onclick='hideorshow("x885","x886")'>show</button></p>
 <blockquote id='x886' style='display:none;'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#raise-function">raise-function:</a></b>
<button id='x887' onclick='hideorshow("x887","x888")'>show</button></p>
 <blockquote id='x888' style='display:none;'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#type-name">type-name:</a></b>
<button id='x889' onclick='hideorshow("x889","x890")'>show</button></p>
 <blockquote id='x890' style='display:none;'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntaxdiagrams.html#signed-number">signed-number:</a></b>
<button id='x891' onclick='hideorshow("x891","x892")'>show</button></p>
 <blockquote id='x892' style='display:none;'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</blockquote>
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-clause">join-clause:</a></b>
<button id='x893' onclick='hideorshow("x893","x894")'>show</button></p>
 <blockquote id='x894' style='display:none;'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntaxdiagrams.html#join-constraint">join-constraint:</a></b>
<button id='x895' onclick='hideorshow("x895","x896")'>show</button></p>
 <blockquote id='x896' style='display:none;'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-operator">join-operator:</a></b>
<button id='x897' onclick='hideorshow("x897","x898")'>show</button></p>
 <blockquote id='x898' style='display:none;'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#ordering-term">ordering-term:</a></b>
<button id='x899' onclick='hideorshow("x899","x900")'>show</button></p>
 <blockquote id='x900' style='display:none;'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#result-column">result-column:</a></b>
<button id='x901' onclick='hideorshow("x901","x902")'>show</button></p>
 <blockquote id='x902' style='display:none;'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#table-or-subquery">table-or-subquery:</a></b>
<button id='x903' onclick='hideorshow("x903","x904")'>show</button></p>
 <blockquote id='x904' style='display:none;'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#table-constraint">table-constraint:</a></b>
<button id='x905' onclick='hideorshow("x905","x906")'>show</button></p>
 <blockquote id='x906' style='display:none;'>
 <img alt="syntax diagram table-constraint" src="images/syntax/table-constraint.gif" />
<p><b><a href="syntaxdiagrams.html#conflict-clause">conflict-clause:</a></b>
<button id='x907' onclick='hideorshow("x907","x908")'>show</button></p>
 <blockquote id='x908' style='display:none;'>
 <img alt="syntax diagram conflict-clause" src="images/syntax/conflict-clause.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#expr">expr:</a></b>
<button id='x909' onclick='hideorshow("x909","x910")'>show</button></p>
 <blockquote id='x910' style='display:none;'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntaxdiagrams.html#literal-value">literal-value:</a></b>
<button id='x911' onclick='hideorshow("x911","x912")'>show</button></p>
 <blockquote id='x912' style='display:none;'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#raise-function">raise-function:</a></b>
<button id='x913' onclick='hideorshow("x913","x914")'>show</button></p>
 <blockquote id='x914' style='display:none;'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#type-name">type-name:</a></b>
<button id='x915' onclick='hideorshow("x915","x916")'>show</button></p>
 <blockquote id='x916' style='display:none;'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntaxdiagrams.html#signed-number">signed-number:</a></b>
<button id='x917' onclick='hideorshow("x917","x918")'>show</button></p>
 <blockquote id='x918' style='display:none;'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</blockquote>
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#foreign-key-clause">foreign-key-clause:</a></b>
<button id='x919' onclick='hideorshow("x919","x920")'>show</button></p>
 <blockquote id='x920' style='display:none;'>
 <img alt="syntax diagram foreign-key-clause" src="images/syntax/foreign-key-clause.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#indexed-column">indexed-column:</a></b>
<button id='x921' onclick='hideorshow("x921","x922")'>show</button></p>
 <blockquote id='x922' style='display:none;'>
 <img alt="syntax diagram indexed-column" src="images/syntax/indexed-column.gif" />
</blockquote>
</blockquote>
</blockquote>


<p>The "CREATE TABLE" command is used to create a new table in an SQLite 
412
413
414
415
416
417
418
419

420
421
422
423
424
425
426
is no explicit DEFAULT clause attached to a column definition, then the 
default value of the column is NULL. An explicit DEFAULT clause may specify
that the default value is NULL, a string constant, a blob constant, a
signed-number, or any constant expression enclosed in parentheses. An explicit
default value may also be one of the special case-independent keywords
CURRENT_TIME, CURRENT_DATE or CURRENT_TIMESTAMP. For the purposes of the
DEFAULT clause, an expression is considered constant provided that it does
not contain any sub-queries or string constants enclosed in double quotes.


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

<ul>
  <li><p>If the default value of the column is a constant NULL, text, blob or







|
>







412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
is no explicit DEFAULT clause attached to a column definition, then the 
default value of the column is NULL. An explicit DEFAULT clause may specify
that the default value is NULL, a string constant, a blob constant, a
signed-number, or any constant expression enclosed in parentheses. An explicit
default value may also be one of the special case-independent keywords
CURRENT_TIME, CURRENT_DATE or CURRENT_TIMESTAMP. For the purposes of the
DEFAULT clause, an expression is considered constant provided that it does
not contain any sub-queries, column or table references, 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
468
469
470
471
472
473
474
475

476
477
478
479
480
481
482
483
  associated with an <a href="lang_createtable.html#rowid">INTEGER PRIMARY KEY</a>.

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

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







|
>
|







469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
  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.
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
  the expression associated with each CHECK constraint is evaluated and
  cast to a NUMERIC value in the same way as a <a href="lang_expr.html#castexpr">CAST expression</a>. If the 
  result is zero (integer value 0 or real value 0.0), then a constraint
  violation has occurred. If the CHECK expression evaluates to NULL, or
  any other non-zero value, it is not a constraint violation.
  The expression of a CHECK constraint may not contain a subquery.

<p>CHECK constraints have been supported since <a href="releaselog/3_3_0.html">version 3.3.0</a>. Prior to
  version 3.3.0, CHECK constraints were parsed but not enforced.

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

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







<
<
<







514
515
516
517
518
519
520



521
522
523
524
525
526
527
  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>A <b>NOT NULL</b> constraint may only be attached to a column definition,
  not specified as a table constraint.  Not surprisingly, a NOT NULL
  constraint dictates that the associated column may not contain a NULL value.
  Attempting to set the column value to NULL when inserting a new row or
  updating an existing one causes a constraint violation.
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
the rowid.

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

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







|







572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
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>
Changes to Doc/Extra/Core/lang_createtrigger.html.
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
    </form>
    </div>
  </table>

<div class=startsearch></div>
  
<h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>CREATE TRIGGER</h2><p><b><a href="syntaxdiagrams.html#create-trigger-stmt">create-trigger-stmt:</a></b>
<button id='x907' onclick='hideorshow("x907","x908")'>hide</button></p>
 <blockquote id='x908'>
 <img alt="syntax diagram create-trigger-stmt" src="images/syntax/create-trigger-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#delete-stmt">delete-stmt:</a></b>
<button id='x909' onclick='hideorshow("x909","x910")'>show</button></p>
 <blockquote id='x910' style='display:none;'>
 <img alt="syntax diagram delete-stmt" src="images/syntax/delete-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#qualified-table-name">qualified-table-name:</a></b>
<button id='x911' onclick='hideorshow("x911","x912")'>show</button></p>
 <blockquote id='x912' style='display:none;'>
 <img alt="syntax diagram qualified-table-name" src="images/syntax/qualified-table-name.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#with-clause">with-clause:</a></b>
<button id='x913' onclick='hideorshow("x913","x914")'>show</button></p>
 <blockquote id='x914' style='display:none;'>
 <img alt="syntax diagram with-clause" src="images/syntax/with-clause.gif" />
<p><b><a href="syntaxdiagrams.html#cte-table-name">cte-table-name:</a></b>
<button id='x915' onclick='hideorshow("x915","x916")'>show</button></p>
 <blockquote id='x916' style='display:none;'>
 <img alt="syntax diagram cte-table-name" src="images/syntax/cte-table-name.gif" />
</blockquote>
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#expr">expr:</a></b>
<button id='x917' onclick='hideorshow("x917","x918")'>show</button></p>
 <blockquote id='x918' style='display:none;'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntaxdiagrams.html#literal-value">literal-value:</a></b>
<button id='x919' onclick='hideorshow("x919","x920")'>show</button></p>
 <blockquote id='x920' style='display:none;'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#raise-function">raise-function:</a></b>
<button id='x921' onclick='hideorshow("x921","x922")'>show</button></p>
 <blockquote id='x922' style='display:none;'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#type-name">type-name:</a></b>
<button id='x923' onclick='hideorshow("x923","x924")'>show</button></p>
 <blockquote id='x924' style='display:none;'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntaxdiagrams.html#signed-number">signed-number:</a></b>
<button id='x925' onclick='hideorshow("x925","x926")'>show</button></p>
 <blockquote id='x926' style='display:none;'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</blockquote>
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#insert-stmt">insert-stmt:</a></b>
<button id='x927' onclick='hideorshow("x927","x928")'>show</button></p>
 <blockquote id='x928' style='display:none;'>
 <img alt="syntax diagram insert-stmt" src="images/syntax/insert-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#with-clause">with-clause:</a></b>
<button id='x929' onclick='hideorshow("x929","x930")'>show</button></p>
 <blockquote id='x930' style='display:none;'>
 <img alt="syntax diagram with-clause" src="images/syntax/with-clause.gif" />
<p><b><a href="syntaxdiagrams.html#cte-table-name">cte-table-name:</a></b>
<button id='x931' onclick='hideorshow("x931","x932")'>show</button></p>
 <blockquote id='x932' style='display:none;'>
 <img alt="syntax diagram cte-table-name" src="images/syntax/cte-table-name.gif" />
</blockquote>
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#select-stmt">select-stmt:</a></b>
<button id='x933' onclick='hideorshow("x933","x934")'>show</button></p>
 <blockquote id='x934' style='display:none;'>








































 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#common-table-expression">common-table-expression:</a></b>
<button id='x935' onclick='hideorshow("x935","x936")'>show</button></p>
 <blockquote id='x936' style='display:none;'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#compound-operator">compound-operator:</a></b>
<button id='x937' onclick='hideorshow("x937","x938")'>show</button></p>
 <blockquote id='x938' style='display:none;'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-clause">join-clause:</a></b>
<button id='x939' onclick='hideorshow("x939","x940")'>show</button></p>
 <blockquote id='x940' style='display:none;'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntaxdiagrams.html#join-constraint">join-constraint:</a></b>
<button id='x941' onclick='hideorshow("x941","x942")'>show</button></p>
 <blockquote id='x942' style='display:none;'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-operator">join-operator:</a></b>
<button id='x943' onclick='hideorshow("x943","x944")'>show</button></p>
 <blockquote id='x944' style='display:none;'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#ordering-term">ordering-term:</a></b>
<button id='x945' onclick='hideorshow("x945","x946")'>show</button></p>
 <blockquote id='x946' style='display:none;'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#result-column">result-column:</a></b>
<button id='x947' onclick='hideorshow("x947","x948")'>show</button></p>
 <blockquote id='x948' style='display:none;'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#table-or-subquery">table-or-subquery:</a></b>
<button id='x949' onclick='hideorshow("x949","x950")'>show</button></p>
 <blockquote id='x950' style='display:none;'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#update-stmt">update-stmt:</a></b>
<button id='x951' onclick='hideorshow("x951","x952")'>show</button></p>
 <blockquote id='x952' style='display:none;'>
 <img alt="syntax diagram update-stmt" src="images/syntax/update-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#qualified-table-name">qualified-table-name:</a></b>
<button id='x953' onclick='hideorshow("x953","x954")'>show</button></p>
 <blockquote id='x954' style='display:none;'>
 <img alt="syntax diagram qualified-table-name" src="images/syntax/qualified-table-name.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#with-clause">with-clause:</a></b>
<button id='x955' onclick='hideorshow("x955","x956")'>show</button></p>
 <blockquote id='x956' style='display:none;'>
 <img alt="syntax diagram with-clause" src="images/syntax/with-clause.gif" />
<p><b><a href="syntaxdiagrams.html#cte-table-name">cte-table-name:</a></b>
<button id='x957' onclick='hideorshow("x957","x958")'>show</button></p>
 <blockquote id='x958' style='display:none;'>
 <img alt="syntax diagram cte-table-name" src="images/syntax/cte-table-name.gif" />
</blockquote>
</blockquote>
</blockquote>
</blockquote>









|
|


|
|


|
|



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










|


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


|
|



|
|



|
|


|
|



|
|




|
|



|
|



|
|




|
|


|
|



|
|


|
|







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
    </form>
    </div>
  </table>

<div class=startsearch></div>
  
<h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>CREATE TRIGGER</h2><p><b><a href="syntaxdiagrams.html#create-trigger-stmt">create-trigger-stmt:</a></b>
<button id='x923' onclick='hideorshow("x923","x924")'>hide</button></p>
 <blockquote id='x924'>
 <img alt="syntax diagram create-trigger-stmt" src="images/syntax/create-trigger-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#delete-stmt">delete-stmt:</a></b>
<button id='x925' onclick='hideorshow("x925","x926")'>show</button></p>
 <blockquote id='x926' style='display:none;'>
 <img alt="syntax diagram delete-stmt" src="images/syntax/delete-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#qualified-table-name">qualified-table-name:</a></b>
<button id='x927' onclick='hideorshow("x927","x928")'>show</button></p>
 <blockquote id='x928' style='display:none;'>
 <img alt="syntax diagram qualified-table-name" src="images/syntax/qualified-table-name.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#with-clause">with-clause:</a></b>








































<button id='x929' onclick='hideorshow("x929","x930")'>show</button></p>
 <blockquote id='x930' style='display:none;'>
 <img alt="syntax diagram with-clause" src="images/syntax/with-clause.gif" />
<p><b><a href="syntaxdiagrams.html#cte-table-name">cte-table-name:</a></b>
<button id='x931' onclick='hideorshow("x931","x932")'>show</button></p>
 <blockquote id='x932' style='display:none;'>
 <img alt="syntax diagram cte-table-name" src="images/syntax/cte-table-name.gif" />
</blockquote>
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#expr">expr:</a></b>
<button id='x933' onclick='hideorshow("x933","x934")'>show</button></p>
 <blockquote id='x934' style='display:none;'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntaxdiagrams.html#literal-value">literal-value:</a></b>
<button id='x935' onclick='hideorshow("x935","x936")'>show</button></p>
 <blockquote id='x936' style='display:none;'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#raise-function">raise-function:</a></b>
<button id='x937' onclick='hideorshow("x937","x938")'>show</button></p>
 <blockquote id='x938' style='display:none;'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#type-name">type-name:</a></b>
<button id='x939' onclick='hideorshow("x939","x940")'>show</button></p>
 <blockquote id='x940' style='display:none;'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntaxdiagrams.html#signed-number">signed-number:</a></b>
<button id='x941' onclick='hideorshow("x941","x942")'>show</button></p>
 <blockquote id='x942' style='display:none;'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</blockquote>
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#insert-stmt">insert-stmt:</a></b>
<button id='x943' onclick='hideorshow("x943","x944")'>show</button></p>
 <blockquote id='x944' style='display:none;'>
 <img alt="syntax diagram insert-stmt" src="images/syntax/insert-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#with-clause">with-clause:</a></b>
<button id='x945' onclick='hideorshow("x945","x946")'>show</button></p>
 <blockquote id='x946' style='display:none;'>
 <img alt="syntax diagram with-clause" src="images/syntax/with-clause.gif" />
<p><b><a href="syntaxdiagrams.html#cte-table-name">cte-table-name:</a></b>
<button id='x947' onclick='hideorshow("x947","x948")'>show</button></p>
 <blockquote id='x948' style='display:none;'>
 <img alt="syntax diagram cte-table-name" src="images/syntax/cte-table-name.gif" />
</blockquote>
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#select-stmt">select-stmt:</a></b>
<button id='x949' onclick='hideorshow("x949","x950")'>show</button></p>
 <blockquote id='x950' style='display:none;'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#common-table-expression">common-table-expression:</a></b>
<button id='x951' onclick='hideorshow("x951","x952")'>show</button></p>
 <blockquote id='x952' style='display:none;'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#compound-operator">compound-operator:</a></b>
<button id='x953' onclick='hideorshow("x953","x954")'>show</button></p>
 <blockquote id='x954' style='display:none;'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-clause">join-clause:</a></b>
<button id='x955' onclick='hideorshow("x955","x956")'>show</button></p>
 <blockquote id='x956' style='display:none;'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntaxdiagrams.html#join-constraint">join-constraint:</a></b>
<button id='x957' onclick='hideorshow("x957","x958")'>show</button></p>
 <blockquote id='x958' style='display:none;'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-operator">join-operator:</a></b>
<button id='x959' onclick='hideorshow("x959","x960")'>show</button></p>
 <blockquote id='x960' style='display:none;'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#ordering-term">ordering-term:</a></b>
<button id='x961' onclick='hideorshow("x961","x962")'>show</button></p>
 <blockquote id='x962' style='display:none;'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#result-column">result-column:</a></b>
<button id='x963' onclick='hideorshow("x963","x964")'>show</button></p>
 <blockquote id='x964' style='display:none;'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#table-or-subquery">table-or-subquery:</a></b>
<button id='x965' onclick='hideorshow("x965","x966")'>show</button></p>
 <blockquote id='x966' style='display:none;'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#update-stmt">update-stmt:</a></b>
<button id='x967' onclick='hideorshow("x967","x968")'>show</button></p>
 <blockquote id='x968' style='display:none;'>
 <img alt="syntax diagram update-stmt" src="images/syntax/update-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#qualified-table-name">qualified-table-name:</a></b>
<button id='x969' onclick='hideorshow("x969","x970")'>show</button></p>
 <blockquote id='x970' style='display:none;'>
 <img alt="syntax diagram qualified-table-name" src="images/syntax/qualified-table-name.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#with-clause">with-clause:</a></b>
<button id='x971' onclick='hideorshow("x971","x972")'>show</button></p>
 <blockquote id='x972' style='display:none;'>
 <img alt="syntax diagram with-clause" src="images/syntax/with-clause.gif" />
<p><b><a href="syntaxdiagrams.html#cte-table-name">cte-table-name:</a></b>
<button id='x973' onclick='hideorshow("x973","x974")'>show</button></p>
 <blockquote id='x974' style='display:none;'>
 <img alt="syntax diagram cte-table-name" src="images/syntax/cte-table-name.gif" />
</blockquote>
</blockquote>
</blockquote>
</blockquote>


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
  that compile-time option only applies to top-level <a href="lang_update.html">UPDATE</a> and <a href="lang_delete.html">DELETE</a>
  statements, not <a href="lang_update.html">UPDATE</a> and <a href="lang_delete.html">DELETE</a> statements within triggers.
  </p></li>
</ul>

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

<h3>INSTEAD OF trigger</h3>

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

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

<h3>Examples</h3>

<p>Assuming that customer records are stored in the "customers" table, and
that order records are stored in the "orders" table, the following trigger

ensures that all associated orders are redirected when a customer changes
his or her address:</p>

<blockquote><pre>
CREATE TRIGGER update_customer_address UPDATE OF address ON customers 
  BEGIN
    UPDATE orders SET address = new.address WHERE customer_name = old.name;







|















|


|
>







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
  that compile-time option only applies to top-level <a href="lang_update.html">UPDATE</a> and <a href="lang_delete.html">DELETE</a>
  statements, not <a href="lang_update.html">UPDATE</a> and <a href="lang_delete.html">DELETE</a> statements within triggers.
  </p></li>
</ul>

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

<h3>INSTEAD OF 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>

<blockquote><pre>
CREATE TRIGGER update_customer_address UPDATE OF address ON customers 
  BEGIN
    UPDATE orders SET address = new.address WHERE customer_name = old.name;
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

<p>causes the following to be automatically executed:</p>

<blockquote><pre>
UPDATE orders SET address = '1 Main St.' WHERE customer_name = 'Jack Jones';
</pre></blockquote>






























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

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

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

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

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



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

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

<p><b><a href="syntaxdiagrams.html#raise-function">raise-function:</a></b></p><blockquote>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif"></img>
 </blockquote>


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

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







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
















>
>















|







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

<p>causes the following to be automatically executed:</p>

<blockquote><pre>
UPDATE orders SET address = '1 Main St.' WHERE customer_name = 'Jack Jones';
</pre></blockquote>

<p>For an example of an INSTEAD OF trigger, consider the following schema:

<blockquote><pre>
CREATE TABLE customer(
  cust_id INTEGER PRIMARY KEY,
  cust_name TEXT,
  cust_addr TEXT
);
CREATE VIEW customer_address AS
   SELECT cust_id, cust_addr FROM customer;
CREATE TRIGGER cust_addr_chng
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="syntaxdiagrams.html#raise-function">raise-function:</a></b></p><blockquote>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif"></img>
 </blockquote>


<p>When one of RAISE(ROLLBACK,...), RAISE(ABORT,...) or RAISE(FAIL,...)
is called during trigger-program
execution, the specified <a href="lang_conflict.html">ON CONFLICT</a> processing is performed
the current query terminates.
An error code of <a href="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
Changes to Doc/Extra/Core/lang_createview.html.
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
    </form>
    </div>
  </table>

<div class=startsearch></div>
  
<h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>CREATE VIEW</h2><p><b><a href="syntaxdiagrams.html#create-view-stmt">create-view-stmt:</a></b>
<button id='x959' onclick='hideorshow("x959","x960")'>hide</button></p>
 <blockquote id='x960'>
 <img alt="syntax diagram create-view-stmt" src="images/syntax/create-view-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#select-stmt">select-stmt:</a></b>
<button id='x961' onclick='hideorshow("x961","x962")'>show</button></p>
 <blockquote id='x962' style='display:none;'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#common-table-expression">common-table-expression:</a></b>
<button id='x963' onclick='hideorshow("x963","x964")'>show</button></p>
 <blockquote id='x964' style='display:none;'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#compound-operator">compound-operator:</a></b>
<button id='x965' onclick='hideorshow("x965","x966")'>show</button></p>
 <blockquote id='x966' style='display:none;'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#expr">expr:</a></b>
<button id='x967' onclick='hideorshow("x967","x968")'>show</button></p>
 <blockquote id='x968' style='display:none;'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntaxdiagrams.html#literal-value">literal-value:</a></b>
<button id='x969' onclick='hideorshow("x969","x970")'>show</button></p>
 <blockquote id='x970' style='display:none;'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#raise-function">raise-function:</a></b>
<button id='x971' onclick='hideorshow("x971","x972")'>show</button></p>
 <blockquote id='x972' style='display:none;'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#type-name">type-name:</a></b>
<button id='x973' onclick='hideorshow("x973","x974")'>show</button></p>
 <blockquote id='x974' style='display:none;'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntaxdiagrams.html#signed-number">signed-number:</a></b>
<button id='x975' onclick='hideorshow("x975","x976")'>show</button></p>
 <blockquote id='x976' style='display:none;'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</blockquote>
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-clause">join-clause:</a></b>
<button id='x977' onclick='hideorshow("x977","x978")'>show</button></p>
 <blockquote id='x978' style='display:none;'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntaxdiagrams.html#join-constraint">join-constraint:</a></b>
<button id='x979' onclick='hideorshow("x979","x980")'>show</button></p>
 <blockquote id='x980' style='display:none;'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-operator">join-operator:</a></b>
<button id='x981' onclick='hideorshow("x981","x982")'>show</button></p>
 <blockquote id='x982' style='display:none;'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#ordering-term">ordering-term:</a></b>
<button id='x983' onclick='hideorshow("x983","x984")'>show</button></p>
 <blockquote id='x984' style='display:none;'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#result-column">result-column:</a></b>
<button id='x985' onclick='hideorshow("x985","x986")'>show</button></p>
 <blockquote id='x986' style='display:none;'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#table-or-subquery">table-or-subquery:</a></b>
<button id='x987' onclick='hideorshow("x987","x988")'>show</button></p>
 <blockquote id='x988' style='display:none;'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</blockquote>
</blockquote>
</blockquote>


<p>The CREATE VIEW command assigns a name to a pre-packaged 







|
|


|
|


|
|



|
|



|
|


|
|



|
|



|
|


|
|





|
|


|
|



|
|




|
|



|
|



|
|







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
    </form>
    </div>
  </table>

<div class=startsearch></div>
  
<h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>CREATE VIEW</h2><p><b><a href="syntaxdiagrams.html#create-view-stmt">create-view-stmt:</a></b>
<button id='x975' onclick='hideorshow("x975","x976")'>hide</button></p>
 <blockquote id='x976'>
 <img alt="syntax diagram create-view-stmt" src="images/syntax/create-view-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#select-stmt">select-stmt:</a></b>
<button id='x977' onclick='hideorshow("x977","x978")'>show</button></p>
 <blockquote id='x978' style='display:none;'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#common-table-expression">common-table-expression:</a></b>
<button id='x979' onclick='hideorshow("x979","x980")'>show</button></p>
 <blockquote id='x980' style='display:none;'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#compound-operator">compound-operator:</a></b>
<button id='x981' onclick='hideorshow("x981","x982")'>show</button></p>
 <blockquote id='x982' style='display:none;'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#expr">expr:</a></b>
<button id='x983' onclick='hideorshow("x983","x984")'>show</button></p>
 <blockquote id='x984' style='display:none;'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntaxdiagrams.html#literal-value">literal-value:</a></b>
<button id='x985' onclick='hideorshow("x985","x986")'>show</button></p>
 <blockquote id='x986' style='display:none;'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#raise-function">raise-function:</a></b>
<button id='x987' onclick='hideorshow("x987","x988")'>show</button></p>
 <blockquote id='x988' style='display:none;'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#type-name">type-name:</a></b>
<button id='x989' onclick='hideorshow("x989","x990")'>show</button></p>
 <blockquote id='x990' style='display:none;'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntaxdiagrams.html#signed-number">signed-number:</a></b>
<button id='x991' onclick='hideorshow("x991","x992")'>show</button></p>
 <blockquote id='x992' style='display:none;'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</blockquote>
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-clause">join-clause:</a></b>
<button id='x993' onclick='hideorshow("x993","x994")'>show</button></p>
 <blockquote id='x994' style='display:none;'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntaxdiagrams.html#join-constraint">join-constraint:</a></b>
<button id='x995' onclick='hideorshow("x995","x996")'>show</button></p>
 <blockquote id='x996' style='display:none;'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-operator">join-operator:</a></b>
<button id='x997' onclick='hideorshow("x997","x998")'>show</button></p>
 <blockquote id='x998' style='display:none;'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#ordering-term">ordering-term:</a></b>
<button id='x999' onclick='hideorshow("x999","x1000")'>show</button></p>
 <blockquote id='x1000' style='display:none;'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#result-column">result-column:</a></b>
<button id='x1001' onclick='hideorshow("x1001","x1002")'>show</button></p>
 <blockquote id='x1002' style='display:none;'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#table-or-subquery">table-or-subquery:</a></b>
<button id='x1003' onclick='hideorshow("x1003","x1004")'>show</button></p>
 <blockquote id='x1004' style='display:none;'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</blockquote>
</blockquote>
</blockquote>


<p>The CREATE VIEW command assigns a name to a pre-packaged 
Changes to Doc/Extra/Core/lang_createvtab.html.
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
    </form>
    </div>
  </table>

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


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







|
|







125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
    </form>
    </div>
  </table>

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


<p>A <a href="vtab.html">virtual table</a> is an interface to an external storage or computation
engine that appears to be a table but does not actually store information
in the database file.</p>
Changes to Doc/Extra/Core/lang_datefunc.html.
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
subtracted from the indicated date and time in order to compute zulu time.
For example, all of the following time strings are equivalent:
</p>

<blockquote>
2013-10-07 08:23:19.120<br>
2013-10-07T08:23:19.120Z<br>
2013-10-07 08:23:19.120-04:00<br>
2456572.84952685
</blockquote>

<p>
In formats 4, 7, and 10, the fractional seconds value SS.SSS can have
one or more digits following the decimal point.  Exactly three digits are
shown in the examples because only the first three digits are significant







|







250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
subtracted from the indicated date and time in order to compute zulu time.
For example, all of the following time strings are equivalent:
</p>

<blockquote>
2013-10-07 08:23:19.120<br>
2013-10-07T08:23:19.120Z<br>
2013-10-07 04:23:19.120-04:00<br>
2456572.84952685
</blockquote>

<p>
In formats 4, 7, and 10, the fractional seconds value SS.SSS can have
one or more digits following the decimal point.  Exactly three digits are
shown in the examples because only the first three digits are significant
Changes to Doc/Extra/Core/lang_delete.html.
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
    </form>
    </div>
  </table>

<div class=startsearch></div>
  
<h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>DELETE</h2><p><b><a href="syntaxdiagrams.html#delete-stmt">delete-stmt:</a></b>
<button id='x991' onclick='hideorshow("x991","x992")'>hide</button></p>
 <blockquote id='x992'>
 <img alt="syntax diagram delete-stmt" src="images/syntax/delete-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#expr">expr:</a></b>
<button id='x993' onclick='hideorshow("x993","x994")'>show</button></p>
 <blockquote id='x994' style='display:none;'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntaxdiagrams.html#literal-value">literal-value:</a></b>
<button id='x995' onclick='hideorshow("x995","x996")'>show</button></p>
 <blockquote id='x996' style='display:none;'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#raise-function">raise-function:</a></b>
<button id='x997' onclick='hideorshow("x997","x998")'>show</button></p>
 <blockquote id='x998' style='display:none;'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#select-stmt">select-stmt:</a></b>
<button id='x999' onclick='hideorshow("x999","x1000")'>show</button></p>
 <blockquote id='x1000' style='display:none;'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#common-table-expression">common-table-expression:</a></b>
<button id='x1001' onclick='hideorshow("x1001","x1002")'>show</button></p>
 <blockquote id='x1002' style='display:none;'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#compound-operator">compound-operator:</a></b>
<button id='x1003' onclick='hideorshow("x1003","x1004")'>show</button></p>
 <blockquote id='x1004' style='display:none;'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-clause">join-clause:</a></b>
<button id='x1005' onclick='hideorshow("x1005","x1006")'>show</button></p>
 <blockquote id='x1006' style='display:none;'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntaxdiagrams.html#join-constraint">join-constraint:</a></b>
<button id='x1007' onclick='hideorshow("x1007","x1008")'>show</button></p>
 <blockquote id='x1008' style='display:none;'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-operator">join-operator:</a></b>
<button id='x1009' onclick='hideorshow("x1009","x1010")'>show</button></p>
 <blockquote id='x1010' style='display:none;'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#ordering-term">ordering-term:</a></b>
<button id='x1011' onclick='hideorshow("x1011","x1012")'>show</button></p>
 <blockquote id='x1012' style='display:none;'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#result-column">result-column:</a></b>
<button id='x1013' onclick='hideorshow("x1013","x1014")'>show</button></p>
 <blockquote id='x1014' style='display:none;'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#table-or-subquery">table-or-subquery:</a></b>
<button id='x1015' onclick='hideorshow("x1015","x1016")'>show</button></p>
 <blockquote id='x1016' style='display:none;'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#type-name">type-name:</a></b>
<button id='x1017' onclick='hideorshow("x1017","x1018")'>show</button></p>
 <blockquote id='x1018' style='display:none;'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntaxdiagrams.html#signed-number">signed-number:</a></b>
<button id='x1019' onclick='hideorshow("x1019","x1020")'>show</button></p>
 <blockquote id='x1020' style='display:none;'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</blockquote>
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#qualified-table-name">qualified-table-name:</a></b>
<button id='x1021' onclick='hideorshow("x1021","x1022")'>show</button></p>
 <blockquote id='x1022' style='display:none;'>
 <img alt="syntax diagram qualified-table-name" src="images/syntax/qualified-table-name.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#with-clause">with-clause:</a></b>
<button id='x1023' onclick='hideorshow("x1023","x1024")'>show</button></p>
 <blockquote id='x1024' style='display:none;'>
 <img alt="syntax diagram with-clause" src="images/syntax/with-clause.gif" />
<p><b><a href="syntaxdiagrams.html#cte-table-name">cte-table-name:</a></b>
<button id='x1025' onclick='hideorshow("x1025","x1026")'>show</button></p>
 <blockquote id='x1026' style='display:none;'>
 <img alt="syntax diagram cte-table-name" src="images/syntax/cte-table-name.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#select-stmt">select-stmt:</a></b>
<button id='x1027' onclick='hideorshow("x1027","x1028")'>show</button></p>
 <blockquote id='x1028' style='display:none;'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#common-table-expression">common-table-expression:</a></b>
<button id='x1029' onclick='hideorshow("x1029","x1030")'>show</button></p>
 <blockquote id='x1030' style='display:none;'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#compound-operator">compound-operator:</a></b>
<button id='x1031' onclick='hideorshow("x1031","x1032")'>show</button></p>
 <blockquote id='x1032' style='display:none;'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-clause">join-clause:</a></b>
<button id='x1033' onclick='hideorshow("x1033","x1034")'>show</button></p>
 <blockquote id='x1034' style='display:none;'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntaxdiagrams.html#join-constraint">join-constraint:</a></b>
<button id='x1035' onclick='hideorshow("x1035","x1036")'>show</button></p>
 <blockquote id='x1036' style='display:none;'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-operator">join-operator:</a></b>
<button id='x1037' onclick='hideorshow("x1037","x1038")'>show</button></p>
 <blockquote id='x1038' style='display:none;'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#ordering-term">ordering-term:</a></b>
<button id='x1039' onclick='hideorshow("x1039","x1040")'>show</button></p>
 <blockquote id='x1040' style='display:none;'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#result-column">result-column:</a></b>
<button id='x1041' onclick='hideorshow("x1041","x1042")'>show</button></p>
 <blockquote id='x1042' style='display:none;'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#table-or-subquery">table-or-subquery:</a></b>
<button id='x1043' onclick='hideorshow("x1043","x1044")'>show</button></p>
 <blockquote id='x1044' style='display:none;'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</blockquote>
</blockquote>
</blockquote>
</blockquote>









|
|


|
|


|
|



|
|



|
|


|
|



|
|



|
|


|
|



|
|




|
|



|
|



|
|




|
|


|
|





|
|



|
|


|
|



|
|


|
|



|
|



|
|


|
|



|
|




|
|



|
|



|
|







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
    </form>
    </div>
  </table>

<div class=startsearch></div>
  
<h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>DELETE</h2><p><b><a href="syntaxdiagrams.html#delete-stmt">delete-stmt:</a></b>
<button id='x1007' onclick='hideorshow("x1007","x1008")'>hide</button></p>
 <blockquote id='x1008'>
 <img alt="syntax diagram delete-stmt" src="images/syntax/delete-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#expr">expr:</a></b>
<button id='x1009' onclick='hideorshow("x1009","x1010")'>show</button></p>
 <blockquote id='x1010' style='display:none;'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntaxdiagrams.html#literal-value">literal-value:</a></b>
<button id='x1011' onclick='hideorshow("x1011","x1012")'>show</button></p>
 <blockquote id='x1012' style='display:none;'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#raise-function">raise-function:</a></b>
<button id='x1013' onclick='hideorshow("x1013","x1014")'>show</button></p>
 <blockquote id='x1014' style='display:none;'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#select-stmt">select-stmt:</a></b>
<button id='x1015' onclick='hideorshow("x1015","x1016")'>show</button></p>
 <blockquote id='x1016' style='display:none;'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#common-table-expression">common-table-expression:</a></b>
<button id='x1017' onclick='hideorshow("x1017","x1018")'>show</button></p>
 <blockquote id='x1018' style='display:none;'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#compound-operator">compound-operator:</a></b>
<button id='x1019' onclick='hideorshow("x1019","x1020")'>show</button></p>
 <blockquote id='x1020' style='display:none;'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-clause">join-clause:</a></b>
<button id='x1021' onclick='hideorshow("x1021","x1022")'>show</button></p>
 <blockquote id='x1022' style='display:none;'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntaxdiagrams.html#join-constraint">join-constraint:</a></b>
<button id='x1023' onclick='hideorshow("x1023","x1024")'>show</button></p>
 <blockquote id='x1024' style='display:none;'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-operator">join-operator:</a></b>
<button id='x1025' onclick='hideorshow("x1025","x1026")'>show</button></p>
 <blockquote id='x1026' style='display:none;'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#ordering-term">ordering-term:</a></b>
<button id='x1027' onclick='hideorshow("x1027","x1028")'>show</button></p>
 <blockquote id='x1028' style='display:none;'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#result-column">result-column:</a></b>
<button id='x1029' onclick='hideorshow("x1029","x1030")'>show</button></p>
 <blockquote id='x1030' style='display:none;'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#table-or-subquery">table-or-subquery:</a></b>
<button id='x1031' onclick='hideorshow("x1031","x1032")'>show</button></p>
 <blockquote id='x1032' style='display:none;'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#type-name">type-name:</a></b>
<button id='x1033' onclick='hideorshow("x1033","x1034")'>show</button></p>
 <blockquote id='x1034' style='display:none;'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntaxdiagrams.html#signed-number">signed-number:</a></b>
<button id='x1035' onclick='hideorshow("x1035","x1036")'>show</button></p>
 <blockquote id='x1036' style='display:none;'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</blockquote>
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#qualified-table-name">qualified-table-name:</a></b>
<button id='x1037' onclick='hideorshow("x1037","x1038")'>show</button></p>
 <blockquote id='x1038' style='display:none;'>
 <img alt="syntax diagram qualified-table-name" src="images/syntax/qualified-table-name.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#with-clause">with-clause:</a></b>
<button id='x1039' onclick='hideorshow("x1039","x1040")'>show</button></p>
 <blockquote id='x1040' style='display:none;'>
 <img alt="syntax diagram with-clause" src="images/syntax/with-clause.gif" />
<p><b><a href="syntaxdiagrams.html#cte-table-name">cte-table-name:</a></b>
<button id='x1041' onclick='hideorshow("x1041","x1042")'>show</button></p>
 <blockquote id='x1042' style='display:none;'>
 <img alt="syntax diagram cte-table-name" src="images/syntax/cte-table-name.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#select-stmt">select-stmt:</a></b>
<button id='x1043' onclick='hideorshow("x1043","x1044")'>show</button></p>
 <blockquote id='x1044' style='display:none;'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#common-table-expression">common-table-expression:</a></b>
<button id='x1045' onclick='hideorshow("x1045","x1046")'>show</button></p>
 <blockquote id='x1046' style='display:none;'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#compound-operator">compound-operator:</a></b>
<button id='x1047' onclick='hideorshow("x1047","x1048")'>show</button></p>
 <blockquote id='x1048' style='display:none;'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-clause">join-clause:</a></b>
<button id='x1049' onclick='hideorshow("x1049","x1050")'>show</button></p>
 <blockquote id='x1050' style='display:none;'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntaxdiagrams.html#join-constraint">join-constraint:</a></b>
<button id='x1051' onclick='hideorshow("x1051","x1052")'>show</button></p>
 <blockquote id='x1052' style='display:none;'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-operator">join-operator:</a></b>
<button id='x1053' onclick='hideorshow("x1053","x1054")'>show</button></p>
 <blockquote id='x1054' style='display:none;'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#ordering-term">ordering-term:</a></b>
<button id='x1055' onclick='hideorshow("x1055","x1056")'>show</button></p>
 <blockquote id='x1056' style='display:none;'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#result-column">result-column:</a></b>
<button id='x1057' onclick='hideorshow("x1057","x1058")'>show</button></p>
 <blockquote id='x1058' style='display:none;'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#table-or-subquery">table-or-subquery:</a></b>
<button id='x1059' onclick='hideorshow("x1059","x1060")'>show</button></p>
 <blockquote id='x1060' style='display:none;'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</blockquote>
</blockquote>
</blockquote>
</blockquote>


Changes to Doc/Extra/Core/lang_detach.html.
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
    </form>
    </div>
  </table>

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


<p>This statement detaches an additional database connection previously 
attached using the <a href="lang_attach.html">ATTACH</a> statement.  
When not in <a href="sharedcache.html">shared cache mode</a>, 







|
|







125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
    </form>
    </div>
  </table>

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


<p>This statement detaches an additional database connection previously 
attached using the <a href="lang_attach.html">ATTACH</a> statement.  
When not in <a href="sharedcache.html">shared cache mode</a>, 
Changes to Doc/Extra/Core/lang_dropindex.html.
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
    </form>
    </div>
  </table>

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


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







|
|







125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
    </form>
    </div>
  </table>

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


<p>The DROP INDEX statement removes an index added
with the <a href="lang_createindex.html">CREATE INDEX</a> statement.  The index is completely removed from
the disk.  The only way to recover the index is to reenter the
Changes to Doc/Extra/Core/lang_droptable.html.
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
    </form>
    </div>
  </table>

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


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







|
|







125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
    </form>
    </div>
  </table>

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


<p>The DROP TABLE statement removes a table added with the
<a href="lang_createtable.html">CREATE TABLE</a> statement.  The name specified is the
table name.  The dropped table is completely removed from the database 
Changes to Doc/Extra/Core/lang_droptrigger.html.
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
    </form>
    </div>
  </table>

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


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







|
|







125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
    </form>
    </div>
  </table>

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


<p>The DROP TRIGGER statement removes a trigger created by the 
<a href="lang_createtrigger.html">CREATE TRIGGER</a> statement. Once removed, the trigger definition is no
longer present in the sqlite_master (or sqlite_temp_master) table and is
Changes to Doc/Extra/Core/lang_dropview.html.
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
    </form>
    </div>
  </table>

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


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







|
|







125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
    </form>
    </div>
  </table>

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


<p>The DROP VIEW statement removes a view created by the <a href="lang_createview.html">CREATE VIEW</a> 
  statement. The view definition is removed from the database schema, but 
  no actual data in the underlying base tables is modified.
Changes to Doc/Extra/Core/lang_expr.html.
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
    </form>
    </div>
  </table>

<div class=startsearch></div>
  
<h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>expression</h2><p><b><a href="syntaxdiagrams.html#expr">expr:</a></b>
<button id='x1055' onclick='hideorshow("x1055","x1056")'>hide</button></p>
 <blockquote id='x1056'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntaxdiagrams.html#literal-value">literal-value:</a></b>
<button id='x1057' onclick='hideorshow("x1057","x1058")'>show</button></p>
 <blockquote id='x1058' style='display:none;'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#raise-function">raise-function:</a></b>
<button id='x1059' onclick='hideorshow("x1059","x1060")'>show</button></p>
 <blockquote id='x1060' style='display:none;'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#select-stmt">select-stmt:</a></b>
<button id='x1061' onclick='hideorshow("x1061","x1062")'>show</button></p>
 <blockquote id='x1062' style='display:none;'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#common-table-expression">common-table-expression:</a></b>
<button id='x1063' onclick='hideorshow("x1063","x1064")'>show</button></p>
 <blockquote id='x1064' style='display:none;'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#compound-operator">compound-operator:</a></b>
<button id='x1065' onclick='hideorshow("x1065","x1066")'>show</button></p>
 <blockquote id='x1066' style='display:none;'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-clause">join-clause:</a></b>
<button id='x1067' onclick='hideorshow("x1067","x1068")'>show</button></p>
 <blockquote id='x1068' style='display:none;'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntaxdiagrams.html#join-constraint">join-constraint:</a></b>
<button id='x1069' onclick='hideorshow("x1069","x1070")'>show</button></p>
 <blockquote id='x1070' style='display:none;'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-operator">join-operator:</a></b>
<button id='x1071' onclick='hideorshow("x1071","x1072")'>show</button></p>
 <blockquote id='x1072' style='display:none;'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#ordering-term">ordering-term:</a></b>
<button id='x1073' onclick='hideorshow("x1073","x1074")'>show</button></p>
 <blockquote id='x1074' style='display:none;'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#result-column">result-column:</a></b>
<button id='x1075' onclick='hideorshow("x1075","x1076")'>show</button></p>
 <blockquote id='x1076' style='display:none;'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#table-or-subquery">table-or-subquery:</a></b>
<button id='x1077' onclick='hideorshow("x1077","x1078")'>show</button></p>
 <blockquote id='x1078' style='display:none;'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#type-name">type-name:</a></b>
<button id='x1079' onclick='hideorshow("x1079","x1080")'>show</button></p>
 <blockquote id='x1080' style='display:none;'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntaxdiagrams.html#signed-number">signed-number:</a></b>
<button id='x1081' onclick='hideorshow("x1081","x1082")'>show</button></p>
 <blockquote id='x1082' style='display:none;'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</blockquote>
</blockquote>
</blockquote>


<p>This section is different from the others.  Most other sections of







|
|


|
|



|
|



|
|


|
|



|
|



|
|


|
|



|
|




|
|



|
|



|
|




|
|


|
|







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
    </form>
    </div>
  </table>

<div class=startsearch></div>
  
<h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>expression</h2><p><b><a href="syntaxdiagrams.html#expr">expr:</a></b>
<button id='x1071' onclick='hideorshow("x1071","x1072")'>hide</button></p>
 <blockquote id='x1072'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntaxdiagrams.html#literal-value">literal-value:</a></b>
<button id='x1073' onclick='hideorshow("x1073","x1074")'>show</button></p>
 <blockquote id='x1074' style='display:none;'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#raise-function">raise-function:</a></b>
<button id='x1075' onclick='hideorshow("x1075","x1076")'>show</button></p>
 <blockquote id='x1076' style='display:none;'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#select-stmt">select-stmt:</a></b>
<button id='x1077' onclick='hideorshow("x1077","x1078")'>show</button></p>
 <blockquote id='x1078' style='display:none;'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#common-table-expression">common-table-expression:</a></b>
<button id='x1079' onclick='hideorshow("x1079","x1080")'>show</button></p>
 <blockquote id='x1080' style='display:none;'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#compound-operator">compound-operator:</a></b>
<button id='x1081' onclick='hideorshow("x1081","x1082")'>show</button></p>
 <blockquote id='x1082' style='display:none;'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-clause">join-clause:</a></b>
<button id='x1083' onclick='hideorshow("x1083","x1084")'>show</button></p>
 <blockquote id='x1084' style='display:none;'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntaxdiagrams.html#join-constraint">join-constraint:</a></b>
<button id='x1085' onclick='hideorshow("x1085","x1086")'>show</button></p>
 <blockquote id='x1086' style='display:none;'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-operator">join-operator:</a></b>
<button id='x1087' onclick='hideorshow("x1087","x1088")'>show</button></p>
 <blockquote id='x1088' style='display:none;'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#ordering-term">ordering-term:</a></b>
<button id='x1089' onclick='hideorshow("x1089","x1090")'>show</button></p>
 <blockquote id='x1090' style='display:none;'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#result-column">result-column:</a></b>
<button id='x1091' onclick='hideorshow("x1091","x1092")'>show</button></p>
 <blockquote id='x1092' style='display:none;'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#table-or-subquery">table-or-subquery:</a></b>
<button id='x1093' onclick='hideorshow("x1093","x1094")'>show</button></p>
 <blockquote id='x1094' style='display:none;'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#type-name">type-name:</a></b>
<button id='x1095' onclick='hideorshow("x1095","x1096")'>show</button></p>
 <blockquote id='x1096' style='display:none;'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntaxdiagrams.html#signed-number">signed-number:</a></b>
<button id='x1097' onclick='hideorshow("x1097","x1098")'>show</button></p>
 <blockquote id='x1098' style='display:none;'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</blockquote>
</blockquote>
</blockquote>


<p>This section is different from the others.  Most other sections of
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
IS operator evaluates to 1 (true) and the IS NOT operator evaluates
to 0 (false). If one operand is NULL and the other is not, then the
IS operator evaluates to 0 (false) and the IS NOT operator is 1 (true).
It is not possible for an IS or IS NOT expression to evaluate to NULL.
Operators <font color="#2c2cf0"><big>IS</big></font> and <font color="#2c2cf0"><big>IS NOT</big></font> have the same 
precedence as <font color="#2c2cf0"><big>=</big></font>.<a name="litvalue"></a>

<h3>Literal Values</h3>
<p>
A literal value is a constant of some kind.
Literal values may be integers, floating point numbers, strings,
BLOBs, or NULLs.</p>

<p>The syntax for integer and floating point literals (collectively
"numeric literals") is shown by the following diagram:</p>

<p><b><a href="syntaxdiagrams.html#numeric-literal">numeric-literal:</a></b></p><blockquote>
 <img alt="syntax diagram numeric-literal" src="images/syntax/numeric-literal.gif"></img>
 </blockquote>


<p>
If a numeric literal has a decimal point or an exponentiation

clause, then it is a floating point literal.  Otherwise is it is an 

integer literal.  The "E" character that begins the exponentiation
clause of a floating point literal can be either upper or lower case.
The "." character is always used 
as the decimal point even if the locale setting specifies "," for
this role - the use of "," for the decimal point would result in
syntactic ambiguity.</p>



























<p> A string constant is formed by enclosing the
string in single quotes (').  A single quote within the string can
be encoded by putting two single quotes in a row - as in Pascal.
C-style escapes using the backslash character are not supported because
they are not standard SQL.

BLOB literals are string literals containing hexadecimal data and
preceded by a single "x" or "X" character.  For example:</p>

<blockquote><pre>
X'53514C697465'
</pre></blockquote>

<p>
A literal value can also be the token "NULL".
</p>

<a name="varparam"></a>








|

|

|
|
|









>
|
>
|




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






>
|
|
<
<
<
<







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
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="syntaxdiagrams.html#numeric-literal">numeric-literal:</a></b></p><blockquote>
 <img alt="syntax diagram numeric-literal" src="images/syntax/numeric-literal.gif"></img>
 </blockquote>


<p>
If a numeric literal has a decimal point or an exponentiation
clause or if its magnitude is less than -9223372036854775808 or
greater than 9223372036854775807, then it is a floating point literal.
Otherwise is it is an  integer literal.
The "E" character that begins the exponentiation
clause of a floating point literal can be either upper or lower case.
The "." character is always used 
as the decimal point even if the locale setting specifies "," for
this role - the use of "," for the decimal point would result in
syntactic ambiguity.

<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 version 3.8.6.
For backwards compatibility, the "0x" hexadecimal integer
notation is only understood by the SQL language parser, not by the
type conversions routines.
String variables that
contain text formatted like hexadecimal integers are not
interpreted as hexadecimal integers when coercing the string value
into an integer due to a <a href="lang_expr.html#castexpr">CAST expression</a> or for a <a href="datatype3.html#affinity">column affinity</a>
transformation or prior to performing a numeric operation or for
any other run-time conversions.  When coercing a
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>

332
333
334
335
336
337
338




339
340
341
342
343
344
345
</tr>
<tr>
<td align="right" valign="top"><b>?</b></td><td width="20"></td>
<td>A question mark that is not followed by a number creates a parameter
with a number one greater than the largest parameter number already assigned.
If this means the parameter number is greater than
<a href="limits.html#max_variable_number">SQLITE_MAX_VARIABLE_NUMBER</a>, it is an error.




</td>
</tr>
<tr>
<td align="right" valign="top"><b>:</b><i>AAAA</i></td><td width="20"></td>
<td>A colon followed by an identifier name holds a spot for a 
<a href="c3ref/bind_parameter_name.html">named parameter</a> with the name :AAAA.  
Named parameters are also numbered. The number assigned is one greater than







>
>
>
>







357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
</tr>
<tr>
<td align="right" valign="top"><b>?</b></td><td width="20"></td>
<td>A question mark that is not followed by a number creates a parameter
with a number one greater than the largest parameter number already assigned.
If this means the parameter number is greater than
<a href="limits.html#max_variable_number">SQLITE_MAX_VARIABLE_NUMBER</a>, it is an error.
This parameter format is provided for compatibility with other database
engines.  But because it is easy to miscount the question marks, the
use of this parameter format is discouraged.  Programmers are encouraged
to use one of the symbolic formats below or the ?NNN format above instead.
</td>
</tr>
<tr>
<td align="right" valign="top"><b>:</b><i>AAAA</i></td><td width="20"></td>
<td>A colon followed by an identifier name holds a spot for a 
<a href="c3ref/bind_parameter_name.html">named parameter</a> with the name :AAAA.  
Named parameters are also numbered. The number assigned is one greater than
364
365
366
367
368
369
370
371

372
373
374
375
376
377
378
379
380
381
<a href="tclsqlite.html">Tcl extension</a> that has escaped into the wild.</td>
</tr>
</table>
</blockquote>

<p>Parameters that are not assigned values using
<a href="c3ref/bind_blob.html">sqlite3_bind()</a> are treated
as NULL.</p>


<p>The maximum parameter number is set at compile-time by
the <a href="limits.html#max_variable_number">SQLITE_MAX_VARIABLE_NUMBER</a> macro.  An individual <a href="c3ref/sqlite3.html">database connections</a>
D can reduce its maximum parameter number below the compile-time maximum
using the <a href="c3ref/limit.html">sqlite3_limit</a>(D, <a href="c3ref/c_limit_attached.html#sqlitelimitvariablenumber">SQLITE_LIMIT_VARIABLE_NUMBER</a>,...) interface.
</p>

<a name="like"></a>

<h3>The LIKE and GLOB operators</h3>







|
>


|







393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
<a href="tclsqlite.html">Tcl extension</a> that has escaped into the wild.</td>
</tr>
</table>
</blockquote>

<p>Parameters that are not assigned values using
<a href="c3ref/bind_blob.html">sqlite3_bind()</a> are treated
as NULL.  The <a href="c3ref/bind_parameter_index.html">sqlite3_bind_parameter_index()</a> interface can be used
to translate a symbolic parameter name into its equivalent numeric index.</p>

<p>The maximum parameter number is set at compile-time by
the <a href="limits.html#max_variable_number">SQLITE_MAX_VARIABLE_NUMBER</a> macro.  An individual <a href="c3ref/sqlite3.html">database 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 and GLOB operators</h3>
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
subqueries.

<h3>Table Column Names</h3>

<p>A column name can be any of the names defined in the <a href="lang_createtable.html">CREATE TABLE</a>
statement or one of the following special identifiers: "<b>ROWID</b>",
"<b>OID</b>", or "<b>_ROWID_</b>".
These special identifiers all describe the
unique integer key (the <a href="lang_createtable.html#rowid">rowid</a>) associated with every 
row of every table.
The special identifiers only refer to the row key if the <a href="lang_createtable.html">CREATE TABLE</a>
statement does not define a real column with the same name.
The rowid can be used anywhere a regular
column can be used.</p>

<p>A <a href="lang_select.html">SELECT</a> statement used as either a scalar subquery or as the 
right-hand operand of an IN, NOT IN or EXISTS expression may contain 







|

|







626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
subqueries.

<h3>Table Column Names</h3>

<p>A column name can be any of the names defined in the <a href="lang_createtable.html">CREATE TABLE</a>
statement or one of the following special identifiers: "<b>ROWID</b>",
"<b>OID</b>", or "<b>_ROWID_</b>".
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>

<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 
669
670
671
672
673
674
675
676



677
678
679
680
681
682
683
  <td> When casting a BLOB value to INTEGER, the value is first converted to
        TEXT.
       <p>When casting a TEXT value to INTEGER, the longest possible prefix of
        the value that can be interpreted as an integer number is extracted from
        the TEXT value and the remainder ignored. Any leading spaces in the
        TEXT value when converting from TEXT to INTEGER are ignored. If there
        is no prefix that can be interpreted as an integer number, the result
        of the conversion is 0.




      <p>A cast of a REAL value into an INTEGER results in the integer
      between the REAL value and zero that is closest to the REAL value.
      If a REAL is greater than the greatest possible signed
      integer (+9223372036854775807) then the result is the greatest possible
      signed integer and if the REAL is less than the least possible signed
      integer (-9223372036854775808) then the result is the least possible







|
>
>
>







699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
  <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.  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
722
723
724
725
726
727
728
729

730
731
732
733
734
735
736
737
738
739



740
741



742
743
744
745
    <li> the HAVING clause of a SELECT statement,
    <li> the WHEN clause of an SQL trigger, and
    <li> the WHEN clause or clauses of some CASE expressions.
  </ul>

<p>To convert the results of an SQL expression to a boolean value, SQLite
first casts the result to a NUMERIC value in the same way as a 
<a href="lang_expr.html#castexpr">CAST expression</a>. A NULL or zero value (integer value 0 or real value 0.0) is

considered to be false. All other values are considered true.

<p>For example, the values NULL, 0.0, 0, 'english' and '0' are all considered
to be false. Values 1, 1.0, 0.1, -0.1 and '1english' are considered to 
be true.

<h3>Functions</h3>
<p>Both <a href="lang_corefunc.html">simple</a> and <a href="lang_aggfunc.html">aggregate</a> functions are supported.
(For presentation purposes, simple functions are further subdivided into
<a href="lang_corefunc.html">core functions</a> and <a href="lang_datefunc.html">date-time functions</a>.)



A simple function can be used in any expression.  Simple functions return
a result immediately based on their inputs.  Aggregate functions



may only be used in a SELECT statement.  Aggregate functions compute
their result across all rows of the result set.</p>









|
>
|






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


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

<h3>Functions</h3>
<p>SQLite supports many <a href="lang_corefunc.html">simple</a> and <a href="lang_aggfunc.html">aggregate</a>
SQL functions.  For presentation purposes, simple functions are further
subdivided into <a href="lang_corefunc.html">core functions</a> and <a href="lang_datefunc.html">date-time functions</a>.
Applications can add new functions, written in C/C++, using the
<a href="c3ref/create_function.html">sqlite3_create_function()</a> interface.
</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.



Changes to Doc/Extra/Core/lang_indexedby.html.
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
particular named index on a <a href="lang_delete.html">DELETE</a>, <a href="lang_select.html">SELECT</a>, or <a href="lang_update.html">UPDATE</a> statement.
The INDEXED BY phrase is an extension that is particular to SQLite and
is not portable to other SQL database engines.
The INDEXED BY phrase can be seen in the following syntax
diagrams:</p>

<p><b><a href="syntaxdiagrams.html#qualified-table-name">qualified-table-name:</a></b>
<button id='x1417' onclick='hideorshow("x1417","x1418")'>hide</button></p>
 <blockquote id='x1418'>
 <img alt="syntax diagram qualified-table-name" src="images/syntax/qualified-table-name.gif" />
</blockquote>


<p>The "INDEXED BY index-name" phrase specifies that the named index
must be used in order to look up values on the preceding table.
If index-name does not exist or cannot be used for the query, then







|
|







133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
particular named index on a <a href="lang_delete.html">DELETE</a>, <a href="lang_select.html">SELECT</a>, or <a href="lang_update.html">UPDATE</a> statement.
The INDEXED BY phrase is an extension that is particular to SQLite and
is not portable to other SQL database engines.
The INDEXED BY phrase can be seen in the following syntax
diagrams:</p>

<p><b><a href="syntaxdiagrams.html#qualified-table-name">qualified-table-name:</a></b>
<button id='x1433' onclick='hideorshow("x1433","x1434")'>hide</button></p>
 <blockquote id='x1434'>
 <img alt="syntax diagram qualified-table-name" src="images/syntax/qualified-table-name.gif" />
</blockquote>


<p>The "INDEXED BY index-name" phrase specifies that the named index
must be used in order to look up values on the preceding table.
If index-name does not exist or cannot be used for the query, then
Changes to Doc/Extra/Core/lang_insert.html.
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
    </form>
    </div>
  </table>

<div class=startsearch></div>
  
<h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>INSERT</h2><p><b><a href="syntaxdiagrams.html#insert-stmt">insert-stmt:</a></b>
<button id='x1083' onclick='hideorshow("x1083","x1084")'>hide</button></p>
 <blockquote id='x1084'>
 <img alt="syntax diagram insert-stmt" src="images/syntax/insert-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#expr">expr:</a></b>
<button id='x1085' onclick='hideorshow("x1085","x1086")'>show</button></p>
 <blockquote id='x1086' style='display:none;'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntaxdiagrams.html#literal-value">literal-value:</a></b>
<button id='x1087' onclick='hideorshow("x1087","x1088")'>show</button></p>
 <blockquote id='x1088' style='display:none;'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#raise-function">raise-function:</a></b>
<button id='x1089' onclick='hideorshow("x1089","x1090")'>show</button></p>
 <blockquote id='x1090' style='display:none;'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#type-name">type-name:</a></b>
<button id='x1091' onclick='hideorshow("x1091","x1092")'>show</button></p>
 <blockquote id='x1092' style='display:none;'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntaxdiagrams.html#signed-number">signed-number:</a></b>
<button id='x1093' onclick='hideorshow("x1093","x1094")'>show</button></p>
 <blockquote id='x1094' style='display:none;'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</blockquote>
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#select-stmt">select-stmt:</a></b>
<button id='x1095' onclick='hideorshow("x1095","x1096")'>show</button></p>
 <blockquote id='x1096' style='display:none;'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#common-table-expression">common-table-expression:</a></b>
<button id='x1097' onclick='hideorshow("x1097","x1098")'>show</button></p>
 <blockquote id='x1098' style='display:none;'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#compound-operator">compound-operator:</a></b>
<button id='x1099' onclick='hideorshow("x1099","x1100")'>show</button></p>
 <blockquote id='x1100' style='display:none;'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-clause">join-clause:</a></b>
<button id='x1101' onclick='hideorshow("x1101","x1102")'>show</button></p>
 <blockquote id='x1102' style='display:none;'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntaxdiagrams.html#join-constraint">join-constraint:</a></b>
<button id='x1103' onclick='hideorshow("x1103","x1104")'>show</button></p>
 <blockquote id='x1104' style='display:none;'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-operator">join-operator:</a></b>
<button id='x1105' onclick='hideorshow("x1105","x1106")'>show</button></p>
 <blockquote id='x1106' style='display:none;'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#ordering-term">ordering-term:</a></b>
<button id='x1107' onclick='hideorshow("x1107","x1108")'>show</button></p>
 <blockquote id='x1108' style='display:none;'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#result-column">result-column:</a></b>
<button id='x1109' onclick='hideorshow("x1109","x1110")'>show</button></p>
 <blockquote id='x1110' style='display:none;'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#table-or-subquery">table-or-subquery:</a></b>
<button id='x1111' onclick='hideorshow("x1111","x1112")'>show</button></p>
 <blockquote id='x1112' style='display:none;'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#with-clause">with-clause:</a></b>
<button id='x1113' onclick='hideorshow("x1113","x1114")'>show</button></p>
 <blockquote id='x1114' style='display:none;'>
 <img alt="syntax diagram with-clause" src="images/syntax/with-clause.gif" />
<p><b><a href="syntaxdiagrams.html#cte-table-name">cte-table-name:</a></b>
<button id='x1115' onclick='hideorshow("x1115","x1116")'>show</button></p>
 <blockquote id='x1116' style='display:none;'>
 <img alt="syntax diagram cte-table-name" src="images/syntax/cte-table-name.gif" />
</blockquote>
</blockquote>
</blockquote>


<p>The INSERT statement comes in three basic forms.  
<ul>
<li><p>The first form (with the "VALUES" keyword) creates one or more
new rows in
an existing table. If no column-list is specified then the number
of values inserted into each row
must be the same as the number of columns in the table. In this case
the result of evaluating the left-most expression in each term of
the VALUES list is inserted into the left-most column of the each new row,
and forth for each subsequent expression. If a
column-list is specified, then the number of values in each term of the
VALUE list must match the number of
specified columns. Each of the named columns of the new row is populated
with the results of evaluating the corresponding VALUES expression. Table
columns that do not appear in the column list are populated with the default
column value (specified as part of the CREATE TABLE statement), or with NULL if
no default value is specified.







|
|


|
|


|
|



|
|



|
|


|
|





|
|


|
|



|
|



|
|


|
|



|
|




|
|



|
|



|
|




|
|


|
|













|
|
|







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
    </form>
    </div>
  </table>

<div class=startsearch></div>
  
<h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>INSERT</h2><p><b><a href="syntaxdiagrams.html#insert-stmt">insert-stmt:</a></b>
<button id='x1099' onclick='hideorshow("x1099","x1100")'>hide</button></p>
 <blockquote id='x1100'>
 <img alt="syntax diagram insert-stmt" src="images/syntax/insert-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#expr">expr:</a></b>
<button id='x1101' onclick='hideorshow("x1101","x1102")'>show</button></p>
 <blockquote id='x1102' style='display:none;'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntaxdiagrams.html#literal-value">literal-value:</a></b>
<button id='x1103' onclick='hideorshow("x1103","x1104")'>show</button></p>
 <blockquote id='x1104' style='display:none;'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#raise-function">raise-function:</a></b>
<button id='x1105' onclick='hideorshow("x1105","x1106")'>show</button></p>
 <blockquote id='x1106' style='display:none;'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#type-name">type-name:</a></b>
<button id='x1107' onclick='hideorshow("x1107","x1108")'>show</button></p>
 <blockquote id='x1108' style='display:none;'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntaxdiagrams.html#signed-number">signed-number:</a></b>
<button id='x1109' onclick='hideorshow("x1109","x1110")'>show</button></p>
 <blockquote id='x1110' style='display:none;'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</blockquote>
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#select-stmt">select-stmt:</a></b>
<button id='x1111' onclick='hideorshow("x1111","x1112")'>show</button></p>
 <blockquote id='x1112' style='display:none;'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#common-table-expression">common-table-expression:</a></b>
<button id='x1113' onclick='hideorshow("x1113","x1114")'>show</button></p>
 <blockquote id='x1114' style='display:none;'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#compound-operator">compound-operator:</a></b>
<button id='x1115' onclick='hideorshow("x1115","x1116")'>show</button></p>
 <blockquote id='x1116' style='display:none;'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-clause">join-clause:</a></b>
<button id='x1117' onclick='hideorshow("x1117","x1118")'>show</button></p>
 <blockquote id='x1118' style='display:none;'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntaxdiagrams.html#join-constraint">join-constraint:</a></b>
<button id='x1119' onclick='hideorshow("x1119","x1120")'>show</button></p>
 <blockquote id='x1120' style='display:none;'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-operator">join-operator:</a></b>
<button id='x1121' onclick='hideorshow("x1121","x1122")'>show</button></p>
 <blockquote id='x1122' style='display:none;'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#ordering-term">ordering-term:</a></b>
<button id='x1123' onclick='hideorshow("x1123","x1124")'>show</button></p>
 <blockquote id='x1124' style='display:none;'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#result-column">result-column:</a></b>
<button id='x1125' onclick='hideorshow("x1125","x1126")'>show</button></p>
 <blockquote id='x1126' style='display:none;'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#table-or-subquery">table-or-subquery:</a></b>
<button id='x1127' onclick='hideorshow("x1127","x1128")'>show</button></p>
 <blockquote id='x1128' style='display:none;'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#with-clause">with-clause:</a></b>
<button id='x1129' onclick='hideorshow("x1129","x1130")'>show</button></p>
 <blockquote id='x1130' style='display:none;'>
 <img alt="syntax diagram with-clause" src="images/syntax/with-clause.gif" />
<p><b><a href="syntaxdiagrams.html#cte-table-name">cte-table-name:</a></b>
<button id='x1131' onclick='hideorshow("x1131","x1132")'>show</button></p>
 <blockquote id='x1132' style='display:none;'>
 <img alt="syntax diagram cte-table-name" src="images/syntax/cte-table-name.gif" />
</blockquote>
</blockquote>
</blockquote>


<p>The INSERT statement comes in three basic forms.  
<ul>
<li><p>The first form (with the "VALUES" keyword) creates one or more
new rows in
an existing table. If no column-list is specified then the number
of values inserted into each row
must be the same as the number of columns in the table. In this case
the result of evaluating the left-most expression 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
column-list is specified, then the number of values in each term of the
VALUE list must match the number of
specified columns. Each of the named columns of the new row is populated
with the results of evaluating the corresponding VALUES expression. Table
columns that do not appear in the column list are populated with the default
column value (specified as part of the CREATE TABLE statement), or with NULL if
no default value is specified.
Changes to Doc/Extra/Core/lang_reindex.html.
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
    </form>
    </div>
  </table>

<div class=startsearch></div>
  
<h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>REINDEX</h2><p><b><a href="syntaxdiagrams.html#reindex-stmt">reindex-stmt:</a></b>
<button id='x1119' onclick='hideorshow("x1119","x1120")'>hide</button></p>
 <blockquote id='x1120'>
 <img alt="syntax diagram reindex-stmt" src="images/syntax/reindex-stmt.gif" />
</blockquote>


<p>The REINDEX command is used to delete and recreate indices from scratch.
This is useful when the definition of a collation sequence has changed.
</p>







|
|







125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
    </form>
    </div>
  </table>

<div class=startsearch></div>
  
<h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>REINDEX</h2><p><b><a href="syntaxdiagrams.html#reindex-stmt">reindex-stmt:</a></b>
<button id='x1135' onclick='hideorshow("x1135","x1136")'>hide</button></p>
 <blockquote id='x1136'>
 <img alt="syntax diagram reindex-stmt" src="images/syntax/reindex-stmt.gif" />
</blockquote>


<p>The REINDEX command is used to delete and recreate indices from scratch.
This is useful when the definition of a collation sequence has changed.
</p>
Changes to Doc/Extra/Core/lang_savepoint.html.
125
126
127
128
129
130
131
132
133
134
135










136
137
138
139
140
141
142
    </form>
    </div>
  </table>

<div class=startsearch></div>
  
<h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>SAVEPOINT</h2><p><b><a href="syntaxdiagrams.html#savepoint-stmt">savepoint-stmt:</a></b>
<button id='x803' onclick='hideorshow("x803","x804")'>hide</button></p>
 <blockquote id='x804'>
 <img alt="syntax diagram savepoint-stmt" src="images/syntax/savepoint-stmt.gif" />
</blockquote>












<p> SAVEPOINTs are a method of creating transactions, similar to
<a href="lang_transaction.html">BEGIN</a> and <a href="lang_transaction.html">COMMIT</a>, except that the SAVEPOINT and RELEASE commands
are named and may be nested.</p>

<p> The SAVEPOINT command starts a new transaction with a name.







|
|


>
>
>
>
>
>
>
>
>
>







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
    </form>
    </div>
  </table>

<div class=startsearch></div>
  
<h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>SAVEPOINT</h2><p><b><a href="syntaxdiagrams.html#savepoint-stmt">savepoint-stmt:</a></b>
<button id='x815' onclick='hideorshow("x815","x816")'>hide</button></p>
 <blockquote id='x816'>
 <img alt="syntax diagram savepoint-stmt" src="images/syntax/savepoint-stmt.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#release-stmt">release-stmt:</a></b>
<button id='x817' onclick='hideorshow("x817","x818")'>hide</button></p>
 <blockquote id='x818'>
 <img alt="syntax diagram release-stmt" src="images/syntax/release-stmt.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#rollback-stmt">rollback-stmt:</a></b>
<button id='x819' onclick='hideorshow("x819","x820")'>hide</button></p>
 <blockquote id='x820'>
 <img alt="syntax diagram rollback-stmt" src="images/syntax/rollback-stmt.gif" />
</blockquote>


<p> SAVEPOINTs are a method of creating transactions, similar to
<a href="lang_transaction.html">BEGIN</a> and <a href="lang_transaction.html">COMMIT</a>, except that the SAVEPOINT and RELEASE commands
are named and may be nested.</p>

<p> The SAVEPOINT command starts a new transaction with a name.
Changes to Doc/Extra/Core/lang_select.html.
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
    </form>
    </div>
  </table>

<div class=startsearch></div>
  
<h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>SELECT</h2><p><b><a href="syntaxdiagrams.html#select-stmt">select-stmt:</a></b>
<button id='x1157' onclick='hideorshow("x1157","x1158")'>hide</button></p>
 <blockquote id='x1158'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#common-table-expression">common-table-expression:</a></b>
<button id='x1159' onclick='hideorshow("x1159","x1160")'>show</button></p>
 <blockquote id='x1160' style='display:none;'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#compound-operator">compound-operator:</a></b>
<button id='x1161' onclick='hideorshow("x1161","x1162")'>show</button></p>
 <blockquote id='x1162' style='display:none;'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#expr">expr:</a></b>
<button id='x1163' onclick='hideorshow("x1163","x1164")'>show</button></p>
 <blockquote id='x1164' style='display:none;'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntaxdiagrams.html#literal-value">literal-value:</a></b>
<button id='x1165' onclick='hideorshow("x1165","x1166")'>show</button></p>
 <blockquote id='x1166' style='display:none;'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#raise-function">raise-function:</a></b>
<button id='x1167' onclick='hideorshow("x1167","x1168")'>show</button></p>
 <blockquote id='x1168' style='display:none;'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#type-name">type-name:</a></b>
<button id='x1169' onclick='hideorshow("x1169","x1170")'>show</button></p>
 <blockquote id='x1170' style='display:none;'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntaxdiagrams.html#signed-number">signed-number:</a></b>
<button id='x1171' onclick='hideorshow("x1171","x1172")'>show</button></p>
 <blockquote id='x1172' style='display:none;'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</blockquote>
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-clause">join-clause:</a></b>
<button id='x1173' onclick='hideorshow("x1173","x1174")'>show</button></p>
 <blockquote id='x1174' style='display:none;'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntaxdiagrams.html#join-constraint">join-constraint:</a></b>
<button id='x1175' onclick='hideorshow("x1175","x1176")'>show</button></p>
 <blockquote id='x1176' style='display:none;'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-operator">join-operator:</a></b>
<button id='x1177' onclick='hideorshow("x1177","x1178")'>show</button></p>
 <blockquote id='x1178' style='display:none;'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#ordering-term">ordering-term:</a></b>
<button id='x1179' onclick='hideorshow("x1179","x1180")'>show</button></p>
 <blockquote id='x1180' style='display:none;'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#result-column">result-column:</a></b>
<button id='x1181' onclick='hideorshow("x1181","x1182")'>show</button></p>
 <blockquote id='x1182' style='display:none;'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#table-or-subquery">table-or-subquery:</a></b>
<button id='x1183' onclick='hideorshow("x1183","x1184")'>show</button></p>
 <blockquote id='x1184' style='display:none;'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</blockquote>
</blockquote>



<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="syntaxdiagrams.html#select-stmt">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="syntaxdiagrams.html#factored-select-stmt">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="syntaxdiagrams.html#factored-select-stmt">factored-select-stmt:</a></b>
<button id='x1185' onclick='hideorshow("x1185","x1186")'>show</button></p>
 <blockquote id='x1186' style='display:none;'>
 <img alt="syntax diagram factored-select-stmt" src="images/syntax/factored-select-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#common-table-expression">common-table-expression:</a></b>
<button id='x1187' onclick='hideorshow("x1187","x1188")'>show</button></p>
 <blockquote id='x1188' style='display:none;'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
<p><b><a href="syntaxdiagrams.html#select-stmt">select-stmt:</a></b>
<button id='x1189' onclick='hideorshow("x1189","x1190")'>show</button></p>
 <blockquote id='x1190' style='display:none;'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#join-clause">join-clause:</a></b>
<button id='x1191' onclick='hideorshow("x1191","x1192")'>show</button></p>
 <blockquote id='x1192' style='display:none;'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntaxdiagrams.html#join-constraint">join-constraint:</a></b>
<button id='x1193' onclick='hideorshow("x1193","x1194")'>show</button></p>
 <blockquote id='x1194' style='display:none;'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-operator">join-operator:</a></b>
<button id='x1195' onclick='hideorshow("x1195","x1196")'>show</button></p>
 <blockquote id='x1196' style='display:none;'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#result-column">result-column:</a></b>
<button id='x1197' onclick='hideorshow("x1197","x1198")'>show</button></p>
 <blockquote id='x1198' style='display:none;'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#table-or-subquery">table-or-subquery:</a></b>
<button id='x1199' onclick='hideorshow("x1199","x1200")'>show</button></p>
 <blockquote id='x1200' style='display:none;'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</blockquote>
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#compound-operator">compound-operator:</a></b>
<button id='x1201' onclick='hideorshow("x1201","x1202")'>show</button></p>
 <blockquote id='x1202' style='display:none;'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#expr">expr:</a></b>
<button id='x1203' onclick='hideorshow("x1203","x1204")'>show</button></p>
 <blockquote id='x1204' style='display:none;'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntaxdiagrams.html#literal-value">literal-value:</a></b>
<button id='x1205' onclick='hideorshow("x1205","x1206")'>show</button></p>
 <blockquote id='x1206' style='display:none;'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#raise-function">raise-function:</a></b>
<button id='x1207' onclick='hideorshow("x1207","x1208")'>show</button></p>
 <blockquote id='x1208' style='display:none;'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#select-stmt">select-stmt:</a></b>
<button id='x1209' onclick='hideorshow("x1209","x1210")'>show</button></p>
 <blockquote id='x1210' style='display:none;'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#join-clause">join-clause:</a></b>
<button id='x1211' onclick='hideorshow("x1211","x1212")'>show</button></p>
 <blockquote id='x1212' style='display:none;'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntaxdiagrams.html#join-constraint">join-constraint:</a></b>
<button id='x1213' onclick='hideorshow("x1213","x1214")'>show</button></p>
 <blockquote id='x1214' style='display:none;'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-operator">join-operator:</a></b>
<button id='x1215' onclick='hideorshow("x1215","x1216")'>show</button></p>
 <blockquote id='x1216' style='display:none;'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#result-column">result-column:</a></b>
<button id='x1217' onclick='hideorshow("x1217","x1218")'>show</button></p>
 <blockquote id='x1218' style='display:none;'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#table-or-subquery">table-or-subquery:</a></b>
<button id='x1219' onclick='hideorshow("x1219","x1220")'>show</button></p>
 <blockquote id='x1220' style='display:none;'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#type-name">type-name:</a></b>
<button id='x1221' onclick='hideorshow("x1221","x1222")'>show</button></p>
 <blockquote id='x1222' style='display:none;'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntaxdiagrams.html#signed-number">signed-number:</a></b>
<button id='x1223' onclick='hideorshow("x1223","x1224")'>show</button></p>
 <blockquote id='x1224' style='display:none;'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</blockquote>
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#ordering-term">ordering-term:</a></b>
<button id='x1225' onclick='hideorshow("x1225","x1226")'>show</button></p>
 <blockquote id='x1226' style='display:none;'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#select-core">select-core:</a></b>
<button id='x1227' onclick='hideorshow("x1227","x1228")'>show</button></p>
 <blockquote id='x1228' style='display:none;'>
 <img alt="syntax diagram select-core" src="images/syntax/select-core.gif" />
<p><b><a href="syntaxdiagrams.html#join-clause">join-clause:</a></b>
<button id='x1229' onclick='hideorshow("x1229","x1230")'>show</button></p>
 <blockquote id='x1230' style='display:none;'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntaxdiagrams.html#join-constraint">join-constraint:</a></b>
<button id='x1231' onclick='hideorshow("x1231","x1232")'>show</button></p>
 <blockquote id='x1232' style='display:none;'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-operator">join-operator:</a></b>
<button id='x1233' onclick='hideorshow("x1233","x1234")'>show</button></p>
 <blockquote id='x1234' style='display:none;'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#result-column">result-column:</a></b>
<button id='x1235' onclick='hideorshow("x1235","x1236")'>show</button></p>
 <blockquote id='x1236' style='display:none;'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#table-or-subquery">table-or-subquery:</a></b>
<button id='x1237' onclick='hideorshow("x1237","x1238")'>show</button></p>
 <blockquote id='x1238' style='display:none;'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
<p><b><a href="syntaxdiagrams.html#select-stmt">select-stmt:</a></b>
<button id='x1239' onclick='hideorshow("x1239","x1240")'>show</button></p>
 <blockquote id='x1240' style='display:none;'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
</blockquote>
</blockquote>
</blockquote>
</blockquote>









|
|


|
|



|
|



|
|


|
|



|
|



|
|


|
|





|
|


|
|



|
|




|
|



|
|



|
|


















|
|


|
|


|
|


|
|


|
|



|
|




|
|



|
|





|
|



|
|


|
|



|
|



|
|


|
|


|
|



|
|




|
|



|
|




|
|


|
|





|
|



|
|


|
|


|
|



|
|




|
|



|
|


|
|







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
    </form>
    </div>
  </table>

<div class=startsearch></div>
  
<h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>SELECT</h2><p><b><a href="syntaxdiagrams.html#select-stmt">select-stmt:</a></b>
<button id='x1173' onclick='hideorshow("x1173","x1174")'>hide</button></p>
 <blockquote id='x1174'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#common-table-expression">common-table-expression:</a></b>
<button id='x1175' onclick='hideorshow("x1175","x1176")'>show</button></p>
 <blockquote id='x1176' style='display:none;'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#compound-operator">compound-operator:</a></b>
<button id='x1177' onclick='hideorshow("x1177","x1178")'>show</button></p>
 <blockquote id='x1178' style='display:none;'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#expr">expr:</a></b>
<button id='x1179' onclick='hideorshow("x1179","x1180")'>show</button></p>
 <blockquote id='x1180' style='display:none;'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntaxdiagrams.html#literal-value">literal-value:</a></b>
<button id='x1181' onclick='hideorshow("x1181","x1182")'>show</button></p>
 <blockquote id='x1182' style='display:none;'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#raise-function">raise-function:</a></b>
<button id='x1183' onclick='hideorshow("x1183","x1184")'>show</button></p>
 <blockquote id='x1184' style='display:none;'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#type-name">type-name:</a></b>
<button id='x1185' onclick='hideorshow("x1185","x1186")'>show</button></p>
 <blockquote id='x1186' style='display:none;'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntaxdiagrams.html#signed-number">signed-number:</a></b>
<button id='x1187' onclick='hideorshow("x1187","x1188")'>show</button></p>
 <blockquote id='x1188' style='display:none;'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</blockquote>
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-clause">join-clause:</a></b>
<button id='x1189' onclick='hideorshow("x1189","x1190")'>show</button></p>
 <blockquote id='x1190' style='display:none;'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntaxdiagrams.html#join-constraint">join-constraint:</a></b>
<button id='x1191' onclick='hideorshow("x1191","x1192")'>show</button></p>
 <blockquote id='x1192' style='display:none;'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-operator">join-operator:</a></b>
<button id='x1193' onclick='hideorshow("x1193","x1194")'>show</button></p>
 <blockquote id='x1194' style='display:none;'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#ordering-term">ordering-term:</a></b>
<button id='x1195' onclick='hideorshow("x1195","x1196")'>show</button></p>
 <blockquote id='x1196' style='display:none;'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#result-column">result-column:</a></b>
<button id='x1197' onclick='hideorshow("x1197","x1198")'>show</button></p>
 <blockquote id='x1198' style='display:none;'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#table-or-subquery">table-or-subquery:</a></b>
<button id='x1199' onclick='hideorshow("x1199","x1200")'>show</button></p>
 <blockquote id='x1200' style='display:none;'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</blockquote>
</blockquote>



<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="syntaxdiagrams.html#select-stmt">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="syntaxdiagrams.html#factored-select-stmt">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="syntaxdiagrams.html#factored-select-stmt">factored-select-stmt:</a></b>
<button id='x1201' onclick='hideorshow("x1201","x1202")'>show</button></p>
 <blockquote id='x1202' style='display:none;'>
 <img alt="syntax diagram factored-select-stmt" src="images/syntax/factored-select-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#common-table-expression">common-table-expression:</a></b>
<button id='x1203' onclick='hideorshow("x1203","x1204")'>show</button></p>
 <blockquote id='x1204' style='display:none;'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
<p><b><a href="syntaxdiagrams.html#select-stmt">select-stmt:</a></b>
<button id='x1205' onclick='hideorshow("x1205","x1206")'>show</button></p>
 <blockquote id='x1206' style='display:none;'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#join-clause">join-clause:</a></b>
<button id='x1207' onclick='hideorshow("x1207","x1208")'>show</button></p>
 <blockquote id='x1208' style='display:none;'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntaxdiagrams.html#join-constraint">join-constraint:</a></b>
<button id='x1209' onclick='hideorshow("x1209","x1210")'>show</button></p>
 <blockquote id='x1210' style='display:none;'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-operator">join-operator:</a></b>
<button id='x1211' onclick='hideorshow("x1211","x1212")'>show</button></p>
 <blockquote id='x1212' style='display:none;'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#result-column">result-column:</a></b>
<button id='x1213' onclick='hideorshow("x1213","x1214")'>show</button></p>
 <blockquote id='x1214' style='display:none;'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#table-or-subquery">table-or-subquery:</a></b>
<button id='x1215' onclick='hideorshow("x1215","x1216")'>show</button></p>
 <blockquote id='x1216' style='display:none;'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</blockquote>
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#compound-operator">compound-operator:</a></b>
<button id='x1217' onclick='hideorshow("x1217","x1218")'>show</button></p>
 <blockquote id='x1218' style='display:none;'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#expr">expr:</a></b>
<button id='x1219' onclick='hideorshow("x1219","x1220")'>show</button></p>
 <blockquote id='x1220' style='display:none;'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntaxdiagrams.html#literal-value">literal-value:</a></b>
<button id='x1221' onclick='hideorshow("x1221","x1222")'>show</button></p>
 <blockquote id='x1222' style='display:none;'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#raise-function">raise-function:</a></b>
<button id='x1223' onclick='hideorshow("x1223","x1224")'>show</button></p>
 <blockquote id='x1224' style='display:none;'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#select-stmt">select-stmt:</a></b>
<button id='x1225' onclick='hideorshow("x1225","x1226")'>show</button></p>
 <blockquote id='x1226' style='display:none;'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#join-clause">join-clause:</a></b>
<button id='x1227' onclick='hideorshow("x1227","x1228")'>show</button></p>
 <blockquote id='x1228' style='display:none;'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntaxdiagrams.html#join-constraint">join-constraint:</a></b>
<button id='x1229' onclick='hideorshow("x1229","x1230")'>show</button></p>
 <blockquote id='x1230' style='display:none;'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-operator">join-operator:</a></b>
<button id='x1231' onclick='hideorshow("x1231","x1232")'>show</button></p>
 <blockquote id='x1232' style='display:none;'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#result-column">result-column:</a></b>
<button id='x1233' onclick='hideorshow("x1233","x1234")'>show</button></p>
 <blockquote id='x1234' style='display:none;'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#table-or-subquery">table-or-subquery:</a></b>
<button id='x1235' onclick='hideorshow("x1235","x1236")'>show</button></p>
 <blockquote id='x1236' style='display:none;'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#type-name">type-name:</a></b>
<button id='x1237' onclick='hideorshow("x1237","x1238")'>show</button></p>
 <blockquote id='x1238' style='display:none;'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntaxdiagrams.html#signed-number">signed-number:</a></b>
<button id='x1239' onclick='hideorshow("x1239","x1240")'>show</button></p>
 <blockquote id='x1240' style='display:none;'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</blockquote>
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#ordering-term">ordering-term:</a></b>
<button id='x1241' onclick='hideorshow("x1241","x1242")'>show</button></p>
 <blockquote id='x1242' style='display:none;'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#select-core">select-core:</a></b>
<button id='x1243' onclick='hideorshow("x1243","x1244")'>show</button></p>
 <blockquote id='x1244' style='display:none;'>
 <img alt="syntax diagram select-core" src="images/syntax/select-core.gif" />
<p><b><a href="syntaxdiagrams.html#join-clause">join-clause:</a></b>
<button id='x1245' onclick='hideorshow("x1245","x1246")'>show</button></p>
 <blockquote id='x1246' style='display:none;'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntaxdiagrams.html#join-constraint">join-constraint:</a></b>
<button id='x1247' onclick='hideorshow("x1247","x1248")'>show</button></p>
 <blockquote id='x1248' style='display:none;'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-operator">join-operator:</a></b>
<button id='x1249' onclick='hideorshow("x1249","x1250")'>show</button></p>
 <blockquote id='x1250' style='display:none;'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#result-column">result-column:</a></b>
<button id='x1251' onclick='hideorshow("x1251","x1252")'>show</button></p>
 <blockquote id='x1252' style='display:none;'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#table-or-subquery">table-or-subquery:</a></b>
<button id='x1253' onclick='hideorshow("x1253","x1254")'>show</button></p>
 <blockquote id='x1254' style='display:none;'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
<p><b><a href="syntaxdiagrams.html#select-stmt">select-stmt:</a></b>
<button id='x1255' onclick='hideorshow("x1255","x1256")'>show</button></p>
 <blockquote id='x1256' style='display:none;'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
</blockquote>
</blockquote>
</blockquote>
</blockquote>


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
<h3>Simple Select Processing</h3>

<p>The core of a SELECT statement is a "simple SELECT" shown by the
<a href="syntaxdiagrams.html#select-core">select-core</a> and <a href="syntaxdiagrams.html#simple-select-stmt">simple-select-stmt</a> syntax diagrams below.  
In practice, most SELECT statements are simple SELECT statements.

<p><b><a href="syntaxdiagrams.html#simple-select-stmt">simple-select-stmt:</a></b>
<button id='x1241' onclick='hideorshow("x1241","x1242")'>hide</button></p>
 <blockquote id='x1242'>
 <img alt="syntax diagram simple-select-stmt" src="images/syntax/simple-select-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#common-table-expression">common-table-expression:</a></b>
<button id='x1243' onclick='hideorshow("x1243","x1244")'>show</button></p>
 <blockquote id='x1244' style='display:none;'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
<p><b><a href="syntaxdiagrams.html#select-stmt">select-stmt:</a></b>
<button id='x1245' onclick='hideorshow("x1245","x1246")'>show</button></p>
 <blockquote id='x1246' style='display:none;'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#compound-operator">compound-operator:</a></b>
<button id='x1247' onclick='hideorshow("x1247","x1248")'>show</button></p>
 <blockquote id='x1248' style='display:none;'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-clause">join-clause:</a></b>
<button id='x1249' onclick='hideorshow("x1249","x1250")'>show</button></p>
 <blockquote id='x1250' style='display:none;'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntaxdiagrams.html#join-constraint">join-constraint:</a></b>
<button id='x1251' onclick='hideorshow("x1251","x1252")'>show</button></p>
 <blockquote id='x1252' style='display:none;'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-operator">join-operator:</a></b>
<button id='x1253' onclick='hideorshow("x1253","x1254")'>show</button></p>
 <blockquote id='x1254' style='display:none;'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#result-column">result-column:</a></b>
<button id='x1255' onclick='hideorshow("x1255","x1256")'>show</button></p>
 <blockquote id='x1256' style='display:none;'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#table-or-subquery">table-or-subquery:</a></b>
<button id='x1257' onclick='hideorshow("x1257","x1258")'>show</button></p>
 <blockquote id='x1258' style='display:none;'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</blockquote>
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#expr">expr:</a></b>
<button id='x1259' onclick='hideorshow("x1259","x1260")'>show</button></p>
 <blockquote id='x1260' style='display:none;'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntaxdiagrams.html#literal-value">literal-value:</a></b>
<button id='x1261' onclick='hideorshow("x1261","x1262")'>show</button></p>
 <blockquote id='x1262' style='display:none;'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#raise-function">raise-function:</a></b>
<button id='x1263' onclick='hideorshow("x1263","x1264")'>show</button></p>
 <blockquote id='x1264' style='display:none;'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#select-stmt">select-stmt:</a></b>
<button id='x1265' onclick='hideorshow("x1265","x1266")'>show</button></p>
 <blockquote id='x1266' style='display:none;'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#compound-operator">compound-operator:</a></b>
<button id='x1267' onclick='hideorshow("x1267","x1268")'>show</button></p>
 <blockquote id='x1268' style='display:none;'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-clause">join-clause:</a></b>
<button id='x1269' onclick='hideorshow("x1269","x1270")'>show</button></p>
 <blockquote id='x1270' style='display:none;'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntaxdiagrams.html#join-constraint">join-constraint:</a></b>
<button id='x1271' onclick='hideorshow("x1271","x1272")'>show</button></p>
 <blockquote id='x1272' style='display:none;'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-operator">join-operator:</a></b>
<button id='x1273' onclick='hideorshow("x1273","x1274")'>show</button></p>
 <blockquote id='x1274' style='display:none;'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#result-column">result-column:</a></b>
<button id='x1275' onclick='hideorshow("x1275","x1276")'>show</button></p>
 <blockquote id='x1276' style='display:none;'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#table-or-subquery">table-or-subquery:</a></b>
<button id='x1277' onclick='hideorshow("x1277","x1278")'>show</button></p>
 <blockquote id='x1278' style='display:none;'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#type-name">type-name:</a></b>
<button id='x1279' onclick='hideorshow("x1279","x1280")'>show</button></p>
 <blockquote id='x1280' style='display:none;'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntaxdiagrams.html#signed-number">signed-number:</a></b>
<button id='x1281' onclick='hideorshow("x1281","x1282")'>show</button></p>
 <blockquote id='x1282' style='display:none;'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</blockquote>
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#ordering-term">ordering-term:</a></b>
<button id='x1283' onclick='hideorshow("x1283","x1284")'>show</button></p>
 <blockquote id='x1284' style='display:none;'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#select-core">select-core:</a></b>
<button id='x1285' onclick='hideorshow("x1285","x1286")'>hide</button></p>
 <blockquote id='x1286'>
 <img alt="syntax diagram select-core" src="images/syntax/select-core.gif" />
<p><b><a href="syntaxdiagrams.html#join-clause">join-clause:</a></b>
<button id='x1287' onclick='hideorshow("x1287","x1288")'>show</button></p>
 <blockquote id='x1288' style='display:none;'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntaxdiagrams.html#join-constraint">join-constraint:</a></b>
<button id='x1289' onclick='hideorshow("x1289","x1290")'>show</button></p>
 <blockquote id='x1290' style='display:none;'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-operator">join-operator:</a></b>
<button id='x1291' onclick='hideorshow("x1291","x1292")'>show</button></p>
 <blockquote id='x1292' style='display:none;'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#result-column">result-column:</a></b>
<button id='x1293' onclick='hideorshow("x1293","x1294")'>show</button></p>
 <blockquote id='x1294' style='display:none;'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#table-or-subquery">table-or-subquery:</a></b>
<button id='x1295' onclick='hideorshow("x1295","x1296")'>show</button></p>
 <blockquote id='x1296' style='display:none;'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
<p><b><a href="syntaxdiagrams.html#select-stmt">select-stmt:</a></b>
<button id='x1297' onclick='hideorshow("x1297","x1298")'>show</button></p>
 <blockquote id='x1298' style='display:none;'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#compound-operator">compound-operator:</a></b>
<button id='x1299' onclick='hideorshow("x1299","x1300")'>show</button></p>
 <blockquote id='x1300' style='display:none;'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</blockquote>








|
|


|
|


|
|


|
|



|
|


|
|



|
|




|
|



|
|





|
|


|
|



|
|



|
|


|
|



|
|


|
|



|
|




|
|



|
|




|
|


|
|





|
|



|
|


|
|


|
|



|
|




|
|



|
|


|
|


|
|







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
<h3>Simple Select Processing</h3>

<p>The core of a SELECT statement is a "simple SELECT" shown by the
<a href="syntaxdiagrams.html#select-core">select-core</a> and <a href="syntaxdiagrams.html#simple-select-stmt">simple-select-stmt</a> syntax diagrams below.  
In practice, most SELECT statements are simple SELECT statements.

<p><b><a href="syntaxdiagrams.html#simple-select-stmt">simple-select-stmt:</a></b>
<button id='x1257' onclick='hideorshow("x1257","x1258")'>hide</button></p>
 <blockquote id='x1258'>
 <img alt="syntax diagram simple-select-stmt" src="images/syntax/simple-select-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#common-table-expression">common-table-expression:</a></b>
<button id='x1259' onclick='hideorshow("x1259","x1260")'>show</button></p>
 <blockquote id='x1260' style='display:none;'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
<p><b><a href="syntaxdiagrams.html#select-stmt">select-stmt:</a></b>
<button id='x1261' onclick='hideorshow("x1261","x1262")'>show</button></p>
 <blockquote id='x1262' style='display:none;'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#compound-operator">compound-operator:</a></b>
<button id='x1263' onclick='hideorshow("x1263","x1264")'>show</button></p>
 <blockquote id='x1264' style='display:none;'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-clause">join-clause:</a></b>
<button id='x1265' onclick='hideorshow("x1265","x1266")'>show</button></p>
 <blockquote id='x1266' style='display:none;'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntaxdiagrams.html#join-constraint">join-constraint:</a></b>
<button id='x1267' onclick='hideorshow("x1267","x1268")'>show</button></p>
 <blockquote id='x1268' style='display:none;'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-operator">join-operator:</a></b>
<button id='x1269' onclick='hideorshow("x1269","x1270")'>show</button></p>
 <blockquote id='x1270' style='display:none;'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#result-column">result-column:</a></b>
<button id='x1271' onclick='hideorshow("x1271","x1272")'>show</button></p>
 <blockquote id='x1272' style='display:none;'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#table-or-subquery">table-or-subquery:</a></b>
<button id='x1273' onclick='hideorshow("x1273","x1274")'>show</button></p>
 <blockquote id='x1274' style='display:none;'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</blockquote>
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#expr">expr:</a></b>
<button id='x1275' onclick='hideorshow("x1275","x1276")'>show</button></p>
 <blockquote id='x1276' style='display:none;'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntaxdiagrams.html#literal-value">literal-value:</a></b>
<button id='x1277' onclick='hideorshow("x1277","x1278")'>show</button></p>
 <blockquote id='x1278' style='display:none;'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#raise-function">raise-function:</a></b>
<button id='x1279' onclick='hideorshow("x1279","x1280")'>show</button></p>
 <blockquote id='x1280' style='display:none;'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#select-stmt">select-stmt:</a></b>
<button id='x1281' onclick='hideorshow("x1281","x1282")'>show</button></p>
 <blockquote id='x1282' style='display:none;'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#compound-operator">compound-operator:</a></b>
<button id='x1283' onclick='hideorshow("x1283","x1284")'>show</button></p>
 <blockquote id='x1284' style='display:none;'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-clause">join-clause:</a></b>
<button id='x1285' onclick='hideorshow("x1285","x1286")'>show</button></p>
 <blockquote id='x1286' style='display:none;'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntaxdiagrams.html#join-constraint">join-constraint:</a></b>
<button id='x1287' onclick='hideorshow("x1287","x1288")'>show</button></p>
 <blockquote id='x1288' style='display:none;'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-operator">join-operator:</a></b>
<button id='x1289' onclick='hideorshow("x1289","x1290")'>show</button></p>
 <blockquote id='x1290' style='display:none;'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#result-column">result-column:</a></b>
<button id='x1291' onclick='hideorshow("x1291","x1292")'>show</button></p>
 <blockquote id='x1292' style='display:none;'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#table-or-subquery">table-or-subquery:</a></b>
<button id='x1293' onclick='hideorshow("x1293","x1294")'>show</button></p>
 <blockquote id='x1294' style='display:none;'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#type-name">type-name:</a></b>
<button id='x1295' onclick='hideorshow("x1295","x1296")'>show</button></p>
 <blockquote id='x1296' style='display:none;'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntaxdiagrams.html#signed-number">signed-number:</a></b>
<button id='x1297' onclick='hideorshow("x1297","x1298")'>show</button></p>
 <blockquote id='x1298' style='display:none;'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</blockquote>
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#ordering-term">ordering-term:</a></b>
<button id='x1299' onclick='hideorshow("x1299","x1300")'>show</button></p>
 <blockquote id='x1300' style='display:none;'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#select-core">select-core:</a></b>
<button id='x1301' onclick='hideorshow("x1301","x1302")'>hide</button></p>
 <blockquote id='x1302'>
 <img alt="syntax diagram select-core" src="images/syntax/select-core.gif" />
<p><b><a href="syntaxdiagrams.html#join-clause">join-clause:</a></b>
<button id='x1303' onclick='hideorshow("x1303","x1304")'>show</button></p>
 <blockquote id='x1304' style='display:none;'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntaxdiagrams.html#join-constraint">join-constraint:</a></b>
<button id='x1305' onclick='hideorshow("x1305","x1306")'>show</button></p>
 <blockquote id='x1306' style='display:none;'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-operator">join-operator:</a></b>
<button id='x1307' onclick='hideorshow("x1307","x1308")'>show</button></p>
 <blockquote id='x1308' style='display:none;'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#result-column">result-column:</a></b>
<button id='x1309' onclick='hideorshow("x1309","x1310")'>show</button></p>
 <blockquote id='x1310' style='display:none;'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#table-or-subquery">table-or-subquery:</a></b>
<button id='x1311' onclick='hideorshow("x1311","x1312")'>show</button></p>
 <blockquote id='x1312' style='display:none;'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
<p><b><a href="syntaxdiagrams.html#select-stmt">select-stmt:</a></b>
<button id='x1313' onclick='hideorshow("x1313","x1314")'>show</button></p>
 <blockquote id='x1314' style='display:none;'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#compound-operator">compound-operator:</a></b>
<button id='x1315' onclick='hideorshow("x1315","x1316")'>show</button></p>
 <blockquote id='x1316' style='display:none;'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</blockquote>

657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
<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







|
|







657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
<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
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
<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="syntaxdiagrams.html#compound-select-stmt">compound-select-stmt:</a></b>
<button id='x1301' onclick='hideorshow("x1301","x1302")'>hide</button></p>
 <blockquote id='x1302'>
 <img alt="syntax diagram compound-select-stmt" src="images/syntax/compound-select-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#common-table-expression">common-table-expression:</a></b>
<button id='x1303' onclick='hideorshow("x1303","x1304")'>show</button></p>
 <blockquote id='x1304' style='display:none;'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
<p><b><a href="syntaxdiagrams.html#select-stmt">select-stmt:</a></b>
<button id='x1305' onclick='hideorshow("x1305","x1306")'>show</button></p>
 <blockquote id='x1306' style='display:none;'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#compound-operator">compound-operator:</a></b>
<button id='x1307' onclick='hideorshow("x1307","x1308")'>show</button></p>
 <blockquote id='x1308' style='display:none;'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-clause">join-clause:</a></b>
<button id='x1309' onclick='hideorshow("x1309","x1310")'>show</button></p>
 <blockquote id='x1310' style='display:none;'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntaxdiagrams.html#join-constraint">join-constraint:</a></b>
<button id='x1311' onclick='hideorshow("x1311","x1312")'>show</button></p>
 <blockquote id='x1312' style='display:none;'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-operator">join-operator:</a></b>
<button id='x1313' onclick='hideorshow("x1313","x1314")'>show</button></p>
 <blockquote id='x1314' style='display:none;'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#result-column">result-column:</a></b>
<button id='x1315' onclick='hideorshow("x1315","x1316")'>show</button></p>
 <blockquote id='x1316' style='display:none;'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#table-or-subquery">table-or-subquery:</a></b>
<button id='x1317' onclick='hideorshow("x1317","x1318")'>show</button></p>
 <blockquote id='x1318' style='display:none;'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</blockquote>
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#expr">expr:</a></b>
<button id='x1319' onclick='hideorshow("x1319","x1320")'>show</button></p>
 <blockquote id='x1320' style='display:none;'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntaxdiagrams.html#literal-value">literal-value:</a></b>
<button id='x1321' onclick='hideorshow("x1321","x1322")'>show</button></p>
 <blockquote id='x1322' style='display:none;'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#raise-function">raise-function:</a></b>
<button id='x1323' onclick='hideorshow("x1323","x1324")'>show</button></p>
 <blockquote id='x1324' style='display:none;'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#select-stmt">select-stmt:</a></b>
<button id='x1325' onclick='hideorshow("x1325","x1326")'>show</button></p>
 <blockquote id='x1326' style='display:none;'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#compound-operator">compound-operator:</a></b>
<button id='x1327' onclick='hideorshow("x1327","x1328")'>show</button></p>
 <blockquote id='x1328' style='display:none;'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-clause">join-clause:</a></b>
<button id='x1329' onclick='hideorshow("x1329","x1330")'>show</button></p>
 <blockquote id='x1330' style='display:none;'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntaxdiagrams.html#join-constraint">join-constraint:</a></b>
<button id='x1331' onclick='hideorshow("x1331","x1332")'>show</button></p>
 <blockquote id='x1332' style='display:none;'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-operator">join-operator:</a></b>
<button id='x1333' onclick='hideorshow("x1333","x1334")'>show</button></p>
 <blockquote id='x1334' style='display:none;'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#result-column">result-column:</a></b>
<button id='x1335' onclick='hideorshow("x1335","x1336")'>show</button></p>
 <blockquote id='x1336' style='display:none;'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#table-or-subquery">table-or-subquery:</a></b>
<button id='x1337' onclick='hideorshow("x1337","x1338")'>show</button></p>
 <blockquote id='x1338' style='display:none;'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#type-name">type-name:</a></b>
<button id='x1339' onclick='hideorshow("x1339","x1340")'>show</button></p>
 <blockquote id='x1340' style='display:none;'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntaxdiagrams.html#signed-number">signed-number:</a></b>
<button id='x1341' onclick='hideorshow("x1341","x1342")'>show</button></p>
 <blockquote id='x1342' style='display:none;'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</blockquote>
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#ordering-term">ordering-term:</a></b>
<button id='x1343' onclick='hideorshow("x1343","x1344")'>show</button></p>
 <blockquote id='x1344' style='display:none;'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#select-core">select-core:</a></b>
<button id='x1345' onclick='hideorshow("x1345","x1346")'>show</button></p>
 <blockquote id='x1346' style='display:none;'>
 <img alt="syntax diagram select-core" src="images/syntax/select-core.gif" />
<p><b><a href="syntaxdiagrams.html#join-clause">join-clause:</a></b>
<button id='x1347' onclick='hideorshow("x1347","x1348")'>show</button></p>
 <blockquote id='x1348' style='display:none;'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntaxdiagrams.html#join-constraint">join-constraint:</a></b>
<button id='x1349' onclick='hideorshow("x1349","x1350")'>show</button></p>
 <blockquote id='x1350' style='display:none;'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-operator">join-operator:</a></b>
<button id='x1351' onclick='hideorshow("x1351","x1352")'>show</button></p>
 <blockquote id='x1352' style='display:none;'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#result-column">result-column:</a></b>
<button id='x1353' onclick='hideorshow("x1353","x1354")'>show</button></p>
 <blockquote id='x1354' style='display:none;'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#table-or-subquery">table-or-subquery:</a></b>
<button id='x1355' onclick='hideorshow("x1355","x1356")'>show</button></p>
 <blockquote id='x1356' style='display:none;'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
<p><b><a href="syntaxdiagrams.html#select-stmt">select-stmt:</a></b>
<button id='x1357' onclick='hideorshow("x1357","x1358")'>show</button></p>
 <blockquote id='x1358' style='display:none;'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#compound-operator">compound-operator:</a></b>
<button id='x1359' onclick='hideorshow("x1359","x1360")'>show</button></p>
 <blockquote id='x1360' style='display:none;'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</blockquote>








|
|


|
|


|
|


|
|



|
|


|
|



|
|




|
|



|
|





|
|


|
|



|
|



|
|


|
|



|
|


|
|



|
|




|
|



|
|




|
|


|
|





|
|



|
|


|
|


|
|



|
|




|
|



|
|


|
|


|
|







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
<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="syntaxdiagrams.html#compound-select-stmt">compound-select-stmt:</a></b>
<button id='x1317' onclick='hideorshow("x1317","x1318")'>hide</button></p>
 <blockquote id='x1318'>
 <img alt="syntax diagram compound-select-stmt" src="images/syntax/compound-select-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#common-table-expression">common-table-expression:</a></b>
<button id='x1319' onclick='hideorshow("x1319","x1320")'>show</button></p>
 <blockquote id='x1320' style='display:none;'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
<p><b><a href="syntaxdiagrams.html#select-stmt">select-stmt:</a></b>
<button id='x1321' onclick='hideorshow("x1321","x1322")'>show</button></p>
 <blockquote id='x1322' style='display:none;'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#compound-operator">compound-operator:</a></b>
<button id='x1323' onclick='hideorshow("x1323","x1324")'>show</button></p>
 <blockquote id='x1324' style='display:none;'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-clause">join-clause:</a></b>
<button id='x1325' onclick='hideorshow("x1325","x1326")'>show</button></p>
 <blockquote id='x1326' style='display:none;'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntaxdiagrams.html#join-constraint">join-constraint:</a></b>
<button id='x1327' onclick='hideorshow("x1327","x1328")'>show</button></p>
 <blockquote id='x1328' style='display:none;'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-operator">join-operator:</a></b>
<button id='x1329' onclick='hideorshow("x1329","x1330")'>show</button></p>
 <blockquote id='x1330' style='display:none;'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#result-column">result-column:</a></b>
<button id='x1331' onclick='hideorshow("x1331","x1332")'>show</button></p>
 <blockquote id='x1332' style='display:none;'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#table-or-subquery">table-or-subquery:</a></b>
<button id='x1333' onclick='hideorshow("x1333","x1334")'>show</button></p>
 <blockquote id='x1334' style='display:none;'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</blockquote>
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#expr">expr:</a></b>
<button id='x1335' onclick='hideorshow("x1335","x1336")'>show</button></p>
 <blockquote id='x1336' style='display:none;'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntaxdiagrams.html#literal-value">literal-value:</a></b>
<button id='x1337' onclick='hideorshow("x1337","x1338")'>show</button></p>
 <blockquote id='x1338' style='display:none;'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#raise-function">raise-function:</a></b>
<button id='x1339' onclick='hideorshow("x1339","x1340")'>show</button></p>
 <blockquote id='x1340' style='display:none;'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#select-stmt">select-stmt:</a></b>
<button id='x1341' onclick='hideorshow("x1341","x1342")'>show</button></p>
 <blockquote id='x1342' style='display:none;'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#compound-operator">compound-operator:</a></b>
<button id='x1343' onclick='hideorshow("x1343","x1344")'>show</button></p>
 <blockquote id='x1344' style='display:none;'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-clause">join-clause:</a></b>
<button id='x1345' onclick='hideorshow("x1345","x1346")'>show</button></p>
 <blockquote id='x1346' style='display:none;'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntaxdiagrams.html#join-constraint">join-constraint:</a></b>
<button id='x1347' onclick='hideorshow("x1347","x1348")'>show</button></p>
 <blockquote id='x1348' style='display:none;'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-operator">join-operator:</a></b>
<button id='x1349' onclick='hideorshow("x1349","x1350")'>show</button></p>
 <blockquote id='x1350' style='display:none;'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#result-column">result-column:</a></b>
<button id='x1351' onclick='hideorshow("x1351","x1352")'>show</button></p>
 <blockquote id='x1352' style='display:none;'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#table-or-subquery">table-or-subquery:</a></b>
<button id='x1353' onclick='hideorshow("x1353","x1354")'>show</button></p>
 <blockquote id='x1354' style='display:none;'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#type-name">type-name:</a></b>
<button id='x1355' onclick='hideorshow("x1355","x1356")'>show</button></p>
 <blockquote id='x1356' style='display:none;'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntaxdiagrams.html#signed-number">signed-number:</a></b>
<button id='x1357' onclick='hideorshow("x1357","x1358")'>show</button></p>
 <blockquote id='x1358' style='display:none;'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</blockquote>
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#ordering-term">ordering-term:</a></b>
<button id='x1359' onclick='hideorshow("x1359","x1360")'>show</button></p>
 <blockquote id='x1360' style='display:none;'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#select-core">select-core:</a></b>
<button id='x1361' onclick='hideorshow("x1361","x1362")'>show</button></p>
 <blockquote id='x1362' style='display:none;'>
 <img alt="syntax diagram select-core" src="images/syntax/select-core.gif" />
<p><b><a href="syntaxdiagrams.html#join-clause">join-clause:</a></b>
<button id='x1363' onclick='hideorshow("x1363","x1364")'>show</button></p>
 <blockquote id='x1364' style='display:none;'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntaxdiagrams.html#join-constraint">join-constraint:</a></b>
<button id='x1365' onclick='hideorshow("x1365","x1366")'>show</button></p>
 <blockquote id='x1366' style='display:none;'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-operator">join-operator:</a></b>
<button id='x1367' onclick='hideorshow("x1367","x1368")'>show</button></p>
 <blockquote id='x1368' style='display:none;'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#result-column">result-column:</a></b>
<button id='x1369' onclick='hideorshow("x1369","x1370")'>show</button></p>
 <blockquote id='x1370' style='display:none;'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#table-or-subquery">table-or-subquery:</a></b>
<button id='x1371' onclick='hideorshow("x1371","x1372")'>show</button></p>
 <blockquote id='x1372' style='display:none;'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
<p><b><a href="syntaxdiagrams.html#select-stmt">select-stmt:</a></b>
<button id='x1373' onclick='hideorshow("x1373","x1374")'>show</button></p>
 <blockquote id='x1374' style='display:none;'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#compound-operator">compound-operator:</a></b>
<button id='x1375' onclick='hideorshow("x1375","x1376")'>show</button></p>
 <blockquote id='x1376' style='display:none;'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</blockquote>

Changes to Doc/Extra/Core/lang_transaction.html.
125
126
127
128
129
130
131
132
133
134
135










136
137
138
139
140
141
142
    </form>
    </div>
  </table>

<div class=startsearch></div>
  
<h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>BEGIN TRANSACTION</h2><p><b><a href="syntaxdiagrams.html#begin-stmt">begin-stmt:</a></b>
<button id='x801' onclick='hideorshow("x801","x802")'>hide</button></p>
 <blockquote id='x802'>
 <img alt="syntax diagram begin-stmt" src="images/syntax/begin-stmt.gif" />
</blockquote>












<p>
No changes can be made to the database except within a transaction.
Any command that changes the database (basically, any SQL command
other than <a href="lang_select.html">SELECT</a>) will automatically start a transaction if
one is not already in effect.  Automatically started transactions







|
|


>
>
>
>
>
>
>
>
>
>







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
    </form>
    </div>
  </table>

<div class=startsearch></div>
  
<h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>BEGIN TRANSACTION</h2><p><b><a href="syntaxdiagrams.html#begin-stmt">begin-stmt:</a></b>
<button id='x809' onclick='hideorshow("x809","x810")'>hide</button></p>
 <blockquote id='x810'>
 <img alt="syntax diagram begin-stmt" src="images/syntax/begin-stmt.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#commit-stmt">commit-stmt:</a></b>
<button id='x811' onclick='hideorshow("x811","x812")'>hide</button></p>
 <blockquote id='x812'>
 <img alt="syntax diagram commit-stmt" src="images/syntax/commit-stmt.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#rollback-stmt">rollback-stmt:</a></b>
<button id='x813' onclick='hideorshow("x813","x814")'>hide</button></p>
 <blockquote id='x814'>
 <img alt="syntax diagram rollback-stmt" src="images/syntax/rollback-stmt.gif" />
</blockquote>


<p>
No changes can be made to the database except within a transaction.
Any command that changes the database (basically, any SQL command
other than <a href="lang_select.html">SELECT</a>) will automatically start a transaction if
one is not already in effect.  Automatically started transactions
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
finishes when it is <a href="c3ref/blob_close.html">closed</a>.
</p>

<p>
The explicit COMMIT command runs immediately, even if there are
pending <a href="lang_select.html">SELECT</a> statements.  However, if there are pending
write operations, the COMMIT command
will fail with an error code <a href="c3ref/c_abort.html">SQLITE_BUSY</a>.
</p>

<p>
An attempt to execute COMMIT might also result in an <a href="c3ref/c_abort.html">SQLITE_BUSY</a> return code
if an another thread or process has a <a href="lockingv3.html#shared_lock">shared lock</a> on the database
that prevented the database from being updated.  When COMMIT fails in this
way, the transaction remains active and the COMMIT can be retried later
after the reader has had a chance to clear.
</p>

<p>
The ROLLBACK will fail with an error code <a href="c3ref/c_abort.html">SQLITE_BUSY</a> if there
are any pending queries.  Both read-only and read/write queries will
cause a ROLLBACK to fail.  A ROLLBACK must fail if there are pending
read operations (unlike COMMIT which can succeed) because bad things
will happen if the in-memory image of the database is changed out from under
an active query.
</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="c3ref/c_abort.html">SQLITE_FULL</a>: database or disk full
<li> <a href="c3ref/c_abort.html">SQLITE_IOERR</a>: disk I/O error
<li> <a href="c3ref/c_abort.html">SQLITE_BUSY</a>: database in use by another process
<li> <a href="c3ref/c_abort.html">SQLITE_NOMEM</a>: out or memory
<li> <a href="c3ref/c_abort.html">SQLITE_INTERRUPT</a>: processing <a href="c3ref/interrupt.html">interrupted</a>
     by application request
</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, 







|



|







|
|
|
|
|
<














|
|
|
|
|







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
finishes when it is <a href="c3ref/blob_close.html">closed</a>.
</p>

<p>
The explicit COMMIT command runs immediately, even if there are
pending <a href="lang_select.html">SELECT</a> statements.  However, if there are pending
write operations, the COMMIT command
will fail with an error code <a href="rescode.html#busy">SQLITE_BUSY</a>.
</p>

<p>
An attempt to execute COMMIT might also result in an <a href="rescode.html#busy">SQLITE_BUSY</a> return code
if an another thread or process has a <a href="lockingv3.html#shared_lock">shared lock</a> on the database
that prevented the database from being updated.  When COMMIT fails in this
way, the transaction remains active and the COMMIT can be retried later
after the reader has had a chance to clear.
</p>

<p>
In older versions of SQLite the ROLLBACK will fail with an error code 
<a href="rescode.html#busy">SQLITE_BUSY</a> if there are any pending queries.  In more recent
versions of SQLite (since version 3.7.11 circa 2012-03-20) the ROLLBACK
will proceed and pending statements will be aborted with an
<a href="rescode.html#abort">SQLITE_ABORT</a> or <a href="rescode.html#abort_rollback">SQLITE_ABORT_ROLLBACK</a> error.

</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
<li> <a href="rescode.html#interrupt">SQLITE_INTERRUPT</a>: processing <a href="c3ref/interrupt.html">interrupted</a>
     by application request
</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, 
Changes to Doc/Extra/Core/lang_update.html.
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
    </form>
    </div>
  </table>

<div class=startsearch></div>
  
<h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>UPDATE</h2><p><b><a href="syntaxdiagrams.html#update-stmt">update-stmt:</a></b>
<button id='x1361' onclick='hideorshow("x1361","x1362")'>hide</button></p>
 <blockquote id='x1362'>
 <img alt="syntax diagram update-stmt" src="images/syntax/update-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#expr">expr:</a></b>
<button id='x1363' onclick='hideorshow("x1363","x1364")'>show</button></p>
 <blockquote id='x1364' style='display:none;'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntaxdiagrams.html#literal-value">literal-value:</a></b>
<button id='x1365' onclick='hideorshow("x1365","x1366")'>show</button></p>
 <blockquote id='x1366' style='display:none;'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#raise-function">raise-function:</a></b>
<button id='x1367' onclick='hideorshow("x1367","x1368")'>show</button></p>
 <blockquote id='x1368' style='display:none;'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#select-stmt">select-stmt:</a></b>
<button id='x1369' onclick='hideorshow("x1369","x1370")'>show</button></p>
 <blockquote id='x1370' style='display:none;'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#common-table-expression">common-table-expression:</a></b>
<button id='x1371' onclick='hideorshow("x1371","x1372")'>show</button></p>
 <blockquote id='x1372' style='display:none;'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#compound-operator">compound-operator:</a></b>
<button id='x1373' onclick='hideorshow("x1373","x1374")'>show</button></p>
 <blockquote id='x1374' style='display:none;'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-clause">join-clause:</a></b>
<button id='x1375' onclick='hideorshow("x1375","x1376")'>show</button></p>
 <blockquote id='x1376' style='display:none;'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntaxdiagrams.html#join-constraint">join-constraint:</a></b>
<button id='x1377' onclick='hideorshow("x1377","x1378")'>show</button></p>
 <blockquote id='x1378' style='display:none;'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-operator">join-operator:</a></b>
<button id='x1379' onclick='hideorshow("x1379","x1380")'>show</button></p>
 <blockquote id='x1380' style='display:none;'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#ordering-term">ordering-term:</a></b>
<button id='x1381' onclick='hideorshow("x1381","x1382")'>show</button></p>
 <blockquote id='x1382' style='display:none;'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#result-column">result-column:</a></b>
<button id='x1383' onclick='hideorshow("x1383","x1384")'>show</button></p>
 <blockquote id='x1384' style='display:none;'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#table-or-subquery">table-or-subquery:</a></b>
<button id='x1385' onclick='hideorshow("x1385","x1386")'>show</button></p>
 <blockquote id='x1386' style='display:none;'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#type-name">type-name:</a></b>
<button id='x1387' onclick='hideorshow("x1387","x1388")'>show</button></p>
 <blockquote id='x1388' style='display:none;'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntaxdiagrams.html#signed-number">signed-number:</a></b>
<button id='x1389' onclick='hideorshow("x1389","x1390")'>show</button></p>
 <blockquote id='x1390' style='display:none;'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</blockquote>
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#qualified-table-name">qualified-table-name:</a></b>
<button id='x1391' onclick='hideorshow("x1391","x1392")'>show</button></p>
 <blockquote id='x1392' style='display:none;'>
 <img alt="syntax diagram qualified-table-name" src="images/syntax/qualified-table-name.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#with-clause">with-clause:</a></b>
<button id='x1393' onclick='hideorshow("x1393","x1394")'>show</button></p>
 <blockquote id='x1394' style='display:none;'>
 <img alt="syntax diagram with-clause" src="images/syntax/with-clause.gif" />
<p><b><a href="syntaxdiagrams.html#cte-table-name">cte-table-name:</a></b>
<button id='x1395' onclick='hideorshow("x1395","x1396")'>show</button></p>
 <blockquote id='x1396' style='display:none;'>
 <img alt="syntax diagram cte-table-name" src="images/syntax/cte-table-name.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#select-stmt">select-stmt:</a></b>
<button id='x1397' onclick='hideorshow("x1397","x1398")'>show</button></p>
 <blockquote id='x1398' style='display:none;'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#common-table-expression">common-table-expression:</a></b>
<button id='x1399' onclick='hideorshow("x1399","x1400")'>show</button></p>
 <blockquote id='x1400' style='display:none;'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#compound-operator">compound-operator:</a></b>
<button id='x1401' onclick='hideorshow("x1401","x1402")'>show</button></p>
 <blockquote id='x1402' style='display:none;'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-clause">join-clause:</a></b>
<button id='x1403' onclick='hideorshow("x1403","x1404")'>show</button></p>
 <blockquote id='x1404' style='display:none;'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntaxdiagrams.html#join-constraint">join-constraint:</a></b>
<button id='x1405' onclick='hideorshow("x1405","x1406")'>show</button></p>
 <blockquote id='x1406' style='display:none;'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-operator">join-operator:</a></b>
<button id='x1407' onclick='hideorshow("x1407","x1408")'>show</button></p>
 <blockquote id='x1408' style='display:none;'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#ordering-term">ordering-term:</a></b>
<button id='x1409' onclick='hideorshow("x1409","x1410")'>show</button></p>
 <blockquote id='x1410' style='display:none;'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#result-column">result-column:</a></b>
<button id='x1411' onclick='hideorshow("x1411","x1412")'>show</button></p>
 <blockquote id='x1412' style='display:none;'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#table-or-subquery">table-or-subquery:</a></b>
<button id='x1413' onclick='hideorshow("x1413","x1414")'>show</button></p>
 <blockquote id='x1414' style='display:none;'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</blockquote>
</blockquote>
</blockquote>
</blockquote>









|
|


|
|


|
|



|
|



|
|


|
|



|
|



|
|


|
|



|
|




|
|



|
|



|
|




|
|


|
|





|
|



|
|


|
|



|
|


|
|



|
|



|
|


|
|



|
|




|
|



|
|



|
|







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
    </form>
    </div>
  </table>

<div class=startsearch></div>
  
<h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>UPDATE</h2><p><b><a href="syntaxdiagrams.html#update-stmt">update-stmt:</a></b>
<button id='x1377' onclick='hideorshow("x1377","x1378")'>hide</button></p>
 <blockquote id='x1378'>
 <img alt="syntax diagram update-stmt" src="images/syntax/update-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#expr">expr:</a></b>
<button id='x1379' onclick='hideorshow("x1379","x1380")'>show</button></p>
 <blockquote id='x1380' style='display:none;'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntaxdiagrams.html#literal-value">literal-value:</a></b>
<button id='x1381' onclick='hideorshow("x1381","x1382")'>show</button></p>
 <blockquote id='x1382' style='display:none;'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#raise-function">raise-function:</a></b>
<button id='x1383' onclick='hideorshow("x1383","x1384")'>show</button></p>
 <blockquote id='x1384' style='display:none;'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#select-stmt">select-stmt:</a></b>
<button id='x1385' onclick='hideorshow("x1385","x1386")'>show</button></p>
 <blockquote id='x1386' style='display:none;'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#common-table-expression">common-table-expression:</a></b>
<button id='x1387' onclick='hideorshow("x1387","x1388")'>show</button></p>
 <blockquote id='x1388' style='display:none;'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#compound-operator">compound-operator:</a></b>
<button id='x1389' onclick='hideorshow("x1389","x1390")'>show</button></p>
 <blockquote id='x1390' style='display:none;'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-clause">join-clause:</a></b>
<button id='x1391' onclick='hideorshow("x1391","x1392")'>show</button></p>
 <blockquote id='x1392' style='display:none;'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntaxdiagrams.html#join-constraint">join-constraint:</a></b>
<button id='x1393' onclick='hideorshow("x1393","x1394")'>show</button></p>
 <blockquote id='x1394' style='display:none;'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-operator">join-operator:</a></b>
<button id='x1395' onclick='hideorshow("x1395","x1396")'>show</button></p>
 <blockquote id='x1396' style='display:none;'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#ordering-term">ordering-term:</a></b>
<button id='x1397' onclick='hideorshow("x1397","x1398")'>show</button></p>
 <blockquote id='x1398' style='display:none;'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#result-column">result-column:</a></b>
<button id='x1399' onclick='hideorshow("x1399","x1400")'>show</button></p>
 <blockquote id='x1400' style='display:none;'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#table-or-subquery">table-or-subquery:</a></b>
<button id='x1401' onclick='hideorshow("x1401","x1402")'>show</button></p>
 <blockquote id='x1402' style='display:none;'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#type-name">type-name:</a></b>
<button id='x1403' onclick='hideorshow("x1403","x1404")'>show</button></p>
 <blockquote id='x1404' style='display:none;'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntaxdiagrams.html#signed-number">signed-number:</a></b>
<button id='x1405' onclick='hideorshow("x1405","x1406")'>show</button></p>
 <blockquote id='x1406' style='display:none;'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</blockquote>
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#qualified-table-name">qualified-table-name:</a></b>
<button id='x1407' onclick='hideorshow("x1407","x1408")'>show</button></p>
 <blockquote id='x1408' style='display:none;'>
 <img alt="syntax diagram qualified-table-name" src="images/syntax/qualified-table-name.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#with-clause">with-clause:</a></b>
<button id='x1409' onclick='hideorshow("x1409","x1410")'>show</button></p>
 <blockquote id='x1410' style='display:none;'>
 <img alt="syntax diagram with-clause" src="images/syntax/with-clause.gif" />
<p><b><a href="syntaxdiagrams.html#cte-table-name">cte-table-name:</a></b>
<button id='x1411' onclick='hideorshow("x1411","x1412")'>show</button></p>
 <blockquote id='x1412' style='display:none;'>
 <img alt="syntax diagram cte-table-name" src="images/syntax/cte-table-name.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#select-stmt">select-stmt:</a></b>
<button id='x1413' onclick='hideorshow("x1413","x1414")'>show</button></p>
 <blockquote id='x1414' style='display:none;'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#common-table-expression">common-table-expression:</a></b>
<button id='x1415' onclick='hideorshow("x1415","x1416")'>show</button></p>
 <blockquote id='x1416' style='display:none;'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#compound-operator">compound-operator:</a></b>
<button id='x1417' onclick='hideorshow("x1417","x1418")'>show</button></p>
 <blockquote id='x1418' style='display:none;'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-clause">join-clause:</a></b>
<button id='x1419' onclick='hideorshow("x1419","x1420")'>show</button></p>
 <blockquote id='x1420' style='display:none;'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntaxdiagrams.html#join-constraint">join-constraint:</a></b>
<button id='x1421' onclick='hideorshow("x1421","x1422")'>show</button></p>
 <blockquote id='x1422' style='display:none;'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-operator">join-operator:</a></b>
<button id='x1423' onclick='hideorshow("x1423","x1424")'>show</button></p>
 <blockquote id='x1424' style='display:none;'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#ordering-term">ordering-term:</a></b>
<button id='x1425' onclick='hideorshow("x1425","x1426")'>show</button></p>
 <blockquote id='x1426' style='display:none;'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#result-column">result-column:</a></b>
<button id='x1427' onclick='hideorshow("x1427","x1428")'>show</button></p>
 <blockquote id='x1428' style='display:none;'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#table-or-subquery">table-or-subquery:</a></b>
<button id='x1429' onclick='hideorshow("x1429","x1430")'>show</button></p>
 <blockquote id='x1430' style='display:none;'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</blockquote>
</blockquote>
</blockquote>
</blockquote>


Changes to Doc/Extra/Core/lang_vacuum.html.
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
    </form>
    </div>
  </table>

<div class=startsearch></div>
  
<h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>VACUUM</h2><p><b><a href="syntaxdiagrams.html#vacuum-stmt">vacuum-stmt:</a></b>
<button id='x1415' onclick='hideorshow("x1415","x1416")'>hide</button></p>
 <blockquote id='x1416'>
 <img alt="syntax diagram vacuum-stmt" src="images/syntax/vacuum-stmt.gif" />
</blockquote>


<p>
  The VACUUM command rebuilds the entire database. There are several 
  reasons an application might do this:







|
|







125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
    </form>
    </div>
  </table>

<div class=startsearch></div>
  
<h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>VACUUM</h2><p><b><a href="syntaxdiagrams.html#vacuum-stmt">vacuum-stmt:</a></b>
<button id='x1431' onclick='hideorshow("x1431","x1432")'>hide</button></p>
 <blockquote id='x1432'>
 <img alt="syntax diagram vacuum-stmt" src="images/syntax/vacuum-stmt.gif" />
</blockquote>


<p>
  The VACUUM command rebuilds the entire database. There are several 
  reasons an application might do this:
Changes to Doc/Extra/Core/lang_with.html.
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
    </form>
    </div>
  </table>

<div class=startsearch></div>
  
<h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>WITH clause</h2><p><b><a href="syntaxdiagrams.html#with-clause">with-clause:</a></b>
<button id='x1121' onclick='hideorshow("x1121","x1122")'>hide</button></p>
 <blockquote id='x1122'>
 <img alt="syntax diagram with-clause" src="images/syntax/with-clause.gif" />
<p><b><a href="syntaxdiagrams.html#cte-table-name">cte-table-name:</a></b>
<button id='x1123' onclick='hideorshow("x1123","x1124")'>show</button></p>
 <blockquote id='x1124' style='display:none;'>
 <img alt="syntax diagram cte-table-name" src="images/syntax/cte-table-name.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#select-stmt">select-stmt:</a></b>
<button id='x1125' onclick='hideorshow("x1125","x1126")'>show</button></p>
 <blockquote id='x1126' style='display:none;'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#common-table-expression">common-table-expression:</a></b>
<button id='x1127' onclick='hideorshow("x1127","x1128")'>show</button></p>
 <blockquote id='x1128' style='display:none;'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#compound-operator">compound-operator:</a></b>
<button id='x1129' onclick='hideorshow("x1129","x1130")'>show</button></p>
 <blockquote id='x1130' style='display:none;'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#expr">expr:</a></b>
<button id='x1131' onclick='hideorshow("x1131","x1132")'>show</button></p>
 <blockquote id='x1132' style='display:none;'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntaxdiagrams.html#literal-value">literal-value:</a></b>
<button id='x1133' onclick='hideorshow("x1133","x1134")'>show</button></p>
 <blockquote id='x1134' style='display:none;'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#raise-function">raise-function:</a></b>
<button id='x1135' onclick='hideorshow("x1135","x1136")'>show</button></p>
 <blockquote id='x1136' style='display:none;'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#type-name">type-name:</a></b>
<button id='x1137' onclick='hideorshow("x1137","x1138")'>show</button></p>
 <blockquote id='x1138' style='display:none;'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntaxdiagrams.html#signed-number">signed-number:</a></b>
<button id='x1139' onclick='hideorshow("x1139","x1140")'>show</button></p>
 <blockquote id='x1140' style='display:none;'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</blockquote>
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-clause">join-clause:</a></b>
<button id='x1141' onclick='hideorshow("x1141","x1142")'>show</button></p>
 <blockquote id='x1142' style='display:none;'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntaxdiagrams.html#join-constraint">join-constraint:</a></b>
<button id='x1143' onclick='hideorshow("x1143","x1144")'>show</button></p>
 <blockquote id='x1144' style='display:none;'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-operator">join-operator:</a></b>
<button id='x1145' onclick='hideorshow("x1145","x1146")'>show</button></p>
 <blockquote id='x1146' style='display:none;'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#ordering-term">ordering-term:</a></b>
<button id='x1147' onclick='hideorshow("x1147","x1148")'>show</button></p>
 <blockquote id='x1148' style='display:none;'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#result-column">result-column:</a></b>
<button id='x1149' onclick='hideorshow("x1149","x1150")'>show</button></p>
 <blockquote id='x1150' style='display:none;'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#table-or-subquery">table-or-subquery:</a></b>
<button id='x1151' onclick='hideorshow("x1151","x1152")'>show</button></p>
 <blockquote id='x1152' style='display:none;'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</blockquote>
</blockquote>
</blockquote>


<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 expression
provide the ability to do hierarchical or
recursive queries of trees and graphs, a capability
that is not otherwise available in the SQL language.

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.


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





<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







|
|


|
|



|
|


|
|



|
|



|
|


|
|



|
|



|
|


|
|





|
|


|
|



|
|




|
|



|
|



|
|












|




|


|
>









>
>
>
>







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
    </form>
    </div>
  </table>

<div class=startsearch></div>
  
<h1 align="center">SQL As Understood By SQLite</h1><p><a href="lang.html">[Top]</a></p><h2>WITH clause</h2><p><b><a href="syntaxdiagrams.html#with-clause">with-clause:</a></b>
<button id='x1137' onclick='hideorshow("x1137","x1138")'>hide</button></p>
 <blockquote id='x1138'>
 <img alt="syntax diagram with-clause" src="images/syntax/with-clause.gif" />
<p><b><a href="syntaxdiagrams.html#cte-table-name">cte-table-name:</a></b>
<button id='x1139' onclick='hideorshow("x1139","x1140")'>show</button></p>
 <blockquote id='x1140' style='display:none;'>
 <img alt="syntax diagram cte-table-name" src="images/syntax/cte-table-name.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#select-stmt">select-stmt:</a></b>
<button id='x1141' onclick='hideorshow("x1141","x1142")'>show</button></p>
 <blockquote id='x1142' style='display:none;'>
 <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#common-table-expression">common-table-expression:</a></b>
<button id='x1143' onclick='hideorshow("x1143","x1144")'>show</button></p>
 <blockquote id='x1144' style='display:none;'>
 <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#compound-operator">compound-operator:</a></b>
<button id='x1145' onclick='hideorshow("x1145","x1146")'>show</button></p>
 <blockquote id='x1146' style='display:none;'>
 <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#expr">expr:</a></b>
<button id='x1147' onclick='hideorshow("x1147","x1148")'>show</button></p>
 <blockquote id='x1148' style='display:none;'>
 <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
<p><b><a href="syntaxdiagrams.html#literal-value">literal-value:</a></b>
<button id='x1149' onclick='hideorshow("x1149","x1150")'>show</button></p>
 <blockquote id='x1150' style='display:none;'>
 <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#raise-function">raise-function:</a></b>
<button id='x1151' onclick='hideorshow("x1151","x1152")'>show</button></p>
 <blockquote id='x1152' style='display:none;'>
 <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#type-name">type-name:</a></b>
<button id='x1153' onclick='hideorshow("x1153","x1154")'>show</button></p>
 <blockquote id='x1154' style='display:none;'>
 <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
<p><b><a href="syntaxdiagrams.html#signed-number">signed-number:</a></b>
<button id='x1155' onclick='hideorshow("x1155","x1156")'>show</button></p>
 <blockquote id='x1156' style='display:none;'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</blockquote>
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-clause">join-clause:</a></b>
<button id='x1157' onclick='hideorshow("x1157","x1158")'>show</button></p>
 <blockquote id='x1158' style='display:none;'>
 <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
<p><b><a href="syntaxdiagrams.html#join-constraint">join-constraint:</a></b>
<button id='x1159' onclick='hideorshow("x1159","x1160")'>show</button></p>
 <blockquote id='x1160' style='display:none;'>
 <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#join-operator">join-operator:</a></b>
<button id='x1161' onclick='hideorshow("x1161","x1162")'>show</button></p>
 <blockquote id='x1162' style='display:none;'>
 <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
</blockquote>
</blockquote>
<p><b><a href="syntaxdiagrams.html#ordering-term">ordering-term:</a></b>
<button id='x1163' onclick='hideorshow("x1163","x1164")'>show</button></p>
 <blockquote id='x1164' style='display:none;'>
 <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#result-column">result-column:</a></b>
<button id='x1165' onclick='hideorshow("x1165","x1166")'>show</button></p>
 <blockquote id='x1166' style='display:none;'>
 <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
</blockquote>
<p><b><a href="syntaxdiagrams.html#table-or-subquery">table-or-subquery:</a></b>
<button id='x1167' onclick='hideorshow("x1167","x1168")'>show</button></p>
 <blockquote id='x1168' style='display:none;'>
 <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
</blockquote>
</blockquote>
</blockquote>


<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
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
     of the compound select, and nowhere else.
</ol>

<p>To put it another way, a recursive common table expression must
look like the following:

<p><b><a href="syntaxdiagrams.html#recursive-cte">recursive-cte:</a></b>
<button id='x1153' onclick='hideorshow("x1153","x1154")'>hide</button></p>
 <blockquote id='x1154'>
 <img alt="syntax diagram recursive-cte" src="images/syntax/recursive-cte.gif" />
<p><b><a href="syntaxdiagrams.html#cte-table-name">cte-table-name:</a></b>
<button id='x1155' onclick='hideorshow("x1155","x1156")'>show</button></p>
 <blockquote id='x1156' style='display:none;'>
 <img alt="syntax diagram cte-table-name" src="images/syntax/cte-table-name.gif" />
</blockquote>
</blockquote>


<p>We refer to the table named by the cte-table-name in a recursive
common table expression as the "recursive table".







|
|


|
|







258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
     of the compound select, and nowhere else.
</ol>

<p>To put it another way, a recursive common table expression must
look like the following:

<p><b><a href="syntaxdiagrams.html#recursive-cte">recursive-cte:</a></b>
<button id='x1169' onclick='hideorshow("x1169","x1170")'>hide</button></p>
 <blockquote id='x1170'>
 <img alt="syntax diagram recursive-cte" src="images/syntax/recursive-cte.gif" />
<p><b><a href="syntaxdiagrams.html#cte-table-name">cte-table-name:</a></b>
<button id='x1171' onclick='hideorshow("x1171","x1172")'>show</button></p>
 <blockquote id='x1172' style='display:none;'>
 <img alt="syntax diagram cte-table-name" src="images/syntax/cte-table-name.gif" />
</blockquote>
</blockquote>


<p>We refer to the table named by the cte-table-name in a recursive
common table expression as the "recursive table".
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579

<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.name=under_alice.boss
     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)







|







570
571
572
573
574
575
576
577
578
579
580
581
582
583
584

<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)
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609

<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.name=under_alice.boss
     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:








|







600
601
602
603
604
605
606
607
608
609
610
611
612
613
614

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

657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
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 into an SQLite <a href="sqlite.html">command-line shell</a> results
in the following output:

<blockquote><pre>
                                    ....#
                                   ..#*..
                                 ..+####+.
                            .......+####....   +







|







662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
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>
                                    ....#
                                   ..#*..
                                 ..+####+.
                            .......+####....   +
Changes to Doc/Extra/Core/pragma.html.
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
opportunity to add new PRAGMA statements or to override the meaning of
built-in PRAGMA statements.</p>


<hr /><a name="syntax"></a>
<h2>PRAGMA command syntax</h2>
<p><b><a href="syntaxdiagrams.html#pragma-stmt">pragma-stmt:</a></b>
<button id='x1451' onclick='hideorshow("x1451","x1452")'>hide</button></p>
 <blockquote id='x1452'>
 <img alt="syntax diagram pragma-stmt" src="images/syntax/pragma-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#pragma-value">pragma-value:</a></b>
<button id='x1453' onclick='hideorshow("x1453","x1454")'>hide</button></p>
 <blockquote id='x1454'>
 <img alt="syntax diagram pragma-value" src="images/syntax/pragma-value.gif" />
<p><b><a href="syntaxdiagrams.html#signed-number">signed-number:</a></b>
<button id='x1455' onclick='hideorshow("x1455","x1456")'>show</button></p>
 <blockquote id='x1456' style='display:none;'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</blockquote>
</blockquote>
</blockquote>


<p>







|
|


|
|


|
|







163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
opportunity to add new PRAGMA statements or to override the meaning of
built-in PRAGMA statements.</p>


<hr /><a name="syntax"></a>
<h2>PRAGMA command syntax</h2>
<p><b><a href="syntaxdiagrams.html#pragma-stmt">pragma-stmt:</a></b>
<button id='x1467' onclick='hideorshow("x1467","x1468")'>hide</button></p>
 <blockquote id='x1468'>
 <img alt="syntax diagram pragma-stmt" src="images/syntax/pragma-stmt.gif" />
<p><b><a href="syntaxdiagrams.html#pragma-value">pragma-value:</a></b>
<button id='x1469' onclick='hideorshow("x1469","x1470")'>hide</button></p>
 <blockquote id='x1470'>
 <img alt="syntax diagram pragma-value" src="images/syntax/pragma-value.gif" />
<p><b><a href="syntaxdiagrams.html#signed-number">signed-number:</a></b>
<button id='x1471' onclick='hideorshow("x1471","x1472")'>show</button></p>
 <blockquote id='x1472' style='display:none;'>
 <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
</blockquote>
</blockquote>
</blockquote>


<p>
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
<li><a href="#pragma_recursive_triggers">recursive_triggers</a>
<li><a href="#pragma_reverse_unordered_selects">reverse_unordered_selects</a>
<li><a href="#pragma_schema_version">schema_version</a>
<li><a href="#pragma_secure_delete">secure_delete</a>
<li><a href="#pragma_short_column_names"><s>short_column_names</s></a>&sup1;
<li><a href="#pragma_shrink_memory">shrink_memory</a>
<li><a href="#pragma_soft_heap_limit">soft_heap_limit</a>
<li><a href="#pragma_stats">stats</a>
<li><a href="#pragma_synchronous">synchronous</a>
<li><a href="#pragma_table_info">table_info</a>
<li><a href="#pragma_temp_store">temp_store</a>
<li><a href="#pragma_temp_store_directory"><s>temp_store_directory</s></a>&sup1;
<li><a href="#pragma_schema_version">user_version</a>
<li><a href="#pragma_vdbe_addoptrace"><i>vdbe_addoptrace</i></a>&sup2;
<li><a href="#pragma_vdbe_debug"><i>vdbe_debug</i></a>&sup2;







|







260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
<li><a href="#pragma_recursive_triggers">recursive_triggers</a>
<li><a href="#pragma_reverse_unordered_selects">reverse_unordered_selects</a>
<li><a href="#pragma_schema_version">schema_version</a>
<li><a href="#pragma_secure_delete">secure_delete</a>
<li><a href="#pragma_short_column_names"><s>short_column_names</s></a>&sup1;
<li><a href="#pragma_shrink_memory">shrink_memory</a>
<li><a href="#pragma_soft_heap_limit">soft_heap_limit</a>
<li><a href="#pragma_stats"><i>stats</i></a>&sup3;
<li><a href="#pragma_synchronous">synchronous</a>
<li><a href="#pragma_table_info">table_info</a>
<li><a href="#pragma_temp_store">temp_store</a>
<li><a href="#pragma_temp_store_directory"><s>temp_store_directory</s></a>&sup1;
<li><a href="#pragma_schema_version">user_version</a>
<li><a href="#pragma_vdbe_addoptrace"><i>vdbe_addoptrace</i></a>&sup2;
<li><a href="#pragma_vdbe_debug"><i>vdbe_debug</i></a>&sup2;
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
<p>Notes:
<ol>
<li>Pragmas whose names are marked through in the list above
are deprecated that are maintained for historical compatibility only.
Do not use the deprecated pragmas in new applications.
Remove deprecated pragmas
from existing applications at your earliest opportunity.</blockquote>
<li>These pragmas are used for debugging SQLite itself and
are only available when SQLite is compiled using <a href="compile.html#debug">SQLITE_DEBUG</a>.</ol></p>


<a name="pragma_application_id"></a>
<hr>
    <p><b>PRAGMA application_id;
       <br>PRAGMA application_id = </b><i>integer </i><b>;</b>
  
<p>    The application_id PRAGMA is used to query or set the 32-bit
       unsigned 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="whentouse.html#appfileformat">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
       <a href="http://www.sqlite.org/src/artifact?ci=trunk&filename=magic.txt">magic.txt</a> file in the SQLite source repository.
<a name="pragma_auto_vacuum"></a>
<hr>







|
|
>
>








|







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
<p>Notes:
<ol>
<li>Pragmas whose names are marked through in the list above
are deprecated that are maintained for historical compatibility only.
Do not use the deprecated pragmas in new applications.
Remove deprecated pragmas
from existing applications at your earliest opportunity.</blockquote>
<li>These pragmas are used for debugging SQLite and
are only available when SQLite is compiled using <a href="compile.html#debug">SQLITE_DEBUG</a>.
<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>
<hr>
    <p><b>PRAGMA application_id;
       <br>PRAGMA application_id = </b><i>integer </i><b>;</b>
  
<p>    The application_id PRAGMA is used to query or set the 32-bit
       unsigned 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
       <a href="http://www.sqlite.org/src/artifact?ci=trunk&filename=magic.txt">magic.txt</a> file in the SQLite source repository.
<a name="pragma_auto_vacuum"></a>
<hr>
371
372
373
374
375
376
377




378
379
380
381
382
383
384
    <p><b>PRAGMA busy_timeout;
         <br>PRAGMA busy_timeout = </b><i>milliseconds</i><b>;</b></p>
    <p>Query or change the setting of the
    <a href="c3ref/busy_timeout.html">busy timeout</a>.
    This pragma is an alternative to the <a href="c3ref/busy_timeout.html">sqlite3_busy_timeout()</a> C-language
    interface which is made available as a pragma for use with language
    bindings that do not provide direct access to <a href="c3ref/busy_timeout.html">sqlite3_busy_timeout()</a>.




<a name="pragma_cache_size"></a>
<hr>
    <p><b>PRAGMA cache_size;
       <br>PRAGMA cache_size = </b><i>pages</i><b>;
       <br>PRAGMA cache_size = -</b><i>kibibytes</i><b>;</b></p>
    <p>Query or change the suggested maximum number of database disk pages
    that SQLite will hold in memory at once per open database file.  Whether







>
>
>
>







373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
    <p><b>PRAGMA busy_timeout;
         <br>PRAGMA busy_timeout = </b><i>milliseconds</i><b>;</b></p>
    <p>Query or change the setting of the
    <a href="c3ref/busy_timeout.html">busy timeout</a>.
    This pragma is an alternative to the <a href="c3ref/busy_timeout.html">sqlite3_busy_timeout()</a> C-language
    interface which is made available as a pragma for use with language
    bindings that do not provide direct access to <a href="c3ref/busy_timeout.html">sqlite3_busy_timeout()</a>.

    <p>Each database connection can only have a single
    <a href="c3ref/busy_handler.html">busy handler</a>.  This PRAGMA sets the busy handler
    for the process, possibly overwriting any previously set busy handler.
<a name="pragma_cache_size"></a>
<hr>
    <p><b>PRAGMA cache_size;
       <br>PRAGMA cache_size = </b><i>pages</i><b>;
       <br>PRAGMA cache_size = -</b><i>kibibytes</i><b>;</b></p>
    <p>Query or change the suggested maximum number of database disk pages
    that SQLite will hold in memory at once per open database file.  Whether
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
       enforcement may only be enabled or disabled when there is no pending
       <a href="lang_transaction.html">BEGIN</a> or <a href="lang_savepoint.html">SAVEPOINT</a>.

    <p>Changing the foreign_keys setting affects the execution of
       all statements prepared
       using the database connection, including those prepared before the
       setting was changed. Any existing statements prepared using the legacy 
       <a href="c3ref/prepare.html">sqlite3_prepare()</a> interface may fail with an <a href="c3ref/c_abort.html">SQLITE_SCHEMA</a> error
       after the foreign_keys setting is changed.

    <p>As of SQLite <a href="releaselog/3_6_19.html">version 3.6.19</a>, the default setting for foreign
       key enforcement is OFF.  However, that might change in a future
       release of SQLite.  The default setting for foreign key enforcement
       can be specified at compile-time using the <a href="compile.html#default_foreign_keys">SQLITE_DEFAULT_FOREIGN_KEYS</a>
       preprocessor macro.  To minimize future problems, applications should







|







666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
       enforcement may only be enabled or disabled when there is no pending
       <a href="lang_transaction.html">BEGIN</a> or <a href="lang_savepoint.html">SAVEPOINT</a>.

    <p>Changing the foreign_keys setting affects the execution of
       all statements prepared
       using the database connection, including those prepared before the
       setting was changed. Any existing statements prepared using the legacy 
       <a href="c3ref/prepare.html">sqlite3_prepare()</a> interface may fail with an <a href="rescode.html#schema">SQLITE_SCHEMA</a> error
       after the foreign_keys setting is changed.

    <p>As of SQLite <a href="releaselog/3_6_19.html">version 3.6.19</a>, the default setting for foreign
       key enforcement is OFF.  However, that might change in a future
       release of SQLite.  The default setting for foreign key enforcement
       can be specified at compile-time using the <a href="compile.html#default_foreign_keys">SQLITE_DEFAULT_FOREIGN_KEYS</a>
       preprocessor macro.  To minimize future problems, applications should
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772








773
774
775
776
777
778
779
    </p>
<a name="pragma_integrity_check"></a>
<hr>
    <p><b>PRAGMA integrity_check;
    <br>PRAGMA integrity_check(</b><i>N</i><b>)</b></p>
    <p>This pragma does an integrity check of the entire database.  The
    integrity_check pragma
    looks for out-of-order records, missing pages, malformed records, and
    corrupt indices.
    If the integrity_check pragma finds problems, strings are returned
    (as multiple rows with a single column per row) which describe
    the problems.  Pragma integrity_check will return at most <i>N</i>
    errors will be reported before the analysis quits, with N defaulting
    to 100.  If pragma integrity_check finds no errors are found, a
    single row with the value 'ok' is returned.</p>








<a name="pragma_journal_mode"></a>
<hr>
    <p><b>PRAGMA journal_mode;
       <br>PRAGMA </b><i>database</i><b>.journal_mode;
       <br>PRAGMA journal_mode
              = <i>DELETE | TRUNCATE | PERSIST | MEMORY | WAL | OFF</i>
       <br>PRAGMA </b><i>database</i><b>.journal_mode







|
|



|
|

>
>
>
>
>
>
>
>







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
    </p>
<a name="pragma_integrity_check"></a>
<hr>
    <p><b>PRAGMA integrity_check;
    <br>PRAGMA integrity_check(</b><i>N</i><b>)</b></p>
    <p>This pragma does an integrity check of the entire database.  The
    integrity_check pragma
    looks for out-of-order records, missing pages, malformed records, missing
    index entries, and UNIQUE and NOT NULL constraint errors.
    If the integrity_check pragma finds problems, strings are returned
    (as multiple rows with a single column per row) which describe
    the problems.  Pragma integrity_check will return at most <i>N</i>
    errors before the analysis quits, with N defaulting
    to 100.  If pragma integrity_check finds no errors, a
    single row with the value 'ok' is returned.</p>

    <p>PRAGMA integrity_check does not find
    <a href="foreignkeys.html">FOREIGN KEY</a> errors.  
    Use the <a href="pragma.html#pragma_foreign_key_check">PRAGMA foreign_key_check</a> command for to find errors in
    FOREIGN KEY constraints.</p>

    <p>See also the <a href="pragma.html#pragma_quick_check">PRAGMA quick_check</a> command which does most of the
    checking of PRAGMA integrity_check but runs much faster.</p>
<a name="pragma_journal_mode"></a>
<hr>
    <p><b>PRAGMA journal_mode;
       <br>PRAGMA </b><i>database</i><b>.journal_mode;
       <br>PRAGMA journal_mode
              = <i>DELETE | TRUNCATE | PERSIST | MEMORY | WAL | OFF</i>
       <br>PRAGMA </b><i>database</i><b>.journal_mode
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
    option, then the parser_trace pragma can be used to turn on tracing
    for the SQL parser used internally by SQLite.
    This feature is used for debugging SQLite itself.</p>

    
    <p style='background-color: #f0e0ff;'>
    This pragma is intended for use when debugging SQLite itself.  It
    is only contained in the build when the <a href="compile.html#debug">SQLITE_DEBUG</a> compile-time option
    is used.</p>
  
<a name="pragma_query_only"></a>
<hr>
    <p><b>PRAGMA query_only;
       <br>PRAGMA query_only = </b><i>boolean</i><b>;</b></p>

    <p>The query_only pragma prevents all changes to database files when
    enabled.</p>
<a name="pragma_quick_check"></a>
<hr>
    <p><b>PRAGMA quick_check;
    <br>PRAGMA quick_check(</b><i>N</i><b>)</b></p>
    <p>The pragma is like <a href="pragma.html#pragma_integrity_check">integrity_check</a> except that it does not verify

    that index content matches table content.  By skipping the verification
    of index content, quick_check is able to run much faster than
    integrity_check.  Otherwise the two pragmas are the same.
    </p>
<a name="pragma_read_uncommitted"></a>
<hr>
    <p><b>PRAGMA read_uncommitted;
       <br>PRAGMA read_uncommitted = </b><i>boolean</i><b>;</b></p>
    <p>Query, set, or clear READ UNCOMMITTED isolation. The default isolation







|














>
|
|







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
    option, then the parser_trace pragma can be used to turn on tracing
    for the SQL parser used internally by SQLite.
    This feature is used for debugging SQLite itself.</p>

    
    <p style='background-color: #f0e0ff;'>
    This pragma is intended for use when debugging SQLite itself.  It
    is only available when the <a href="compile.html#debug">SQLITE_DEBUG</a> compile-time option
    is used.</p>
  
<a name="pragma_query_only"></a>
<hr>
    <p><b>PRAGMA query_only;
       <br>PRAGMA query_only = </b><i>boolean</i><b>;</b></p>

    <p>The query_only pragma prevents all changes to database files when
    enabled.</p>
<a name="pragma_quick_check"></a>
<hr>
    <p><b>PRAGMA quick_check;
    <br>PRAGMA quick_check(</b><i>N</i><b>)</b></p>
    <p>The pragma is like <a href="pragma.html#pragma_integrity_check">integrity_check</a> except that it does not verify
    UNIQUE and NOT NULL constraints and does not verify
    that index content matches table content.  By skipping UNIQUE and NOT NULL
    and index consistency checks, quick_check is able to run much faster than
    integrity_check.  Otherwise the two pragmas are the same.
    </p>
<a name="pragma_read_uncommitted"></a>
<hr>
    <p><b>PRAGMA read_uncommitted;
       <br>PRAGMA read_uncommitted = </b><i>boolean</i><b>;</b></p>
    <p>Query, set, or clear READ UNCOMMITTED isolation. The default isolation
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
       <br>PRAGMA recursive_triggers = </b><i>boolean</i><b>;</b></p>
    <p>Query, set, or clear the recursive trigger capability.

    <p>Changing the recursive_triggers setting affects the execution of
       all statements prepared
       using the database connection, including those prepared before the
       setting was changed. Any existing statements prepared using the legacy 
       <a href="c3ref/prepare.html">sqlite3_prepare()</a> interface may fail with an <a href="c3ref/c_abort.html">SQLITE_SCHEMA</a> error
       after the recursive_triggers setting is changed.

    <p>Prior to SQLite version 3.6.18, recursive triggers were not
    supported.  The behavior of SQLite was always as if this pragma was
    set to OFF.  Support for recursive triggers was added in version 3.6.18
    but was initially turned OFF by default, for compatibility.  Recursive
    triggers may be turned on by default in future versions of SQLite.







|







1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
       <br>PRAGMA recursive_triggers = </b><i>boolean</i><b>;</b></p>
    <p>Query, set, or clear the recursive trigger capability.

    <p>Changing the recursive_triggers setting affects the execution of
       all statements prepared
       using the database connection, including those prepared before the
       setting was changed. Any existing statements prepared using the legacy 
       <a href="c3ref/prepare.html">sqlite3_prepare()</a> interface may fail with an <a href="rescode.html#schema">SQLITE_SCHEMA</a> error
       after the recursive_triggers setting is changed.

    <p>Prior to SQLite version 3.6.18, recursive triggers were not
    supported.  The behavior of SQLite was always as if this pragma was
    set to OFF.  Support for recursive triggers was added in version 3.6.18
    but was initially turned OFF by default, for compatibility.  Recursive
    triggers may be turned on by default in future versions of SQLite.
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251





1252
1253
1254
1255
1256
1257
1258
<hr>
    <p><b>PRAGMA stats;</b> </p>
    <p>This pragma returns auxiliary information about tables and
    indices.  The returned information is used during testing to help
    verify that the query planner is operating correctly.  The format
    and meaning of this pragma will likely change from release
    to the next. Because of its volatility, the behavior and output
    format of this pragma are deliberately undocumented.  This pragma is
    intended for interactive, debugging, and testing use only.
    Applications should avoid using this pragma.</p>





<a name="pragma_synchronous"></a>
<hr>
    <p><b>PRAGMA synchronous;
       <br>PRAGMA synchronous = </b>
          <i>0 | OFF | 1 | NORMAL | 2 | FULL</i><b>;</b></p>

    <p>Query or change the setting of the "synchronous" flag.







|
|
|
>
>
>
>
>







1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
<hr>
    <p><b>PRAGMA stats;</b> </p>
    <p>This pragma returns auxiliary information about tables and
    indices.  The returned information is used during testing to help
    verify that the query planner is operating correctly.  The format
    and meaning of this pragma will likely change from release
    to the next. Because of its volatility, the behavior and output
    format of this pragma are deliberately undocumented.</p>

    
    <p style='background-color: #f0e0ff;'>
    The intended use of this pragma is only for testing and validation of
    SQLite.  This pragma is subject to change without notice and is not
    recommended for use by application programs.</p>
  
<a name="pragma_synchronous"></a>
<hr>
    <p><b>PRAGMA synchronous;
       <br>PRAGMA synchronous = </b>
          <i>0 | OFF | 1 | NORMAL | 2 | FULL</i><b>;</b></p>

    <p>Query or change the setting of the "synchronous" flag.
1301
1302
1303
1304
1305
1306
1307

1308
1309
1310
1311
1312
1313
1314
    <p>This pragma returns one row for each column in the named table.
    Columns in the result set include the column name,
    data type, whether or not the column can be NULL, and the default
    value for the column.  The "pk" column in the result set is zero
    for columns that are not part of the primary key, and is the index of
    the column in the primary key for columns that are part of the primary
    key.</p>

<a name="pragma_temp_store"></a>
<hr>
    <p><b>PRAGMA temp_store;
       <br>PRAGMA temp_store = </b>
            <i>0 | DEFAULT | 1 | FILE | 2 | MEMORY</i><b>;</b></p>

    <p>Query or change the setting of the "<b>temp_store</b>" parameter.







>







1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
    <p>This pragma returns one row for each column in the named table.
    Columns in the result set include the column name,
    data type, whether or not the column can be NULL, and the default
    value for the column.  The "pk" column in the result set is zero
    for columns that are not part of the primary key, and is the index of
    the column in the primary key for columns that are part of the primary
    key.</p>
    <p>The table named in the table_info pragma can also be a view.</p>
<a name="pragma_temp_store"></a>
<hr>
    <p><b>PRAGMA temp_store;
       <br>PRAGMA temp_store = </b>
            <i>0 | DEFAULT | 1 | FILE | 2 | MEMORY</i><b>;</b></p>

    <p>Query or change the setting of the "<b>temp_store</b>" parameter.
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494

1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513



1514
1515
1516
1517





1518





















1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
    This feature is used for debugging SQLite itself.  See the 
    <a href="vdbe.html#trace">VDBE documentation</a> for more 
    information.</p>

    
    <p style='background-color: #f0e0ff;'>
    This pragma is intended for use when debugging SQLite itself.  It
    is only contained in the build when the <a href="compile.html#debug">SQLITE_DEBUG</a> compile-time option
    is used.</p>
  
<a name="pragma_vdbe_debug"></a>
<hr>
    <p><b>PRAGMA vdbe_debug = </b><i>boolean</i><b>;</b></p>

    <p>If SQLite has been compiled with the <a href="compile.html#debug">SQLITE_DEBUG</a> compile-time
    option, then the vdbe_debug pragma is a shorthand for three other
    debug-only pragmas: vdbe_addoptrace, vdbe_listing, and vdbe_trace.
    This feature is used for debugging SQLite itself.  See the 
    <a href="vdbe.html#trace">VDBE documentation</a> for more 
    information.</p>

    
    <p style='background-color: #f0e0ff;'>
    This pragma is intended for use when debugging SQLite itself.  It
    is only contained in the build when the <a href="compile.html#debug">SQLITE_DEBUG</a> compile-time option
    is used.</p>
  
<a name="pragma_vdbe_listing"></a>
<hr>
    <p><b>PRAGMA vdbe_listing = </b><i>boolean</i><b>;</b></p>

    <p>If SQLite has been compiled with the <a href="compile.html#debug">SQLITE_DEBUG</a> compile-time
    option, then the vdbe_listing pragma can be used to cause a complete
    listing of the virtual machine opcodes to appear on standard output
    as each statement is evaluated.
    With listing is on, the entire content of a program is printed
    just prior to beginning execution.  The statement
    executes normally after the listing is printed.
    This feature is used for debugging SQLite itself.  See the 
    <a href="vdbe.html#trace">VDBE documentation</a> for more 
    information.</p>

    
    <p style='background-color: #f0e0ff;'>
    This pragma is intended for use when debugging SQLite itself.  It
    is only contained in the build when the <a href="compile.html#debug">SQLITE_DEBUG</a> compile-time option
    is used.</p>
  
<a name="pragma_vdbe_trace"></a>
<hr>
    <p><b>PRAGMA vdbe_trace = </b><i>boolean</i><b>;</b></p>

    <p>If SQLite has been compiled with the <a href="compile.html#debug">SQLITE_DEBUG</a> compile-time
    option, then the vdbe_trace pragma can be used to cause virtual machine
    opcodes to be printed on standard output as they are evaluated.
    This feature is used for debugging SQLite.  See the 
    <a href="vdbe.html#trace">VDBE documentation</a> for more 
    information.</p>

    
    <p style='background-color: #f0e0ff;'>
    This pragma is intended for use when debugging SQLite itself.  It
    is only contained in the build when the <a href="compile.html#debug">SQLITE_DEBUG</a> compile-time option
    is used.</p>
  
<a name="pragma_wal_autocheckpoint"></a>
<hr>
    <p><b>PRAGMA wal_autocheckpoint;<br>
     PRAGMA wal_autocheckpoint=</b><i>N</i><b>;</b></p>

    <p>This pragma queries or sets the <a href="wal.html">write-ahead log</a> 
    <a href="wal.html#ckpt">auto-checkpoint</a> interval.
    When the <a href="wal.html">write-ahead log</a> is enabled (via the
    <a href="pragma.html#pragma_journal_mode">journal_mode pragma</a>) a checkpoint will be run automatically whenever
    the write-ahead log equals or exceeds <i>N</i> pages in length.
    Setting the auto-checkpoint size to zero or a negative value
    turns auto-checkpointing off.</p>
    
    <p>This pragma is a wrapper around the
    <a href="c3ref/wal_autocheckpoint.html">sqlite3_wal_autocheckpoint()</a> C interface.</p>


    <p>Autocheckpointing is enabled by default with an interval
    of 1000 or <a href="compile.html#default_wal_autocheckpoint">SQLITE_DEFAULT_WAL_AUTOCHECKPOINT</a>.</p>

<a name="pragma_wal_checkpoint"></a>
<hr>
    <p><b>PRAGMA </b><i>database</i><b>.wal_checkpoint;</b><br>
    <b>PRAGMA </b><i>database</i><b>.wal_checkpoint(PASSIVE);</b><br>
    <b>PRAGMA </b><i>database</i><b>.wal_checkpoint(FULL);</b><br>
    <b>PRAGMA </b><i>database</i><b>.wal_checkpoint(RESTART);</b>
   </p>

    <p>If the <a href="wal.html">write-ahead log</a> is enabled (via the <a href="pragma.html#pragma_journal_mode">journal_mode pragma</a>),
    this pragma causes a <a href="wal.html#ckpt">checkpoint</a> operation to run on database
    <i>database</i>, or on all attached databases if <i>database</i>
    is omitted.  If <a href="wal.html">write-ahead log</a> mode is disabled, this pragma is a
    harmless no-op.</p>

    <p>Invoking this pragma is equivalent to calling the



    <a href="c3ref/wal_checkpoint_v2.html">sqlite3_wal_checkpoint_v2()</a> C interface with a 
    <a href="c3ref/c_checkpoint_full.html">3rd parameter</a>
    corresponding to the argument of the PRAGMA.  Invoking this
    pragma without an argument is equivalent to calling the





    <a href="c3ref/wal_checkpoint.html">sqlite3_wal_checkpoint()</a> C interface.</p>






















    <p>The wal_checkpoint pragma returns a single row with three
    integer columns.  The first column is usually 0 but will be
    1 if a RESTART or FULL checkpoint was blocked from completing,
    for example because another thread or process was actively
    using the database.  In other words, the first column is 0 if the
    equivalent call to <a href="c3ref/wal_checkpoint_v2.html">sqlite3_wal_checkpoint_v2()</a> would have returned
    <a href="c3ref/c_abort.html">SQLITE_OK</a> or 1 if the equivalent call would have returned <a href="c3ref/c_abort.html">SQLITE_BUSY</a>.
    The second column is the number of modified pages that have been
    written to the write-ahead log file.
    The third column is the number of pages in the write-ahead log file
    that have been successfully moved back into the database file at
    the conclusion of the checkpoint.
   The second and third column are -1 if there is no
    write-ahead log, for example if this pragma is invoked on a database







|
















|




















|
















|
















|
>


















|
>
>
>


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







|







1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
    This feature is used for debugging SQLite itself.  See the 
    <a href="vdbe.html#trace">VDBE documentation</a> for more 
    information.</p>

    
    <p style='background-color: #f0e0ff;'>
    This pragma is intended for use when debugging SQLite itself.  It
    is only available when the <a href="compile.html#debug">SQLITE_DEBUG</a> compile-time option
    is used.</p>
  
<a name="pragma_vdbe_debug"></a>
<hr>
    <p><b>PRAGMA vdbe_debug = </b><i>boolean</i><b>;</b></p>

    <p>If SQLite has been compiled with the <a href="compile.html#debug">SQLITE_DEBUG</a> compile-time
    option, then the vdbe_debug pragma is a shorthand for three other
    debug-only pragmas: vdbe_addoptrace, vdbe_listing, and vdbe_trace.
    This feature is used for debugging SQLite itself.  See the 
    <a href="vdbe.html#trace">VDBE documentation</a> for more 
    information.</p>

    
    <p style='background-color: #f0e0ff;'>
    This pragma is intended for use when debugging SQLite itself.  It
    is only available when the <a href="compile.html#debug">SQLITE_DEBUG</a> compile-time option
    is used.</p>
  
<a name="pragma_vdbe_listing"></a>
<hr>
    <p><b>PRAGMA vdbe_listing = </b><i>boolean</i><b>;</b></p>

    <p>If SQLite has been compiled with the <a href="compile.html#debug">SQLITE_DEBUG</a> compile-time
    option, then the vdbe_listing pragma can be used to cause a complete
    listing of the virtual machine opcodes to appear on standard output
    as each statement is evaluated.
    With listing is on, the entire content of a program is printed
    just prior to beginning execution.  The statement
    executes normally after the listing is printed.
    This feature is used for debugging SQLite itself.  See the 
    <a href="vdbe.html#trace">VDBE documentation</a> for more 
    information.</p>

    
    <p style='background-color: #f0e0ff;'>
    This pragma is intended for use when debugging SQLite itself.  It
    is only available when the <a href="compile.html#debug">SQLITE_DEBUG</a> compile-time option
    is used.</p>
  
<a name="pragma_vdbe_trace"></a>
<hr>
    <p><b>PRAGMA vdbe_trace = </b><i>boolean</i><b>;</b></p>

    <p>If SQLite has been compiled with the <a href="compile.html#debug">SQLITE_DEBUG</a> compile-time
    option, then the vdbe_trace pragma can be used to cause virtual machine
    opcodes to be printed on standard output as they are evaluated.
    This feature is used for debugging SQLite.  See the 
    <a href="vdbe.html#trace">VDBE documentation</a> for more 
    information.</p>

    
    <p style='background-color: #f0e0ff;'>
    This pragma is intended for use when debugging SQLite itself.  It
    is only available when the <a href="compile.html#debug">SQLITE_DEBUG</a> compile-time option
    is used.</p>
  
<a name="pragma_wal_autocheckpoint"></a>
<hr>
    <p><b>PRAGMA wal_autocheckpoint;<br>
     PRAGMA wal_autocheckpoint=</b><i>N</i><b>;</b></p>

    <p>This pragma queries or sets the <a href="wal.html">write-ahead log</a> 
    <a href="wal.html#ckpt">auto-checkpoint</a> interval.
    When the <a href="wal.html">write-ahead log</a> is enabled (via the
    <a href="pragma.html#pragma_journal_mode">journal_mode pragma</a>) a checkpoint will be run automatically whenever
    the write-ahead log equals or exceeds <i>N</i> pages in length.
    Setting the auto-checkpoint size to zero or a negative value
    turns auto-checkpointing off.</p>
    
    <p>This pragma is a wrapper around the
    <a href="c3ref/wal_autocheckpoint.html">sqlite3_wal_autocheckpoint()</a> C interface.
    All automatic checkpoints are <a href="c3ref/wal_checkpoint_v2.html">PASSIVE</a>.</p>

    <p>Autocheckpointing is enabled by default with an interval
    of 1000 or <a href="compile.html#default_wal_autocheckpoint">SQLITE_DEFAULT_WAL_AUTOCHECKPOINT</a>.</p>

<a name="pragma_wal_checkpoint"></a>
<hr>
    <p><b>PRAGMA </b><i>database</i><b>.wal_checkpoint;</b><br>
    <b>PRAGMA </b><i>database</i><b>.wal_checkpoint(PASSIVE);</b><br>
    <b>PRAGMA </b><i>database</i><b>.wal_checkpoint(FULL);</b><br>
    <b>PRAGMA </b><i>database</i><b>.wal_checkpoint(RESTART);</b>
   </p>

    <p>If the <a href="wal.html">write-ahead log</a> is enabled (via the <a href="pragma.html#pragma_journal_mode">journal_mode pragma</a>),
    this pragma causes a <a href="wal.html#ckpt">checkpoint</a> operation to run on database
    <i>database</i>, or on all attached databases if <i>database</i>
    is omitted.  If <a href="wal.html">write-ahead log</a> mode is disabled, this pragma is a
    harmless no-op.</p>

    <p>Invoking this
    pragma without an argument is equivalent to calling the
    <a href="c3ref/wal_checkpoint.html">sqlite3_wal_checkpoint()</a> C interface.</p>
    Invoking this pragma with an argument is equivalent to calling the
    <a href="c3ref/wal_checkpoint_v2.html">sqlite3_wal_checkpoint_v2()</a> C interface with a 
    <a href="c3ref/c_checkpoint_full.html">3rd parameter</a>
    corresponding to the argument:

    <dl>
    <dt>PASSIVE<dd>
      Checkpoint as many frames as possible without waiting for any database 
      readers or writers to finish. Sync the db file if all frames in the log
      are checkpointed. This mode is the same as calling 
      sqlite3_wal_checkpoint(). The
      <a href="c3ref/busy_handler.html">busy-handler callback</a> is never invoked.
   
    <dt>FULL<dd>
      This mode blocks 
      (invokes the <a href="c3ref/busy_handler.html">busy-handler callback</a>)
      until there is no
      database writer and all readers are reading from the most recent database
      snapshot. It then checkpoints all frames in the log file and syncs the
      database file. FULL blocks database writers while it is
      running, but not database readers.
   
    <dt>RESTART<dd>
      This mode works the same way as SQLITE_CHECKPOINT_FULL, except after 
      checkpointing the log file it blocks (calls the 
      <a href="c3ref/busy_handler.html">busy-handler callback</a>)
      until all readers are reading from the database file only. This ensures 
      that the next client to write to the database file restarts the log file 
      from the beginning. RESTART blocks database writers while it is
      running, but not database readers.
    </dl>


    <p>The wal_checkpoint pragma returns a single row with three
    integer columns.  The first column is usually 0 but will be
    1 if a RESTART or FULL checkpoint was blocked from completing,
    for example because another thread or process was actively
    using the database.  In other words, the first column is 0 if the
    equivalent call to <a href="c3ref/wal_checkpoint_v2.html">sqlite3_wal_checkpoint_v2()</a> would have returned
    <a href="rescode.html#ok">SQLITE_OK</a> or 1 if the equivalent call would have returned <a href="rescode.html#busy">SQLITE_BUSY</a>.
    The second column is the number of modified pages that have been
    written to the write-ahead log file.
    The third column is the number of pages in the write-ahead log file
    that have been successfully moved back into the database file at
    the conclusion of the checkpoint.
   The second and third column are -1 if there is no
    write-ahead log, for example if this pragma is invoked on a database
Changes to Doc/Extra/Core/syntaxdiagrams.html.
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
Used by:&nbsp;&nbsp; <a href="#sql-stmt">sql-stmt</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_transaction.html">lang_transaction.html</a>
</blockquote>

<a name="commit-stmt"></a>
<h4>commit-stmt:</h4><blockquote>
<img src="images/syntax/commit-stmt.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#sql-stmt">sql-stmt</a>

</blockquote>

<a name="rollback-stmt"></a>
<h4>rollback-stmt:</h4><blockquote>
<img src="images/syntax/rollback-stmt.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#sql-stmt">sql-stmt</a>

</blockquote>

<a name="savepoint-stmt"></a>
<h4>savepoint-stmt:</h4><blockquote>
<img src="images/syntax/savepoint-stmt.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#sql-stmt">sql-stmt</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_savepoint.html">lang_savepoint.html</a>
</blockquote>

<a name="release-stmt"></a>
<h4>release-stmt:</h4><blockquote>
<img src="images/syntax/release-stmt.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#sql-stmt">sql-stmt</a>

</blockquote>

<a name="create-index-stmt"></a>
<h4>create-index-stmt:</h4><blockquote>
<img src="images/syntax/create-index-stmt.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#sql-stmt">sql-stmt</a><br></br>
References:&nbsp;&nbsp; <a href="#expr">expr</a>&nbsp;&nbsp; <a href="#indexed-column">indexed-column</a><br></br>







|
>





|
>












|
>







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
Used by:&nbsp;&nbsp; <a href="#sql-stmt">sql-stmt</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_transaction.html">lang_transaction.html</a>
</blockquote>

<a name="commit-stmt"></a>
<h4>commit-stmt:</h4><blockquote>
<img src="images/syntax/commit-stmt.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#sql-stmt">sql-stmt</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_transaction.html">lang_transaction.html</a>
</blockquote>

<a name="rollback-stmt"></a>
<h4>rollback-stmt:</h4><blockquote>
<img src="images/syntax/rollback-stmt.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#sql-stmt">sql-stmt</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_savepoint.html">lang_savepoint.html</a>&nbsp;&nbsp; <a href="lang_transaction.html">lang_transaction.html</a>
</blockquote>

<a name="savepoint-stmt"></a>
<h4>savepoint-stmt:</h4><blockquote>
<img src="images/syntax/savepoint-stmt.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#sql-stmt">sql-stmt</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_savepoint.html">lang_savepoint.html</a>
</blockquote>

<a name="release-stmt"></a>
<h4>release-stmt:</h4><blockquote>
<img src="images/syntax/release-stmt.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#sql-stmt">sql-stmt</a><br></br>
See also:&nbsp;&nbsp; <a href="lang_savepoint.html">lang_savepoint.html</a>
</blockquote>

<a name="create-index-stmt"></a>
<h4>create-index-stmt:</h4><blockquote>
<img src="images/syntax/create-index-stmt.gif"></img><br></br>
Used by:&nbsp;&nbsp; <a href="#sql-stmt">sql-stmt</a><br></br>
References:&nbsp;&nbsp; <a href="#expr">expr</a>&nbsp;&nbsp; <a href="#indexed-column">indexed-column</a><br></br>
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
See also:&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>
</blockquote>

<a name="raise-function"></a>
<h4>raise-function:</h4><blockquote>
<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_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#undef_before">lang_createtrigger.html#undef_before</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>
</blockquote>

<a name="literal-value"></a>
<h4>literal-value:</h4><blockquote>
<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_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>







|







394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
See also:&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>
</blockquote>

<a name="raise-function"></a>
<h4>raise-function:</h4><blockquote>
<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_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>
</blockquote>

<a name="literal-value"></a>
<h4>literal-value:</h4><blockquote>
<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_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>