Documentation Source Text

Check-in [b45c611781]
Login

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

Overview
Comment:Continuing work on syntax requirements. This is just an incremental check-in.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: b45c611781a8afef53915e7ac79ef0fd691a0587
User & Date: drh 2008-08-08 15:46:56
Context
2008-08-09
00:01
Continuing work on syntax requirements. check-in: ce20876314 user: drh tags: trunk
2008-08-08
15:46
Continuing work on syntax requirements. This is just an incremental check-in. check-in: b45c611781 user: drh tags: trunk
2008-08-07
16:31
Add system requirements for ductile behavior. check-in: e56e9ebd70 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to pages/lang.in.

1814
1815
1816
1817
1818
1819
1820

1821
1822
1823
1824
1825
1826
1827
<tcl>
##############################################################################
Section INSERT insert {INSERT INSERTs}

Syntax {sql-statement} {
INSERT [OR <conflict-algorithm>] INTO [<database-name> .] <table-name> [(<column-list>)] VALUES(<value-list>) |
INSERT [OR <conflict-algorithm>] INTO [<database-name> .] <table-name> [(<column-list>)] <select-statement>

}
</tcl>

<p>The INSERT statement comes in two basic forms.  The first form
(with the "VALUES" keyword) creates a single new row in an existing table.
If no column-list is specified then the number of values must
be the same as the number of columns in the table.  If a column-list







>







1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
<tcl>
##############################################################################
Section INSERT insert {INSERT INSERTs}

Syntax {sql-statement} {
INSERT [OR <conflict-algorithm>] INTO [<database-name> .] <table-name> [(<column-list>)] VALUES(<value-list>) |
INSERT [OR <conflict-algorithm>] INTO [<database-name> .] <table-name> [(<column-list>)] <select-statement>
INSERT [OR <conflict-algorithm>] INTO [<database-name> .] <table-name> DEFAULT VALUES
}
</tcl>

<p>The INSERT statement comes in two basic forms.  The first form
(with the "VALUES" keyword) creates a single new row in an existing table.
If no column-list is specified then the number of values must
be the same as the number of columns in the table.  If a column-list

Changes to pages/syntax.in.

1
2




























3
4









5
6
7

















































8























9
10






























11
12
13

























































































































































































































14







15







16







17







18







19




























20







21









22
23







24
25








26
27
28











29
30
31







32







33
34















































35
36
37








38








39








40












41







42







43







44
45






46
47
48









































































49
50
51
52














<title>SQLite SQL Syntax Requirements</title>





























<h1>SQLite Syntax Requirements</h1>










<h2>1.0 Transaction Control</h2>

<h3>1.1 BEGIN</h3>

















































<h3>1.2 COMMIT</h3>























<h3>1.3 ROLLBACK</h3>































<h2>2.0 Data Definition Language (DDL)</h2>

<h3>2.1 CREATE TABLE</h3>

























































































































































































































<h3>2.2 DROP TABLE</h3>







<h3>2.3 CREATE INDEX</h3>







<h3>2.4 DROP INDEX</h3>







<h3>2.5 CREATE VIEW</h3>







<h3>2.6 DROP VIEW</h3>







<h3>2.7 CREATE TRIGGER</h3>




























<h3>2.8 DROP TRIGGER</h3>







<h3>2.9 CREATE VIRTUAL TABLE</h3>









<h3>2.10 ALTER TABLE</h3>
<h4>2.11 ALTER TABLE RENAME</h4>







<h4>2.12 ALTER TABLE ADD COLUMN</h4>









<h2>3.0 Data Manipulation Language (DML)</h2>

<h3>3.1 INSERT</h3>











<h4>3.1.1 INSERT VALUE</h4>
<h4>3.1.2 INSERT SELECT</h4>
<h3>3.2 DELETE</h3>







<h3>3.3 UPDATE</h3>







<h3>3.4 SELECT</h3>
















































<h2>4.0 Other Language Elements</h2>

<h3>4.1 VACUUM</h3>








<h3>4.2 ANALYZE</h3>








<h3>4.3 REINDEX</h3>








<h3>4.4 PRAGMA</h3>












<h3>4.5 ATTACH</h3>







<h3>4.6 DETACH</h3>







<h3>4.7 EXPLAIN</h3>







<h3>4.8 EXPLAIN QUERY PLAN</h3>







<h2>5.0 Common Language Subelements</h2>

<h3>5.1 Expressions</h3>









































































<h3>5.2 Functions</h3>
<h4>5.2.1 Core Scalar Functions</h4>
<h4>5.2.2 Date and Time Functions</h4>
<h4>5.2.3 Aggregate Functions</h4>
















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


>
>
>
>
>
>
>
>
>



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

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


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



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

>
>
>
>
>
>
>

>
>
>
>
>
>
>

>
>
>
>
>
>
>

>
>
>
>
>
>
>

>
>
>
>
>
>
>

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

>
>
>
>
>
>
>

>
>
>
>
>
>
>
>
>


>
>
>
>
>
>
>


>
>
>
>
>
>
>
>



>
>
>
>
>
>
>
>
>
>
>



>
>
>
>
>
>
>

>
>
>
>
>
>
>


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



>
>
>
>
>
>
>
>

>
>
>
>
>
>
>
>

>
>
>
>
>
>
>
>

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

>
>
>
>
>
>
>

>
>
>
>
>
>
>

>
>
>
>
>
>
>


>
>
>
>
>
>



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




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

<tcl>
proc syntaxreq {id derivedfrom explaination text {bnf {}}} {
  hd_fragment $id $id
  set dlist {}
  foreach d $derivedfrom {
    append dlist <$d>
  }
  if {$bnf!=""} {
    regsub -all {\n  } $bnf "\n" bnf
    append text <blockquote><pre>$bnf</pre></blockquote>
  }
  hd_requirement $id $text$dlist
  if {[string length $explaination]} {
    hd_resolve "<p>$explaination</p>"
  }
  hd_puts "<blockquote><b>$id:</b>"
  hd_resolve $text
  hd_puts {</b></blockquote}
}
set syntax_dcnt 0
proc syntaxdef {namelist text} {
  global syntax_dcnt
  incr syntax_dcnt
  eval hd_fragment D$syntax_dcnt $namelist
  hd_resolve "\n<p>$text</p>\n\n"
}
</tcl>

<h1>SQLite Syntax Requirements</h1>

<tcl>
syntaxreq {H42000} {} {} {
  SQLite shall accept SQL statements consisting of an SQL command
  followed by a semicolon.
} {
  sql_statement ::= cmd SEMI.
}
</tcl>

<h2>1.0 Transaction Control</h2>

<h3>1.1 BEGIN</h3>

<tcl>
syntaxreq {H42010} {} {} {
  SQLite shall accept the following BEGIN statement syntax:
} {
  cmd ::= BEGIN transaction_type transaction_name.
  transaction_type ::= .
  transaction_type ::= DEFERRED.
  transaction_type ::= IMMEDIATE.
  transaction_type ::= EXCLUSIVE.
  transaction_name ::= .
  transaction_name ::= TRANSACTION.
  transaction_name ::= TRANSACTION name.
}
syntaxreq {H42013} {} {} {
  The successful evaluation of a BEGIN statement shall
  cause the [database connection] to leave autocommit mode.
}
syntaxreq {H42016} {} {} {
  A BEGIN TRANSACTION statement shall return an error
  if the [database connection] is not in autocommit mode when the 
  statement is launched.
}
syntaxreq {H42019} {} {} {
  If the <i>transaction_type</i> keyword is omitted from a
  BEGIN TRANSACTION statement then the behavior shall be the same
  as if the DEFERRED keyword were used.
}
syntaxreq {H42022} {} {} {
  When the DEFERRED keyword appears in a BEGIN statement
  the locking statement of the underlying database files shall remain
  unchanged by the BEGIN TRANSACTION statement.
}
syntaxreq {H42025} {} {} {
  When the IMMEDIATE keyword appears in a BEGIN statement
  then evaluation of the statement shall cause a PENDING lock to be
  obtained for all underlying database files.
}
syntaxreq {H42028} {} {} {
  When the EXCLUSIVE keyword appears in a BEGIN statement
  then evaluation of the statement shall cause a EXCLUSIVE lock to be
  obtained for all underlying database files.
}
syntaxreq {H42031} {} {} {
  The <i>transaction_name</i> clause of a BEGIN statement shall be
  silently ignored.
}
</tcl>

<h3>1.2 COMMIT</h3>

<tcl>
syntaxreq {H42110} {} {} {
  SQLite shall except the following COMMIT statement syntax:
} {
  cmd ::= COMMIT transaction_name.
  cmd ::= END transaction_name.
}
syntaxreq {H42113} {} {} {
  Every successful evaluation of COMMIT statement places the
  [database connection] in autocommit mode.
}
syntaxreq {H42116} {} {} {
  If a [database connection] is already in autocommit mode when
  a COMMIT statement is invoked, then the statement shall return
  an error.
}
syntaxreq {H42119} {} {} {
  The <i>transaction_name</i> clause of a COMMIT statement shall be
  silently ignored.
}
</tcl>

<h3>1.3 ROLLBACK</h3>

<tcl>
syntaxreq {H42210} {} {} {
  SQLite shall except the following ROLLBACK statement syntax:
} {
  cmd ::= ROLLBACK transaction_name.
}
syntaxreq {H42213} {} {} {
  Every successful evaluation of ROLLBACK statement places the
  [database connection] in autocommit mode.
}
syntaxreq {H42216} {} {} {
  If a [database connection] is already in autocommit mode when
  a ROLLBACK statement is invoked, then the statement shall return
  an error.
}
syntaxreq {H42219} {} {} {
  The <i>transaction_name</i> clause of a ROLLBACK statement shall be
  silently ignored.
}
syntaxreq {H42222} {} {} {
  Other pending statements on the same [database connection]
  as a successful ROLLBACK shall be aborted.
}
syntaxreq {H42225} {} {} {
  The successful evaluation of a ROLLBACK statement causes the
  current transaction on the [database connection] to roll back.
}
</tcl>


<h2>2.0 Data Definition Language (DDL)</h2>

<h3>2.1 CREATE TABLE</h3>

<tcl>
syntaxreq {H42310} {} {} {
  SQLite shall accept the following syntax for creating new, empty
  database tables.
} {
  cmd ::= CREATE temp TABLE ifnotexists fullname table_definition.
  temp ::= .
  temp ::= TEMP.
  ifnotexists ::= .
  ifnotexists ::= IF NOT EXISTS.
}
syntaxdef [list {database name} {object name}] {
  The <i>fullname</i> non-terminal symbol of the SQLite grammar specifies
  an SQL object contained within a particular database file.  When
  the rule is of the form  

      &lt;<i>fullname ::= name DOT name.</i>&gt;

  then the first <i>name</i> is called the "database name" and is
  the name of the database file that contains the object.  The second
  <i>name</i> is called the "object name" and is the name of the 
  SQL object itself.  When the <i>fullname</i> non-terminal is of the
  form

      &lt;<i>fullname ::= name.</i>&gt;

  then the <i>name</i> is the object name and the database name is
  unspecified.  An unspecified database name has a default value that
  depends on context and which is specified by requirements.
}  
syntaxreq {H42313} {} {} {
  When the TEMP keyword appears in a CREATE TABLE statement and the
  [database name] exists and is something other than "temp", the CREATE TABLE
  statement shall fail with an error.
}
syntaxreq {H42316} {} {} {
  When the TEMP keyword appears in a CREATE TABLE statement the behavior
  shall be as if the [database name] where "temp".
}
syntaxreq {H42319} {} {} {
  The successful evaluation of a CREATE TABLE statement shall cause
  a new SQL table whose name is given by the [object name] to be
  created in the schema of the database whose name is given by the
  [database name].
}
syntaxreq {H42322} {} {} {
  If a CREATE TABLE statement specifies no [database name] and omits
  the TEMP keyword then the behavior shall be as if a [database name]
  of "main" where used.
}
syntaxreq {H42325} {} {} {
  A CREATE TABLE statement shall fail with an error if the
  ifnotexists clause is omitted and the [object name]
  is the same as the name of a previously exist table or view
  in the same database.
}
syntaxreq {H42328} {} {} {
  A CREATE TABLE statement shall be a silent no-op if the
  ifnotexists clause is present and the [object name]
  is the same as the name of a previously exist table or view
  in the same database.
}
syntaxreq {H42331} {} {} {
  A CREATE TABLE statement shall fail with an error if the
  the [object name] is the same as the name of a previously existing index
  in any database attached to the same [database connection].
}
</tcl>

<h4>2.1.1 CREATE TABLE column definitions</h4>

<tcl>
syntaxdef [list {ordinary CREATE TABLE statement} {CREATE TABLE AS statement}] {
  There are two varieties of CREATE TABLE statements.  The most common form
  specifies the names of all columns in the table together with datatype
  and constraint information.  This first form is called a
  "ordinary CREATE TABLE statement".  The second form of CREATE TABLE
  constructs a new table from the result set of a SELECT statement.
  The second form is called a "CREATE TABLE as statement".
}
syntaxreq {H42410} {} {} {
  SQLite shall accept the following syntax for the <i>table_definition</i>
  section of a CREATE TABLE statement:
} {
  table_definition ::= LP column_list constraint_opt RP.
  column_list ::= column.
  column_list ::= column_list COMMON column.
  constraint_opt ::= .
  constraint_opt ::= COMMA constraint_list.
}
syntaxreq {H42413} {} {} {
  SQLite shall accept the following syntax for the <i>column</i> component
  of a <i>table_definition</i>.
} {
  column ::= name column_type column_constraint_list.
  column_type ::= .
  column_type ::= typename.
  column_type ::= typename LP signed_int RP.
  column_type ::= typename LP signed_int COMMA signed_int RP.
  typename ::= identifier.
  typename ::= typename identifier.
  signed_int ::= INTEGER.
  signed_int ::= MINUS INTEGER.
  signed_int ::= PLUS INTEGER.
}
syntaxreq {H42416} {} {} {
  An [ordinary CREATE TABLE statement] shall fail with an error if it contains
  two or more columns with the same name.
}
syntaxreq {H42419} {} {} {
  The datatype affinity of each column in a table created by an
  [ordinary CREATE TABLE statement]
  shall be determined from the <i>column_type</i>
  text using the following 5-step algorithm:
  <ol>
  <li><p>If the <i>column_type</i> contains the string "INT" (in any case)
  then the affinity is INTEGER.</p></li>
  <li><p>Else if the <i>column_type</i> contains one of the strings
  "CHAR", "CLOB", or "TEXT" (in any case) then the affinity
  is TEXT.</p></li>
  <li><p>Else if the <i>column_type</i> contains the string "BLOB" 
  (in any case) or is omitted then the affinity is NONE.</p></li>
  <li><p>Else if the <i>column_type</i> constains one of the strings
  "REAL", "FLOA", or "DOUB" (in any case) then the affinity is REAL.</p></li>
  <li><p>Otherwise the affinity is NUMERIC.</p></li>
  </ol>
}

syntaxreq {H42450} {} {} {
  SQLite shall accept the following syntax for the list of column
  constraints and modifiers that follows a column definition in 
  an [ordinary CREATE TABLE statement].
} {
  column_constraint_list ::= .
  column_constraint_list ::= column_constraint_list named_column_constraint.
  named_column_constraint ::= CONSTRAINT name column_constraint.
  named_column_constraint ::= column_constraint.
  column_constraint ::= DEFAULT term.
  column_constraint ::= DEFAULT identifier.
  column_constraint ::= DEFAULT PLUS term.
  column_constraint ::= DEFAULT MINUS term.
  column_constraint ::= DEFAULT LP expr RP.
  column_constraint ::= NULL conflict.
  column_constraint ::= NOT NULL conflict.
  column_constraint ::= PRIMARY KEY sortorder conflict autoincr.
  column_constraint ::= UNIQUE conflict.
  column_constraint ::= CHECK LP expr RP.
  column_constraint ::= COLLATE identifier.
  column_constraint ::= foreign_key_constraint.
  column_constraint ::= deferrable_constraint.
  sortorder ::= .
  sortorder ::= ASC.
  sortorder ::= DESC.
  autoincr ::= .
  autoincr ::= AUTOINCR.
  indexlist_opt ::= .
  indexlist_opt ::= LP indexlist RP.
  indexlist ::= indexlist COMMA name collate sortorder.
  indexlist ::= name collate sortorder.
}

syntaxreq {H42510} {} {} {
  SQLite shall accept the following syntax for the list of table
  contraints that occurs at the end of an [ordinary CREATE TABLE statement].
} {
  constraint_list ::= constraint.
  constraint_list ::= constraint_list constraint.
  constraint_list ::= constraint_list COMMA constraint.
  constraint ::= CHECK LP expr RP conflict.
  constraint ::= CONSTRAINT name.
  constraint ::= FOREIGN KEY LP idxlist RP foreign_key_constraint defer_opt.
  constraint ::= PRIMARY KEY LP idxlist autoinc RP conflict.
  constraint ::= UNIQUE LP idxlist RP conflict.
}

syntaxreq {H42570} {} {
  Foreign key constraints are parsed for compatibility with other
  database engines but are not enforced by SQLite.
} {
  SQLite shall accept the following syntax for a foreign key constraint
  as either a separate constraint or as part of a column constraint in 
  an [ordinary CREATE TABLE statement].
} {
  foreign_key_constraint ::= REFERENCES name indexlist_opt fkarglist.
  defer_opt ::= .
  defer_opt ::= deferrable_constraint.
  deferrable_constraint ::= NOT DEFERRABLE initially_deferred_clause.
  deferrable_constraint ::= DEFERRABLE initially_deferred_clause.
  fkarglist ::= .
  fkarglist ::= fkarglist fkarg.
  fkarg ::= MATCH name.
  fkarg ::= ON DELETE fkaction.
  fkarg ::= ON UPDATE fkaction.
  fkarg ::= ON INSERT fkaction.
  fkaction ::= SET NULL.
  fkaction ::= SET DEFAULT.
  fkaction ::= CASCADE.
  fkaction ::= RESTRICT.
  initially_deferred_clause ::= .
  initially_deferred_clause ::= INITIALLY DEFERRED.
  initially_deferred_clause ::= INITIALLY IMMEDIATE.
}
</tcl>

<h4>2.1.2 CREATE TABLE AS</h4>

<tcl>
syntaxreq {H42610} {} {} {
  SQLite shall accept the following syntax for creating new
  database tables that are initialized to the result set of a SELECT statement:
} {
  cmd ::= CREATE temp TABLE ifnotexists fullname AS select.
}
</tcl>


<h3>2.2 DROP TABLE</h3>

<tcl>
syntaxreq {H42700} {} {} {} {
  cmd ::= DROP TABLE ifexists fullname.
}
</tcl>

<h3>2.3 CREATE INDEX</h3>

<tcl>
syntaxreq {H42800} {} {} {} {
  cmd ::= CREATE unique INDEX ifnotexists fullname ON name LP indexlist RP.
}
</tcl>

<h3>2.4 DROP INDEX</h3>

<tcl>
syntaxreq {H42900} {} {} {} {
  cmd ::= DROP INDEX ifexists fullname.
}
</tcl>

<h3>2.5 CREATE VIEW</h3>

<tcl>
syntaxreq {H43100} {} {} {} {
  cmd ::= DROP temp VIEW ifnotexists fullname AS select.
}
</tcl>

<h3>2.6 DROP VIEW</h3>

<tcl>
syntaxreq {H43200} {} {} {} {
  cmd ::= DROP VIEW ifexists fullname.
}
</tcl>

<h3>2.7 CREATE TRIGGER</h3>

<tcl>
syntaxreq {H43300} {} {} {} {
  cmd ::= CREATE temp TRIGGER ifnotexists fullname trigger trigger_body.
  trigger ::= trigger_time trigger_event ON fullname foreach_clause when_clause.
  trigger_body ::= BEGIN trigger_cmd_list END.
  trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI.
  trigger_cmd_list ::=.
  trigger_cmd ::= DELETE FROM name where_opt.
  trigger_cmd ::= UPDATE orconf name SET setlist where_opt.
  trigger_cmd ::= insert_cmd INTO name inscollist_opt VALUES LP itemlist RP.
  trigger_cmd ::= insert_cmd INTO name inscollist_opt select.
  trigger_cmd ::= select.
  trigger_event ::= DELETE.
  trigger_event ::= INSERT.
  trigger_event ::= UPDATE OF inscollist.
  trigger_event ::= UPDATE.
  trigger_time ::= AFTER.
  trigger_time ::= BEFORE.
  trigger_time ::= INSTEAD OF.
  trigger_time ::=.
  foreach_clause ::= FOR EACH ROW.
  foreach_clause ::=.
  when_clause ::= WHEN expr.
  when_clause ::=.
}
</tcl>

<h3>2.8 DROP TRIGGER</h3>

<tcl>
syntaxreq {H43500} {} {} {} {
  cmd ::= DROP TRIGGER ifexists fullname.
}
</tcl>

<h3>2.9 CREATE VIRTUAL TABLE</h3>

<tcl>
syntaxreq {H43600} {} {} {} {
  cmd ::= CREATE VIRTUAL TABLE fullname USING name vtab_arg_list.
  vtab_arg_list ::= .
  vtab_arg_list ::= LP vtab_args RP.
}
</tcl>

<h3>2.10 ALTER TABLE</h3>
<h4>2.11 ALTER TABLE RENAME</h4>

<tcl>
syntaxreq {H43700} {} {} {} {
  cmd ::= ALTER TABLE fullname RENAME TO name.
}
</tcl>

<h4>2.12 ALTER TABLE ADD COLUMN</h4>

<tcl>
syntaxreq {H43750} {} {} {} {
  cmd ::= ALTER TABLE fullname ADD column_keyword column.
  column_keyword ::= .
  column_keyword ::= COLUMNKW.
}
</tcl>

<h2>3.0 Data Manipulation Language (DML)</h2>

<h3>3.1 INSERT</h3>

<tcl>
syntaxreq {H43800} {} {} {} {
  cmd ::= insert_cmd INTO fullname inscollist_opt DEFAULT VALUES.
  cmd ::= insert_cmd INTO fullname inscollist_opt VALUES LP itemlist RP.
  cmd ::= insert_cmd INTO fullname inscollist_opt select.
  insert_cmd ::= INSERT orconf.
  insert_cmd ::= REPLACE.
}
</tcl>

<h4>3.1.1 INSERT VALUE</h4>
<h4>3.1.2 INSERT SELECT</h4>
<h3>3.2 DELETE</h3>

<tcl>
syntaxreq {H43900} {} {} {} {
  cmd ::= DELETE FROM fullname where_opt.
}
</tcl>

<h3>3.3 UPDATE</h3>

<tcl>
syntaxreq {H44100} {} {} {} {
  cmd ::= UPDATE orconf fullname SET setlist where_opt.
}
</tcl>

<h3>3.4 SELECT</h3>

<tcl>
syntaxreq {H45000} {} {} {} {
  cmd ::= select.
  select ::= query.
  select ::= select UNION query.
  select ::= select UNION ALL query.
  select ::= select EXCEPT query.
  select ::= select INTERSECT query.
  query ::= SELECT distinct resultset from where groupby having orderby limit.
  where ::= .
  where ::= WHERE expr.
  groupby ::= .
  groupby ::= GROUP BY exprlist.
  having ::= .
  having ::= HAVING expr.
  orderby ::= .
  orderby ::= ORDER BY exprlist.
  limit ::=.
  limit ::= LIMIT expr.
  limit ::= LIMIT expr COMMA expr.
  limit ::= LIMIT expr OFFSET expr.
  resultset ::= result.
  resultset ::= resultset COMMA result.
  result ::= STAR.
  result ::= expr as.
  result ::= name DOT STAR.
  from ::= .
  from ::= FROM sourceset.
  sourceset ::= source.
  sourceset ::= sourceset joinop source.
  source ::= fullname as on using.
  source ::= LP select RP as on using.
  as ::= .
  as ::= AS name.
  as ::= identifier.
  on ::= .
  on ::= ON expr.
  using ::= .
  using ::= USING LP idlist RP.
  joinop ::= COMMA.
  joinop ::= JOIN.
  joinop ::= JOIN_KW JOIN.
  joinop ::= JOIN_KW name JOIN.
  joinop ::= JOIN_KW name name JOIN.
}
</tcl>

<h2>4.0 Other Language Elements</h2>

<h3>4.1 VACUUM</h3>

<tcl>
syntaxreq {H44200} {} {} {} {
  cmd ::= VACUUM.
  cmd ::= VACUUM name.
}
</tcl>

<h3>4.2 ANALYZE</h3>

<tcl>
syntaxreq {H44300} {} {} {} {
  cmd ::= ANALYZE.
  cmd ::= ANALYZE fullname.
}
</tcl>

<h3>4.3 REINDEX</h3>

<tcl>
syntaxreq {H44400} {} {} {} {
  cmd ::= REINDEX.
  cmd ::= REINDEX fullname.
}
</tcl>

<h3>4.4 PRAGMA</h3>

<tcl>
syntaxreq {H46000} {} {} {} {
  cmd ::= PRAGMA fullname EQ DELETE.
  cmd ::= PRAGMA fullname EQ ON.
  cmd ::= PRAGMA fullname EQ minus_num.
  cmd ::= PRAGMA fullname EQ nmnum.
  cmd ::= PRAGMA fullname LP nmnum RP.
  cmd ::= PRAGMA fullname.
}
</tcl>

<h3>4.5 ATTACH</h3>

<tcl>
syntaxreq {H44500} {} {} {} {
  cmd ::= ATTACH database_kw_opt expr AS expr key_opt.
}
</tcl>

<h3>4.6 DETACH</h3>

<tcl>
syntaxreq {H44600} {} {} {} {
  cmd ::= DETACH database_kw_opt expr.
}
</tcl>

<h3>4.7 EXPLAIN</h3>

<tcl>
syntaxreq {H44700} {} {} {} {
  sql_statement ::= EXPLAIN cmd SEMI.
}
</tcl>

<h3>4.8 EXPLAIN QUERY PLAN</h3>

<tcl>
syntaxreq {H44800} {} {} {} {
  sql_statement ::= EXPLAIN QUERY PLAN cmd SEMI.
}
</tcl>

<h2>5.0 Common Language Subelements</h2>

<h3>5.1 Expressions</h3>

<tcl>
syntaxreq {H47000} {} {} {} {
  expr ::= BITNOT expr.
  expr ::= CASE case_operand case_exprlist case_else END.
  expr ::= CAST LP expr AS typetoken RP.
  case_else ::= ELSE expr.
  case_else ::=.
  case_exprlist ::= WHEN expr THEN expr.
  case_exprlist ::= case_exprlist WHEN expr THEN expr.
  case_operand ::= expr.
  case_operand ::=.
  expr ::= EXISTS LP select RP.
  expr ::= function_name LP STAR RP.
  expr ::= function_name LP distinct exprlist RP.
  expr ::= ID.
  expr ::= JOIN_KW.
  expr ::= LP expr RP.
  expr ::= LP select RP.
  expr ::= MINUS expr.
  expr ::= NOT expr.
  expr ::= PLUS expr.
  expr ::= RAISE LP IGNORE RP.
  expr ::= RAISE LP raisetype COMMA name RP.
  expr ::= REGISTER.
  expr ::= VARIABLE.
  expr ::= expr AND expr.
  expr ::= expr BITAND expr.
  expr ::= expr BITOR expr.
  expr ::= expr LSHIFT expr.
  expr ::= expr RSHIFT expr.
  expr ::= expr COLLATE ids.
  expr ::= expr CONCAT expr.
  expr ::= expr EQ expr.
  expr ::= expr NE expr.
  expr ::= expr IS NOT NULL.
  expr ::= expr IS NULL.
  expr ::= expr ISNULL|NOTNULL.
  expr ::= expr LT expr.
  expr ::= expr GT expr.
  expr ::= expr GE expr.
  expr ::= expr LE expr.
  expr ::= expr NOT NULL.
  expr ::= expr OR expr.
  expr ::= expr PLUS expr.
  expr ::= expr MINUS expr.
  expr ::= expr STAR expr.
  expr ::= expr SLASH expr.
  expr ::= expr REM expr.
  expr ::= expr BETWEEN expr AND expr.
  expr ::= expr NOT BETWEEN expr AND expr.
  expr ::= expr IN LP exprlist RP.
  expr ::= expr IN LP select RP.
  expr ::= expr IN fullname.
  expr ::= expr NOT IN LP exprlist RP.
  expr ::= expr NOT IN LP select RP.
  expr ::= expr NOT IN fullname.
  expr ::= expr LIKE_KW expr escape.
  expr ::= expr MATCH expr escape.
  expr ::= expr NOT LIKE_KW expr escape.
  expr ::= expr NOT MATCH expr escape.
  expr ::= name DOT name DOT name.
  expr ::= name DOT name.
  expr ::= term.
  term ::= CTIME_KW.
  term ::= INTEGER.
  term ::= FLOAT
  term ::= BLOB.
  term ::= NULL.
  term ::= STRING.
}
</tcl>

<h3>5.2 Functions</h3>
<h4>5.2.1 Core Scalar Functions</h4>
<h4>5.2.2 Date and Time Functions</h4>
<h4>5.2.3 Aggregate Functions</h4>

<h3>5.3 Symbolic Names</h3>

<tcl>
syntaxreq {H49100} {} {} {} {
  name ::= ID.
  name ::= JOIN_KW.
  name ::= STRING.
  fullname ::= name.
  fullname ::= name DOT name.
  identifier ::= ID.
  identifier ::= STRING.
}
</tcl>

Changes to pages/sysreq.in.

11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
  }
  hd_requirement $id $text$dlist
  if {[string length $explaination]} {
    hd_resolve "<p>$explaination</p>"
  }
  hd_puts "<blockquote><b>$id:</b>"
  hd_resolve $text
  hd_puts {</b></blockquote}
}
</tcl>

<h1>System Requirements For SQLite</h1>

<p>This document outlines the high-level objectives of the SQLite
library.







|







11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
  }
  hd_requirement $id $text$dlist
  if {[string length $explaination]} {
    hd_resolve "<p>$explaination</p>"
  }
  hd_puts "<blockquote><b>$id:</b>"
  hd_resolve $text
  hd_puts {</b></blockquote>}
}
</tcl>

<h1>System Requirements For SQLite</h1>

<p>This document outlines the high-level objectives of the SQLite
library.

Changes to pages/tokenreq.in.

17
18
19
20
21
22
23
24

25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
..
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
..
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
...
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
and the dollar sign can be expressed as "u0024". 
For notational convenience, the following character classes are
defined:</p>

<blockquote>
<dl>
<dt><b>WHITESPACE</b></dt>
<dd>One of these five characters:  u0009, u000a, u000c, u000d, or u0020</dd>


<dt><b>ALPHABETIC</b></dt>
<dd>Any of the characters in the range u0041 through u005a (letters "A" 
    through "Z") or in the range u0061 through u007a (letters "a" through
    "z") or the character u005f ("_") or any other character larger than
    u007f.</dd>

<dt><b>NUMERIC</b></dt>
<dd>Any of the characters in the range u0030 through u0039 (digits "0"
    through "9")</dd>

<dt><b>ALPHANUMERIC</b></dt>
<dd>Any character which is either ALPHABETIC or NUMERIC</dd>

<dt><b>HEXADECIMAL</b></dt>
<dd>Any NUMERIC character or a characters in the range u0041 through u0046
    ("A" through "F") or in the range u0061 through u0066 ("a" through "f")
</dd>


<dt><b>SPECIAL</b></dt>
<dd>Any character which not WHITESPACE, ALPHABETIC, nor NUMERIC</dd>
</dl>
</blockquote>

<h2>Token requirements</h2>

<tcl>
proc tokenreq {id derivedfrom explaination text} {
................................................................................
  }
  hd_requirement $id $text$dlist
  if {[string length $explaination]} {
    hd_resolve "<p>$explaination</p>"
  }
  hd_puts "<blockquote><b>$id:</b>"
  hd_resolve $text
  hd_puts {</b></blockquote}
}

tokenreq H41010 {} {
  Processing is left-to-right.  This seems obvious, but it needs to be
  explicitly stated.
} {
  SQLite shall divide input SQL text into tokens working from left to
................................................................................
}

tokenreq H41040 {} {
  The tokenizer appends a semicolon to the end of input if necessary.
  This ensures that every SQL statement is terminated by a semicolon.
} {
  When the tokenizer reaches the end of input where the last token sent
  to the parser was not a SEMI token, it shall immediately
  send a SEMI token to the parser.
}

tokenreq H41050 {} {
  An unrecognized token generates an immediate error and aborts the parse.
} {
  When the tokenizer encounters text that is not a valid token, it shall
  cause the [sqlite3_prepare()], [sqlite3_prepare16()], [sqlite3_prepare_v2()],
  or higher-level interface call that provoked the SQL parse to fail.
}

</tcl>
<h3>Whitespace tokens</h3>
<tcl>

tokenreq H41100 {} {
................................................................................
  (u002e) character.
}

</tcl>
<h3>Variables</h3>
<tcl>

tokenreq H42010 {} {
  Variables are used as placeholders in SQL statements for constant
  values that are to be bound at start-time.
} {
  SQLite shall recognize as a VARIABLE token the a question-mark (u003f)
  followed by zero or more NUMERIC characters.
}

tokenreq H42020 {} {
  A "parameter name" is defined to be a sequence of one or more
  characters that consists of
  ALPHANUMERIC characters and/or dollar-signs (u0025) intermixed with
  pairs of colons (u003a) and optionally followed by any sequence
  of non-zero, non-WHITESPACE characters enclosed in parentheses
  (u0028 and u0029).
} {
  SQLite shall recognize as a VARIABLE token one of the characters
  at-sign (u0040), dollar-sign (u0024), or colon (u003a) followed
  by a parameter name.
}
tokenreq H42030 {} {} {
  SQLite shall recognize as a VARIABLE token the shape-sign (u0023)
  followed by a parameter name that does not begin with a
  NUMERIC character.
}

tokenreq L42040 {} {
  The REGISTER token is a special token used internally.  It does not







|
>


|


|


|
|


|


|
|


<

|







 







|







 







|







|
<







 







|







|











|







17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44

45
46
47
48
49
50
51
52
53
..
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
..
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107

108
109
110
111
112
113
114
...
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
and the dollar sign can be expressed as "u0024". 
For notational convenience, the following character classes are
defined:</p>

<blockquote>
<dl>
<dt><b>WHITESPACE</b></dt>
<dd><p>One of these five characters:  u0009, u000a, u000c, u000d, or u0020
</p></dd>

<dt><b>ALPHABETIC</b></dt>
<dd><p>Any of the characters in the range u0041 through u005a (letters "A" 
    through "Z") or in the range u0061 through u007a (letters "a" through
    "z") or the character u005f ("_") or any other character larger than
    u007f.</p></dd>

<dt><b>NUMERIC</b></dt>
<dd><p>Any of the characters in the range u0030 through u0039 (digits "0"
    through "9")</p></dd>

<dt><b>ALPHANUMERIC</b></dt>
<dd><p>Any character which is either ALPHABETIC or NUMERIC</p></dd>

<dt><b>HEXADECIMAL</b></dt>
<dd><p>Any NUMERIC character or a characters in the range u0041 through u0046
    ("A" through "F") or in the range u0061 through u0066 ("a" through "f")</p>
</dd>


<dt><b>SPECIAL</b></dt>
<dd></p>Any character that is not WHITESPACE, ALPHABETIC, nor NUMERIC</p></dd>
</dl>
</blockquote>

<h2>Token requirements</h2>

<tcl>
proc tokenreq {id derivedfrom explaination text} {
................................................................................
  }
  hd_requirement $id $text$dlist
  if {[string length $explaination]} {
    hd_resolve "<p>$explaination</p>"
  }
  hd_puts "<blockquote><b>$id:</b>"
  hd_resolve $text
  hd_puts {</b></blockquote>}
}

tokenreq H41010 {} {
  Processing is left-to-right.  This seems obvious, but it needs to be
  explicitly stated.
} {
  SQLite shall divide input SQL text into tokens working from left to
................................................................................
}

tokenreq H41040 {} {
  The tokenizer appends a semicolon to the end of input if necessary.
  This ensures that every SQL statement is terminated by a semicolon.
} {
  When the tokenizer reaches the end of input where the last token sent
  to the parser was not a SEMI token, it shall 
  send a SEMI token to the parser.
}

tokenreq H41050 {} {
  An unrecognized token generates an immediate error and aborts the parse.
} {
  When the tokenizer encounters text that is not a valid token, it shall
  cause an error to be returned to the application.

}

</tcl>
<h3>Whitespace tokens</h3>
<tcl>

tokenreq H41100 {} {
................................................................................
  (u002e) character.
}

</tcl>
<h3>Variables</h3>
<tcl>

tokenreq H40310 {} {
  Variables are used as placeholders in SQL statements for constant
  values that are to be bound at start-time.
} {
  SQLite shall recognize as a VARIABLE token the a question-mark (u003f)
  followed by zero or more NUMERIC characters.
}

tokenreq H40320 {} {
  A "parameter name" is defined to be a sequence of one or more
  characters that consists of
  ALPHANUMERIC characters and/or dollar-signs (u0025) intermixed with
  pairs of colons (u003a) and optionally followed by any sequence
  of non-zero, non-WHITESPACE characters enclosed in parentheses
  (u0028 and u0029).
} {
  SQLite shall recognize as a VARIABLE token one of the characters
  at-sign (u0040), dollar-sign (u0024), or colon (u003a) followed
  by a parameter name.
}
tokenreq H40330 {} {} {
  SQLite shall recognize as a VARIABLE token the shape-sign (u0023)
  followed by a parameter name that does not begin with a
  NUMERIC character.
}

tokenreq L42040 {} {
  The REGISTER token is a special token used internally.  It does not