Documentation Source Text

Check-in [ce20876314]
Login

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

Overview
Comment:Continuing work on syntax requirements.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: ce208763140380efd78e2b41d890b13300c96b91
User & Date: drh 2008-08-09 00:01:22
Context
2008-08-10
19:23
Continuing work on SQL language requirements. check-in: 451999a899 user: drh tags: trunk
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
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to pages/syntax.in.

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
...
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
...
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
...
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
...
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
...
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
  }
  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 ::= 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 ::= .
................................................................................
  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.
................................................................................
  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.
................................................................................
</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 ::= 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>







|












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

|
>
>
>
>
>
|




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








|
>












|


|
|
|








|
|



|
|



|
|

|
|
>
|
<
<





|





|




|
|

|
|
>
|
|
<
>
>
>
>





|
>




|




|
|

|
|
|
>
|
<

|






>
>
>








|
|







|
>

|
<
>

|

<
|
<
<
<

|

<
|

<
>
>


|
|



|



|

|


|
|



|
|
|




|
|




|


>
>
>
>
>











|

|
>
>
>
>
|
|







|
>
>
>
>
>
>
>
|
|













|
|


|




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




|







 







<
<
<




|
|
>
>
>
>

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

|







|
|
|

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




|
|
|







 







|
>
>
>
|
<
>

<
>

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






|
>
>
>

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






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

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





|
>
>
>







|
>
>
>
|






|
>
>
>







|
>
>
>







 







|
>
>
>







|
>
>
>










|
>
>
>







|
>
>
>










>

|
<
>
>
>

<




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



|
>
>
>







|
>
>
>







|
>
>
>







 







|
>
>
>








|
>
>
>








|
>
>
>








|
>
>
>












|
>
>
>







|
>
>
>







|
>
>
>







|
>
>
>









|
>
>
>



<
<
<
<
<
<







 







>
>
>
>
>
>
>
>
>











|
>
>
>



>
>
|
>
|




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
...
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
...
559
560
561
562
563
564
565
566
567
568
569
570

571
572

573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
...
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
...
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068






1069
1070
1071
1072
1073
1074
1075
....
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
  }
  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>

<p>These requirements make the distinction between "preparing" an
SQL statement and "evaluating" or "invoking" an SQL statement.
Preparation means that the SQL statement text is translated into
an internal binary representation that is more suitable for processing.
Evaluation or invocation means that the processing is actually carried out.
Preparation of an SQL statement is usually accomplished by interfaces
[sqlite3_prepare()], [sqlite3_prepare16()], or [sqlite3_prepare_v2()] and
evaluation or invocation of an SQLite statement is accomplished by
calling [sqlite3_step()].  However, if a statement is initially
prepared using [sqlite3_prepare_v2()] and a change to the database
schema is detected during evaluation, then the preparation is redone
automatically, by [sqlite3_step()].  So even though it is reasonable
to think about preparation as being a function of [sqlite3_prepare_v2()]
and its companions and evaluation as being a function of
[sqlite3_step()], the reader should keep in mind that
[sqlite3_step()] might also sometimes do preparations following
schema changes.</p>

<tcl>
syntaxreq {H42000} {} {
  SQLite expects all statements to be terminated by a semicolon.
  If a statement is submitted to SQLite that does not end in a
  semicolon, then a semicolon is added automatically by the tokenizer.
  (See [H41040].)
} {
  The SQLite parser shall accept SQL statements consisting of an SQL command
  followed by a semicolon.
} {
  sql_statement ::= cmd SEMI.
}
syntaxreq {H42002} {} {
  Acceptance by the parser does not imply that the SQL statement
  will be accepted by SQLite.  SQL statements may be rejected by other
  parts of the SQLite library.  Acceptance by the parser is a necessary
  but not a sufficient condition for the statement to work.
} {
  The preparation of an SQL statement that is not accepted by
  the SQLite parser shall fail with an error.
}
syntaxreq {H42004} {} {
  SQLite ignores case when comparing ASCII characters in identifiers and
  in type names.  (The rules for comparison of content are different.)
  Case is considered for other unicode characters, however.
  Hence, SQLite considers identifiers "A" and "a" to be equivalent but
  "&Aring;" and "&aring;" are distinct.
} {
  SQLite shall use the built-in NOCASE collating sequence when comparing
  identifiers and datatype names within SQL statements during 
  statement preparation.
}
</tcl>

<h2>1.0 Transaction Control</h2>

<h3>1.1 BEGIN</h3>

<tcl>
syntaxreq {H42010} {} {} {
  The SQLite parser shall accept BEGIN statements
  that conform to the following 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 exit autocommit mode.
}
syntaxreq {H42016} {} {} {
  The evaluation of a BEGIN TRANSACTION statement shall fail with an error
  if the [database connection] is not in autocommit mode at the
  start of evaluation.
}
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 state of the underlying database files shall be
  the same before and after the statement is evaluated.
}
syntaxreq {H42025} {} {} {
  When the IMMEDIATE keyword appears in a BEGIN statement
  then successful evaluation of the statement shall cause a RESERVED
  lock to be obtained for all underlying database files.
}
syntaxreq {H42028} {} {} {
  When the EXCLUSIVE keyword appears in a BEGIN statement
  then successful evaluation of the statement shall cause a EXCLUSIVE 
  lock to be obtained for all underlying database files.
}
</tcl>
<p>The <i>transaction_name</i> clause of a BEGIN statement is
provided for syntactic compatibility to other SQL database engines.
The <i>transaction_name</i> clause is silently ignored.</p>



<h3>1.2 COMMIT</h3>

<tcl>
syntaxreq {H42110} {} {} {
  SQLite shall accept the following COMMIT statement syntax:
} {
  cmd ::= COMMIT transaction_name.
  cmd ::= END transaction_name.
}
syntaxreq {H42113} {} {} {
  The 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 evaluated, then the statement shall fail
  with an error.
}
</tcl>
<p>The <i>transaction_name</i> clause of a COMMIT statement is
provided for syntactic compatibility to other SQL database engines.
The <i>transaction_name</i> clause is silently ignored.</p>


<p>The COMMIT and END statements are aliases for one another and
accomplish exactly the same thing.  One is merely a different way
of expression the other.</p>


<h3>1.3 ROLLBACK</h3>

<tcl>
syntaxreq {H42210} {} {} {
  The SQLite parser shall accept ROLLBACK statements
  that conform to the following syntax:
} {
  cmd ::= ROLLBACK transaction_name.
}
syntaxreq {H42213} {} {} {
  The 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 invocation
  shall fail with an error.
}
syntaxreq {H42222} {} {
  A "pending statement" is a statement for which [sqlite3_step()]
  has been called at least once without a subsequent call to
  either [sqlite3_reset()] or [sqlite3_finalize()].
} {

  Other pending statements on the same [database connection]
  as a successfully evaluated ROLLBACK statement shall be aborted.
}
syntaxreq {H42225} {} {} {
  The successful evaluation of a ROLLBACK statement causes the
  current transaction on the [database connection] to roll back.
}
</tcl>
<p>The <i>transaction_name</i> clause of a BEGIN statement is
provided for syntactic compatibility to other SQL database engines.
The <i>transaction_name</i> clause is silently ignored.</p>


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

<h3>2.1 CREATE TABLE</h3>

<tcl>
syntaxreq {H42310} {} {} {
  The SQLite parser shall accept CREATE TABLE statements
  that conform to the following syntax:
} {
  cmd ::= CREATE temp TABLE ifnotexists fullname table_definition.
  temp ::= .
  temp ::= TEMP.
  ifnotexists ::= .
  ifnotexists ::= IF NOT EXISTS.
}
</tcl>
<p>
  The <i>fullname</i> non-terminal symbol of the SQLite grammar specifies
  an SQL object contained within a particular database file.  A

  specific database might be stated explicitly:

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


  or the database might be implied:




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


  An unspecified <i>databasename</i> has a default value that
  depends on context and which is specified by requirements.

</p>
<tcl>
syntaxreq {H42313} {} {} {
  When the TEMP keyword appears in a CREATE TABLE statement and the
  <i>databasename</i> exists and is something other than "temp", then
  the preparation of 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 <i>databasename</i> where "temp".
}
syntaxreq {H42319} {} {} {
  The successful evaluation of a CREATE TABLE statement shall cause
  a new SQL table whose name is given by the <i>objectname</i> to be
  created in the schema of the database whose name is given by the
  <i>databasename</i>.
}
syntaxreq {H42322} {} {} {
  If a CREATE TABLE statement specifies no <i>databasename</i> and omits
  the TEMP keyword then the behavior shall be as if a <i>databasename</i>
  of "main" where used.
}
syntaxreq {H42325} {} {} {
  The preparation of a CREATE TABLE statement shall fail with an 
  error if the IF NOT EXISTS clause is omitted and the <i>objectname</i>
  is the same as the name of a table or view
  in the same database.
}
syntaxreq {H42328} {} {} {
  A CREATE TABLE statement shall be a silent no-op if the
  IF NOT EXISTS clause is present and the <i>objectname</i>
  is the same as the name of a table or view
  in the same database.
}
syntaxreq {H42331} {} {} {
  A CREATE TABLE statement shall fail with an error if the
  the <i>objectname</i> is the same as the name of an index
  in any database attached to the same [database connection].
}
syntaxreq {H42334} {} {} {
  A CREATE TABLE statement shall fail with an error if the
  the <i>databasename</i> references a database that is not
  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} {} {
  In an ordinary CREATE TABLE statement, the <i>table_definition</i>
  consists of a list of column definitions optionally followed by a 
  list of table constraints.
} {
  The SQLite parser 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} {} {
  A column definition within an ordinary CREATE TABLE statement always
  has a column name.  It might also include a datatype for the
  column and zero or more contraints on the column.  But both the
  datatype and the constraints are options.  Other SQL database
  engines also have optional constraints but they usually make the
  datatype required.
} {
  The SQLite parser 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} {} {} {
  The preparation of an [ordinary CREATE TABLE statement] shall fail 
  with an error if it specifies two or more columns with the same name.
}
syntaxreq {H42419} {} {} {
  The datatype affinity of each column in a table generate 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"
          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" then the affinity is TEXT. </p></li>


  <li><p> Else if the <i>column_type</i> contains the string "BLOB" 
          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" then the affinity
          is REAL. </p></li>

  <li><p> Otherwise the affinity is NUMERIC. </p></li>
  </ol>
}

syntaxreq {H42450} {} {} {
  The SQLite parser 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 ::= 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.



  autoincr ::= .
  autoincr ::= AUTOINCR.
  indexlist_opt ::= .
  indexlist_opt ::= LP indexlist RP.
  conflict ::= .
  conflict ::= ON CONFLICT IGNORE.
  conflict ::= ON CONFLICT REPLACE.
  conflict ::= ON CONFLICT ABORT.
  conflict ::= ON CONFLICT FAIL.
  conflict ::= ON CONFLICT ROLLBACK.
}
syntaxreq {H42453} {} {} {
  If a column has no DEFAULT constraint then the default value for
  that column shall be NULL.
}
syntaxreq {H42456} {} {} {
  Every column a table shall have a "NULL conflict resolution behavior"
  which is one of NONE, IGNORE, REPLACE, FAIL, ABORT, or ROLLBACK.
}
syntaxreq {H42459} {} {
  The default NULL conflict resolution behavior is NONE, which means
  NULLs are allowed in the column.  This can be made explicit by
  specifying the NULL constraint.  But the use of the NULL constraint
  is merely comment for human readers.  SQLite silently ignores the
  NULL constraint and its ON CONFLICT clause.  SQLite only cares
  about NOT NULL constraints since only NOT NULL constraints make
  a behaviorial difference.
} {
  If a column has no NOT NULL constraint then the NULL conflict
  resolution behavior for the column shall be NONE.
}
syntaxreq {H42462} {} {} {
  If a column has a NOT NULL constraint without an ON CONFLICT clause
  then the NULL conflict resolution behavior for the column shall
  be ABORT.
}
syntaxreq {H42465} {} {} {
  If a column has a NOT NULL constraint with an ON CONFLICT clause
  then the NULL conflict resolution behavior for the column shall
  be the behavior specified by the ON CONFLICT clause.
}
syntaxreq {H42467} {} {} {
  A column without a COLLATE constraint shall have a default
  collating sequence of BINARY.
}
syntaxreq {H42468} {} {} {
  A column with a COLLATE constraint shall have a default
  collating sequence as specified by the COLLATE constraint.
}

syntaxreq {H42470} {} {
  The rowid is the underlying key used for storing each row of a 
  table in the B-Tree that implements that table.  Every table has
  a rowid column which is either implicit or explicit.  There can
  be up to four names for the rowid within the same table.  All
  can be used interchangeably.
} {
  If the datatype of a single-column PRIMARY KEY is
  exactly "INTEGER" then the name of that column shall be
  an alias for the table rowid.
}
syntaxreq {H42472} {} {} {
  If a table contains no column named "ROWID" then "ROWID" shall be
  an alias for the table rowid.
}
syntaxreq {H42474} {} {} {
  If a table contains no column named "OID" then "OID" shall be
  an alias for the table rowid.
}
syntaxreq {H42476} {} {} {
  If a table contains no column named "_ROWID_" then "_ROWID_" shall be
  an alias for the table rowid.
}
syntaxreq {H42478} {} {
  The AUTOINCREMENT keyword is ignored except for on an explicit
  rowid column.
} {
  A table shall have an autoincrementing rowid if and only if
  the PRIMARY KEY for the table is an alias for the rowid and
  the PRIMARY KEY declaration uses the AUTOINCR keyword.
}

syntaxreq {H42480} {} {} {
  Successful evaluation of a CREATE TABLE statement that contains
  a column UNIQUE constraint without an ON CONFLICT shall create
  unique index on the column and with a conflict resolution 
  algorithm of ABORT.
}
syntaxreq {H42483} {} {} {
  Successful evaluation of a CREATE TABLE statement that contains
  a column UNIQUE constraint with an ON CONFLICT shall create
  unique index on the column and with the specified conflict 
  resolution algorithm.
}


syntaxreq {H42510} {} {} {
  The SQLite parser 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 idlist RP foreign_key_constraint defer_opt.
  constraint ::= PRIMARY KEY LP indexlist autoinc RP conflict.
  constraint ::= UNIQUE LP indexlist RP conflict.
}
syntaxreq {H42513} {} {} {
  The preparation of a CREATE TABLE statement that contains more
  than one PRIMARY KEY constraint shall fail with an error.
}
syntaxreq {H42516} {} {} {
  The preparation of a CREATE TABLE statement that contains a
  CHECK constraint that uses a subquery shall fail with an error.
}
syntaxreq {H42517} {} {} {
  The preparation of a CREATE TABLE statement that contains a
  CHECK constraint that uses a parameter shall fail with an error.
}
syntaxreq {H42518} {} {} {
  The preparation of a CREATE TABLE statement that contains a
  CHECK constraint that references any column of any table other than
  the table being created shall fail with an error.
}
syntaxreq {H42521} {} {} {
  The preparation of a CREATE TABLE statement that contains a
  DEFAULT constraint with an non-constant expression
  shall fail with an error.
}
syntaxreq {H42530} {} {
  Multi-column UNIQUE constraints work just like column UNIQUE
  constraints in that they generate a unique index on the column
  or columns specified.
} {
  Successful evaluation of a CREATE TABLE statement that contains
  a multi-column UNIQUE constraint without an ON CONFLICT shall create
  unique index on the specified columns and with a conflict 
  resolution algorithm of ABORT.
}
syntaxreq {H42532} {} {} {
  Successful evaluation of a CREATE TABLE statement that contains
  a multi-column UNIQUE constraint with an ON CONFLICT shall create
  unique index on the specified columns and with the specified 
  conflict resolution algorithm.
}
syntaxreq {H42536} {} {
  Except for the special case of INTEGER PRIMARY KEY, a
  PRIMARY KEY is just an alias for UNIQUE.
} {
  A PRIMARY KEY constraint that does not result in a rowid alias
  shall have the same effect as a UNIQUE constraint.
}
syntaxreq {H42539} {} {} {
  Preparation of a CREATE TABLE statement shall fail with an
  error if the <i>indexlist</i> of either a table PRIMARY KEY
  or a table UNIQUE constraint references a column that is not
  a column in the table.
}


syntaxreq {H42570} {} {
  Foreign key constraints are parsed for compatibility with other
  database engines but are not enforced by SQLite.
} {
  The SQLite parser 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 ::= .
................................................................................
  initially_deferred_clause ::= INITIALLY IMMEDIATE.
}
</tcl>

<h4>2.1.2 CREATE TABLE AS</h4>

<tcl>
syntaxreq {H42610} {} {
  The CREATE TABLE AS statement generates a new table to hold the
  result set of a SELECT statement.
} {
  The SQLite parser shall accept the following syntax for creating new

  database tables from the result set of SELECT statements.
} {

  table_definition ::= AS select.
}
syntaxreq {H42613} {} {
  The names of the columns in the generated table are taken from the
  column names of the SELECT statement.  All other attributes of the
  generated table are the default attributes for a column.  Hence, the
  table generated by a CREATE TABLE AS as the same behavior as an
  ordinary CREATE TABLE where the <i>table_definition</i> consists of
  a comma-separated list of column names with no datatypes or constraints
  of any kind.
} {
  The table generated by a CREATE TABLE AS statement shall have the
  same number of columns as the result set of the SELECT.
}
syntaxreq {H42616} {} {} {
  The names of the columns in a table generated by a CREATE TABLE AS
  statement shall have base names which are the names of the columns
  in the result set of the SELECT statement
}
syntaxreq {H42617} {} {} {
  Each column name in a table generated by a CREATE TABLE AS
  statement shall have an arbitrary suffix appended to its basename
  if and only if such a suffix is necessary to make the name
  different from all preceding column names in the table.
}
syntaxreq {H42619} {} {} {
  All columns in a table generated by a CREATE TABLE AS statement
  shall have a default value of NULL.
}
syntaxreq {H42622} {} {} {
  All columns in a table generated by a CREATE TABLE AS statement
  shall have a NULL conflict resolution behavior of NONE.
}
syntaxreq {H42625} {} {} {
  All columns in a table generated by a CREATE TABLE AS statement
  shall have an affinity of NONE.
}
syntaxreq {H42628} {} {} {
  All columns in a table generated by a CREATE TABLE AS statement
  shall have a default collating sequence of BINARY.
}

</tcl>


<h3>2.2 DROP TABLE</h3>

<tcl>
syntaxreq {H42700} {} {} {
  The SQLite parser shall accept DROP TABLE statements
  that conform to the following syntax.
} {
  cmd ::= DROP TABLE ifexists fullname.
  ifexists ::= .
  ifexists ::= IF EXISTS.
}
syntaxreq {H42710} {} {} {
  The preparation of a DROP TABLE statement shall fail with an
  error if the statement lacks an IF EXISTS clause and the
  <i>fullname</i> does not reference a existing table.
}
syntaxreq {H42713} {} {} {
  The evaluation of a DROP TABLE statement shall be a silent no-op
  if the the statement has an IF EXISTS clause and the
  <i>fullname</i> does not reference a existing table.
}
syntaxreq {H42716} {} {} {
  The successful evaluation of a DROP TABLE statement shall cause
  the table identified by <i>fullname</i> to be removed from its
  database and discarded.
}
syntaxreq {H42719} {} {} {
  The successful evaluation of a DROP TABLE statement shall cause
  all indices attached to the table identified by <i>fullname</i>
  to be removed from their database and discarded.
}
</tcl>

<h3>2.3 CREATE INDEX</h3>

<tcl>
syntaxreq {H42800} {} {} {
  The SQLite parser shall accept CREATE INDEX statements that 
  conform to the following syntax:
} {
  cmd ::= CREATE unique INDEX ifnotexists fullname ON tablename LP indexlist RP.
  tablename ::= name.
  indexlist ::= indexlist COMMA columnname collate sortorder.
  indexlist ::= columnname collate sortorder.
  columnname ::= name.
  collate ::= .
  collate ::= COLLATE identifier.
  sortorder ::= .
  sortorder ::= ASC.
  sortorder ::= DESC.
}
syntaxreq {H42803} {} {} {
  The target database of a CREATE INDEX statement shall be the 
  <i>databasename</i> specified in the <i>fullname</i> term of the
  statement if that <i>databasename</i> exists.
}
syntaxreq {H42806} {} {} {
  If the <i>fullname</i> term of a CREATE INDEX statement does not
  specify a <i>databasename</i> and the <i>tablename</i> references a table 
  that is in the "temp" database, then the target database for the statement
  shall be "temp".
}
syntaxreq {H42809} {} {} {
  If the <i>fullname</i> term of a CREATE INDEX statement does not
  specify a <i>databasename</i> and the <i>tablename</i> references a table
  that is not in the "temp" database, then the target database for the
  statement shall be "main".
}
syntaxreq {H42812} {} {} {
  The preparation of a CREATE INDEX statement shall fail with an error if the
  <i>databasename</i> of the <i>fullname</i> exists and references a database 
  that is not attached to the same [database connection].
}
syntaxreq {H42815} {} {} {
  The preparation of a CREATE INDEX statement shall fail with an error if the
  <i>tablename</i> does not reference an ordinary table in the
  database of the statement.
}
syntaxreq {H42818} {} {} {
  A successful evaluation of a CREATE INDEX statement shall create a 
  new index called <i>objectname</i>
  in the database of the statement and attached to the
  table identified by <i>tablename</i> in that same database.
}
syntaxreq {H42821} {} {} {
  An index generated by a CREATE INDEX statement that omits the
  UNIQUE keyword shall have a uniqueness conflict resolution behavior
  of NONE.
}
syntaxreq {H42824} {} {} {
  An index generated by a CREATE INDEX statement that includes the
  UNIQUE keyword shall have a uniqueness conflict resolution behavior
  of ABORT.
}
syntaxreq {H42830} {} {} {
  The preparation of a CREATE INDEX statement shall fail with an error if any
  <i>columnname</i> value within the <i>indexlist</i> is not the
  name of one of the columns of the <i>tablename</i> table.
}
syntaxreq {H42833} {} {
  The following rules regarding default collating sequences and
  sort order for indices applies both to indices created by CREATE INDEX
  and also by UNIQUE or PRIMARY KEY constraints on the table definition.
} {
  The collating sequence for each column of an index shall be the
  collating sequence specified in the <i>indexlist</i>.
}
syntaxreq {H42836} {} {} {
  If an index column does not specify a collating sequence then
  the collating sequence shall be
  the default collating sequence of the corresponding table column.
}
syntaxreq {H42839} {} {} {
  The sort order for an index column shall be descending if and only
  if the DESC keyword is used in the <i>indexlist</i> entry for that
  term.
}


</tcl>

<h3>2.4 DROP INDEX</h3>

<tcl>
syntaxreq {H42900} {} {} {
  The SQLite parser shall accept DROP INDEX statements 
  that conform to the following syntax:
} {
  cmd ::= DROP INDEX ifexists fullname.
}
</tcl>

<h3>2.5 CREATE VIEW</h3>

<tcl>
syntaxreq {H43100} {} {} {
  The SQLite parser shall accept CREATE VIEW statements 
  that conform to the following syntax:
} {
  cmd ::= CREATE temp VIEW ifnotexists fullname AS select.
}
</tcl>

<h3>2.6 DROP VIEW</h3>

<tcl>
syntaxreq {H43200} {} {} {
  The SQLite parser shall accept DROP VIEW statements
  that conform to the following syntax:
} {
  cmd ::= DROP VIEW ifexists fullname.
}
</tcl>

<h3>2.7 CREATE TRIGGER</h3>

<tcl>
syntaxreq {H43300} {} {} {
  The SQLite parser shall accept CREATE TRIGGER statements
  that conform to the following syntax:
} {
  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.
................................................................................
  when_clause ::=.
}
</tcl>

<h3>2.8 DROP TRIGGER</h3>

<tcl>
syntaxreq {H43500} {} {} {
  The SQLite parser shall accept DROP TRIGGER statements
  that conform to the following syntax:
} {
  cmd ::= DROP TRIGGER ifexists fullname.
}
</tcl>

<h3>2.9 CREATE VIRTUAL TABLE</h3>

<tcl>
syntaxreq {H43600} {} {} {
  The SQLite parser shall accept CREATE VIRTUAL TABLE statements
  that conform to the following syntax.
} {
  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} {} {} {
  The SQLite parser shall accept ALTER TABLE RENAME statements
  that conform to the following syntax:
} {
  cmd ::= ALTER TABLE fullname RENAME TO name.
}
</tcl>

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

<tcl>
syntaxreq {H43750} {} {} {
  The SQLite parser shall accept ALTER TABLE ADD COLUMN statements
  that conform to the following syntax:
} {
  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>

<h4>3.1.1 INSERT VALUE</h4>
<tcl>
syntaxreq {H43810} {} {} {

  The SQLite parser shall accept INSERT VALUE statements that
  conform to the following syntax:
} {
  cmd ::= insert_cmd INTO fullname inscollist_opt VALUES LP itemlist RP.

  insert_cmd ::= INSERT orconf.
  insert_cmd ::= REPLACE.
}
</tcl>
<h4>3.1.3 INSERT DEFAULT</h4>
<tcl>
syntaxreq {H43820} {} {} {
  The SQLite parser shall accept INSERT DEFAULT statements that
  conform to the following syntax:
} {
  cmd ::= insert_cmd INTO fullname inscollist_opt DEFAULT VALUES.
}

</tcl>
<h4>3.1.3 INSERT SELECT</h4>
syntaxreq {H43830} {} {} {
  The SQLite parser shall accept INSERT SELECT statements that
  conform to the following syntax:
} {
  cmd ::= insert_cmd INTO fullname inscollist_opt DEFAULT VALUES.
}
</tcl>
<h3>3.2 DELETE</h3>

<tcl>
syntaxreq {H43900} {} {} {
  The SQLite parser shall accept DELETE statements that
  conform to the following syntax:
} {
  cmd ::= DELETE FROM fullname where_opt.
}
</tcl>

<h3>3.3 UPDATE</h3>

<tcl>
syntaxreq {H44100} {} {} {
  The SQLite parser shall accept UPDATE statements that
  conform to the following syntax:
} {
  cmd ::= UPDATE orconf fullname SET setlist where_opt.
}
</tcl>

<h3>3.4 SELECT</h3>

<tcl>
syntaxreq {H45000} {} {} {
  The SQLite parser shall accept SELECT statements that
  conform to the following syntax:
} {
  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.
................................................................................
</tcl>

<h2>4.0 Other Language Elements</h2>

<h3>4.1 VACUUM</h3>

<tcl>
syntaxreq {H44200} {} {} {
  The SQLite parser shall accept VACUUM statements that
  conform to the following syntax:
} {
  cmd ::= VACUUM.
  cmd ::= VACUUM name.
}
</tcl>

<h3>4.2 ANALYZE</h3>

<tcl>
syntaxreq {H44300} {} {} {
  The SQLite parser shall accept ANALYZE statements
  that conform to the following syntax:
} {
  cmd ::= ANALYZE.
  cmd ::= ANALYZE fullname.
}
</tcl>

<h3>4.3 REINDEX</h3>

<tcl>
syntaxreq {H44400} {} {} {
  The SQLite parser shall accept REINDEX statements
  that conform to the following syntax:
} {
  cmd ::= REINDEX.
  cmd ::= REINDEX fullname.
}
</tcl>

<h3>4.4 PRAGMA</h3>

<tcl>
syntaxreq {H46000} {} {} {
  The SQLite parser shall accept PRAGMA statements
  that conform to the following syntax:
} {
  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} {} {} {
  The SQLite parser shall accept ATTACH statements
  that conform to the following syntax:
} {
  cmd ::= ATTACH database_kw_opt expr AS expr key_opt.
}
</tcl>

<h3>4.6 DETACH</h3>

<tcl>
syntaxreq {H44600} {} {} {
  The SQLite parser shall accept DETACH statements
  that conform to the following syntax:
} {
  cmd ::= DETACH database_kw_opt expr.
}
</tcl>

<h3>4.7 EXPLAIN</h3>

<tcl>
syntaxreq {H44700} {} {} {
  The SQLite parser shall accept the EXPLAIN keyword as a prefix
  to other valid SQL statements, as shown by the following syntax:
} {
  sql_statement ::= EXPLAIN cmd SEMI.
}
</tcl>

<h3>4.8 EXPLAIN QUERY PLAN</h3>

<tcl>
syntaxreq {H44800} {} {} {
  The SQLite parser shall accept EXPLAIN QUERY PLAY as a prefix
  to other valid SQL statements, as shown by the following syntax:
} {
  sql_statement ::= EXPLAIN QUERY PLAN cmd SEMI.
}
</tcl>

<h2>5.0 Common Language Subelements</h2>

<h3>5.1 Expressions</h3>

<tcl>
syntaxreq {H47000} {} {} {
  The SQLite parser shall accept expressions that
  conform to the following syntax:
} {
  expr ::= BITNOT expr.
  expr ::= CASE case_operand case_exprlist case_else END.
  expr ::= CAST LP expr AS typetoken RP.






  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 ::= term.
  term ::= CTIME_KW.
  term ::= INTEGER.
  term ::= FLOAT
  term ::= BLOB.
  term ::= NULL.
  term ::= STRING.
  exprlist ::= expr.
  exprlist ::= exprlist COMMA expr.
  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 ::= .
  function_name ::= ID.
}
</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} {} {} {
  The SQLite parser shall accept names, fullnames, and identifiers
  that conform to the following syntax:
} {
  name ::= ID.
  name ::= JOIN_KW.
  name ::= STRING.
  fullname ::= objectname.
  fullname ::= databasename DOT objectname.
  objectname ::= name.
  databasename ::= name.
  columnname ::= name.
  identifier ::= ID.
  identifier ::= STRING.
}
</tcl>