@polycode-projects/the-mechanical-code-talker 2.3.0 → 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/corpus/LICENSES.json +19 -4
- package/corpus/README.md +48 -0
- package/corpus/generated/README.md +24 -9
- package/corpus/generated/ace-surface-variants.jsonl +4 -1
- package/corpus/generated/manifest.json +4 -4
- package/corpus/prose/manifest.json +512 -0
- package/corpus/prose/sqlite/LICENSE-NOTICE +53 -0
- package/corpus/prose/sqlite/arch.txt +213 -0
- package/corpus/prose/sqlite/atomiccommit.txt +1117 -0
- package/corpus/prose/sqlite/faq.txt +473 -0
- package/corpus/prose/sqlite/fileformat.txt +1589 -0
- package/corpus/prose/sqlite/lang_createtable.txt +1339 -0
- package/corpus/prose/sqlite/lang_insert.txt +580 -0
- package/corpus/prose/sqlite/lang_select.txt +3293 -0
- package/corpus/prose/sqlite/optoverview.txt +908 -0
- package/corpus/prose/sqlite/queryplanner.txt +447 -0
- package/corpus/prose/sqlite/transactional.txt +41 -0
- package/corpus/prose/sqlite/wal.txt +567 -0
- package/corpus/prose/sqlite/whentouse.txt +300 -0
- package/corpus/prose/wikipedia/Apple.txt +4 -0
- package/corpus/prose/wikipedia/Attempto_Controlled_English.txt +169 -0
- package/corpus/prose/wikipedia/Automated_planning_and_scheduling.txt +67 -0
- package/corpus/prose/wikipedia/Bee.txt +7 -0
- package/corpus/prose/wikipedia/Bird.txt +8 -0
- package/corpus/prose/wikipedia/Bone.txt +4 -0
- package/corpus/prose/wikipedia/Book.txt +7 -0
- package/corpus/prose/wikipedia/Bread.txt +6 -0
- package/corpus/prose/wikipedia/Butterfly.txt +6 -0
- package/corpus/prose/wikipedia/Car.txt +1 -0
- package/corpus/prose/wikipedia/Cat.txt +1 -0
- package/corpus/prose/wikipedia/Child.txt +3 -0
- package/corpus/prose/wikipedia/City.txt +2 -0
- package/corpus/prose/wikipedia/Clock.txt +2 -0
- package/corpus/prose/wikipedia/Cooking.txt +1 -0
- package/corpus/prose/wikipedia/Description_logic.txt +660 -0
- package/corpus/prose/wikipedia/Doctor.txt +6 -0
- package/corpus/prose/wikipedia/Dog.txt +4 -0
- package/corpus/prose/wikipedia/Eagle.txt +4 -0
- package/corpus/prose/wikipedia/Emotion.txt +9 -0
- package/corpus/prose/wikipedia/Eye.txt +5 -0
- package/corpus/prose/wikipedia/Family.txt +3 -0
- package/corpus/prose/wikipedia/Farm.txt +4 -0
- package/corpus/prose/wikipedia/Fear.txt +4 -0
- package/corpus/prose/wikipedia/First-order_logic.txt +1518 -0
- package/corpus/prose/wikipedia/Fish.txt +10 -0
- package/corpus/prose/wikipedia/Flower.txt +3 -0
- package/corpus/prose/wikipedia/Food.txt +10 -0
- package/corpus/prose/wikipedia/Grass.txt +9 -0
- package/corpus/prose/wikipedia/Hand.txt +2 -0
- package/corpus/prose/wikipedia/Happiness.txt +3 -0
- package/corpus/prose/wikipedia/Heart.txt +4 -0
- package/corpus/prose/wikipedia/Horse.txt +4 -0
- package/corpus/prose/wikipedia/House.txt +6 -0
- package/corpus/prose/wikipedia/Human.txt +4 -0
- package/corpus/prose/wikipedia/Insect.txt +6 -0
- package/corpus/prose/wikipedia/Interactive_fiction.txt +112 -0
- package/corpus/prose/wikipedia/Knowledge.txt +5 -0
- package/corpus/prose/wikipedia/Knowledge_representation_and_reasoning.txt +87 -0
- package/corpus/prose/wikipedia/LICENSE-NOTICE +94 -0
- package/corpus/prose/wikipedia/Language.txt +10 -0
- package/corpus/prose/wikipedia/Learning.txt +4 -0
- package/corpus/prose/wikipedia/Mammal.txt +3 -0
- package/corpus/prose/wikipedia/Memory.txt +5 -0
- package/corpus/prose/wikipedia/Milk.txt +1 -0
- package/corpus/prose/wikipedia/Mountain.txt +1 -0
- package/corpus/prose/wikipedia/Natural_language_processing.txt +211 -0
- package/corpus/prose/wikipedia/Ostrich.txt +2 -0
- package/corpus/prose/wikipedia/Owl.txt +2 -0
- package/corpus/prose/wikipedia/Penguin.txt +2 -0
- package/corpus/prose/wikipedia/Plant.txt +5 -0
- package/corpus/prose/wikipedia/Rain.txt +1 -0
- package/corpus/prose/wikipedia/Resource_Description_Framework.txt +184 -0
- package/corpus/prose/wikipedia/River.txt +1 -0
- package/corpus/prose/wikipedia/School.txt +8 -0
- package/corpus/prose/wikipedia/Sea.txt +1 -0
- package/corpus/prose/wikipedia/Semantic_Web.txt +114 -0
- package/corpus/prose/wikipedia/Semantic_reasoner.txt +29 -0
- package/corpus/prose/wikipedia/Snow.txt +5 -0
- package/corpus/prose/wikipedia/Sun.txt +5 -0
- package/corpus/prose/wikipedia/Teacher.txt +4 -0
- package/corpus/prose/wikipedia/Team.txt +3 -0
- package/corpus/prose/wikipedia/Text-based_game.txt +17 -0
- package/corpus/prose/wikipedia/Tool.txt +4 -0
- package/corpus/prose/wikipedia/Tree.txt +7 -0
- package/corpus/prose/wikipedia/Weather.txt +4 -0
- package/corpus/prose/wikipedia/Web_Ontology_Language.txt +133 -0
- package/corpus/prose/wikipedia/Wind.txt +8 -0
- package/corpus/prose/wikipedia/Writing.txt +5 -0
- package/package.json +2 -1
|
@@ -0,0 +1,1339 @@
|
|
|
1
|
+
CREATE TABLE
|
|
2
|
+
Small. Fast. Reliable.
|
|
3
|
+
Choose any three.
|
|
4
|
+
Home
|
|
5
|
+
Menu
|
|
6
|
+
About
|
|
7
|
+
Documentation
|
|
8
|
+
Download
|
|
9
|
+
License
|
|
10
|
+
Support
|
|
11
|
+
Purchase
|
|
12
|
+
Search
|
|
13
|
+
About
|
|
14
|
+
Documentation
|
|
15
|
+
Download
|
|
16
|
+
Support
|
|
17
|
+
Purchase
|
|
18
|
+
Search Documentation
|
|
19
|
+
Search Changelog
|
|
20
|
+
CREATE TABLE
|
|
21
|
+
Table Of Contents
|
|
22
|
+
1. Syntax
|
|
23
|
+
2. The CREATE TABLE command
|
|
24
|
+
2.1. CREATE TABLE ... AS SELECT Statements
|
|
25
|
+
3. Column Definitions
|
|
26
|
+
3.1. Column Data Types
|
|
27
|
+
3.2. The DEFAULT clause
|
|
28
|
+
3.3. The COLLATE clause
|
|
29
|
+
3.4. The GENERATED ALWAYS AS clause
|
|
30
|
+
3.5. The PRIMARY KEY
|
|
31
|
+
3.6. UNIQUE constraints
|
|
32
|
+
3.7. CHECK constraints
|
|
33
|
+
3.8. NOT NULL constraints
|
|
34
|
+
4. Constraint enforcement
|
|
35
|
+
4.1. Response to constraint violations
|
|
36
|
+
5. ROWIDs and the INTEGER PRIMARY KEY
|
|
37
|
+
1. Syntax
|
|
38
|
+
create-table-stmt:
|
|
39
|
+
hide
|
|
40
|
+
CREATE
|
|
41
|
+
TEMP
|
|
42
|
+
TEMPORARY
|
|
43
|
+
TABLE
|
|
44
|
+
IF
|
|
45
|
+
NOT
|
|
46
|
+
EXISTS
|
|
47
|
+
schema-name
|
|
48
|
+
.
|
|
49
|
+
table-name
|
|
50
|
+
(
|
|
51
|
+
column-def
|
|
52
|
+
table-constraint
|
|
53
|
+
,
|
|
54
|
+
)
|
|
55
|
+
table-options
|
|
56
|
+
,
|
|
57
|
+
AS
|
|
58
|
+
select-stmt
|
|
59
|
+
column-def:
|
|
60
|
+
show
|
|
61
|
+
column-name
|
|
62
|
+
type-name
|
|
63
|
+
column-constraint
|
|
64
|
+
column-constraint:
|
|
65
|
+
show
|
|
66
|
+
CONSTRAINT
|
|
67
|
+
name
|
|
68
|
+
PRIMARY
|
|
69
|
+
KEY
|
|
70
|
+
DESC
|
|
71
|
+
conflict-clause
|
|
72
|
+
AUTOINCREMENT
|
|
73
|
+
ASC
|
|
74
|
+
NOT
|
|
75
|
+
NULL
|
|
76
|
+
conflict-clause
|
|
77
|
+
UNIQUE
|
|
78
|
+
conflict-clause
|
|
79
|
+
CHECK
|
|
80
|
+
(
|
|
81
|
+
expr
|
|
82
|
+
)
|
|
83
|
+
DEFAULT
|
|
84
|
+
(
|
|
85
|
+
expr
|
|
86
|
+
)
|
|
87
|
+
literal-value
|
|
88
|
+
signed-number
|
|
89
|
+
COLLATE
|
|
90
|
+
collation-name
|
|
91
|
+
foreign-key-clause
|
|
92
|
+
GENERATED
|
|
93
|
+
ALWAYS
|
|
94
|
+
AS
|
|
95
|
+
(
|
|
96
|
+
expr
|
|
97
|
+
)
|
|
98
|
+
VIRTUAL
|
|
99
|
+
STORED
|
|
100
|
+
conflict-clause:
|
|
101
|
+
show
|
|
102
|
+
ON
|
|
103
|
+
CONFLICT
|
|
104
|
+
ROLLBACK
|
|
105
|
+
ABORT
|
|
106
|
+
FAIL
|
|
107
|
+
IGNORE
|
|
108
|
+
REPLACE
|
|
109
|
+
expr:
|
|
110
|
+
show
|
|
111
|
+
literal-value
|
|
112
|
+
bind-parameter
|
|
113
|
+
schema-name
|
|
114
|
+
.
|
|
115
|
+
table-name
|
|
116
|
+
.
|
|
117
|
+
column-name
|
|
118
|
+
unary-operator
|
|
119
|
+
expr
|
|
120
|
+
expr
|
|
121
|
+
binary-operator
|
|
122
|
+
expr
|
|
123
|
+
function-name
|
|
124
|
+
(
|
|
125
|
+
function-arguments
|
|
126
|
+
)
|
|
127
|
+
filter-clause
|
|
128
|
+
over-clause
|
|
129
|
+
(
|
|
130
|
+
expr
|
|
131
|
+
)
|
|
132
|
+
,
|
|
133
|
+
CAST
|
|
134
|
+
(
|
|
135
|
+
expr
|
|
136
|
+
AS
|
|
137
|
+
type-name
|
|
138
|
+
)
|
|
139
|
+
expr
|
|
140
|
+
COLLATE
|
|
141
|
+
collation-name
|
|
142
|
+
expr
|
|
143
|
+
NOT
|
|
144
|
+
LIKE
|
|
145
|
+
GLOB
|
|
146
|
+
REGEXP
|
|
147
|
+
MATCH
|
|
148
|
+
expr
|
|
149
|
+
expr
|
|
150
|
+
ESCAPE
|
|
151
|
+
expr
|
|
152
|
+
expr
|
|
153
|
+
ISNULL
|
|
154
|
+
NOTNULL
|
|
155
|
+
NOT
|
|
156
|
+
NULL
|
|
157
|
+
expr
|
|
158
|
+
IS
|
|
159
|
+
NOT
|
|
160
|
+
DISTINCT
|
|
161
|
+
FROM
|
|
162
|
+
expr
|
|
163
|
+
expr
|
|
164
|
+
NOT
|
|
165
|
+
BETWEEN
|
|
166
|
+
expr
|
|
167
|
+
AND
|
|
168
|
+
expr
|
|
169
|
+
expr
|
|
170
|
+
NOT
|
|
171
|
+
IN
|
|
172
|
+
(
|
|
173
|
+
select-stmt
|
|
174
|
+
)
|
|
175
|
+
expr
|
|
176
|
+
,
|
|
177
|
+
schema-name
|
|
178
|
+
.
|
|
179
|
+
table-function
|
|
180
|
+
(
|
|
181
|
+
expr
|
|
182
|
+
)
|
|
183
|
+
table-name
|
|
184
|
+
,
|
|
185
|
+
NOT
|
|
186
|
+
EXISTS
|
|
187
|
+
(
|
|
188
|
+
select-stmt
|
|
189
|
+
)
|
|
190
|
+
CASE
|
|
191
|
+
expr
|
|
192
|
+
WHEN
|
|
193
|
+
expr
|
|
194
|
+
THEN
|
|
195
|
+
expr
|
|
196
|
+
ELSE
|
|
197
|
+
expr
|
|
198
|
+
END
|
|
199
|
+
raise-function
|
|
200
|
+
filter-clause:
|
|
201
|
+
show
|
|
202
|
+
FILTER
|
|
203
|
+
(
|
|
204
|
+
WHERE
|
|
205
|
+
expr
|
|
206
|
+
)
|
|
207
|
+
function-arguments:
|
|
208
|
+
show
|
|
209
|
+
DISTINCT
|
|
210
|
+
expr
|
|
211
|
+
,
|
|
212
|
+
*
|
|
213
|
+
ORDER
|
|
214
|
+
BY
|
|
215
|
+
ordering-term
|
|
216
|
+
,
|
|
217
|
+
ordering-term:
|
|
218
|
+
show
|
|
219
|
+
expr
|
|
220
|
+
COLLATE
|
|
221
|
+
collation-name
|
|
222
|
+
DESC
|
|
223
|
+
ASC
|
|
224
|
+
NULLS
|
|
225
|
+
FIRST
|
|
226
|
+
NULLS
|
|
227
|
+
LAST
|
|
228
|
+
over-clause:
|
|
229
|
+
show
|
|
230
|
+
OVER
|
|
231
|
+
window-name
|
|
232
|
+
(
|
|
233
|
+
base-window-name
|
|
234
|
+
PARTITION
|
|
235
|
+
BY
|
|
236
|
+
expr
|
|
237
|
+
,
|
|
238
|
+
ORDER
|
|
239
|
+
BY
|
|
240
|
+
ordering-term
|
|
241
|
+
,
|
|
242
|
+
frame-spec
|
|
243
|
+
)
|
|
244
|
+
frame-spec:
|
|
245
|
+
show
|
|
246
|
+
GROUPS
|
|
247
|
+
BETWEEN
|
|
248
|
+
UNBOUNDED
|
|
249
|
+
PRECEDING
|
|
250
|
+
AND
|
|
251
|
+
UNBOUNDED
|
|
252
|
+
FOLLOWING
|
|
253
|
+
RANGE
|
|
254
|
+
ROWS
|
|
255
|
+
UNBOUNDED
|
|
256
|
+
PRECEDING
|
|
257
|
+
expr
|
|
258
|
+
PRECEDING
|
|
259
|
+
CURRENT
|
|
260
|
+
ROW
|
|
261
|
+
expr
|
|
262
|
+
PRECEDING
|
|
263
|
+
CURRENT
|
|
264
|
+
ROW
|
|
265
|
+
expr
|
|
266
|
+
FOLLOWING
|
|
267
|
+
expr
|
|
268
|
+
PRECEDING
|
|
269
|
+
CURRENT
|
|
270
|
+
ROW
|
|
271
|
+
expr
|
|
272
|
+
FOLLOWING
|
|
273
|
+
EXCLUDE
|
|
274
|
+
CURRENT
|
|
275
|
+
ROW
|
|
276
|
+
EXCLUDE
|
|
277
|
+
GROUP
|
|
278
|
+
EXCLUDE
|
|
279
|
+
TIES
|
|
280
|
+
EXCLUDE
|
|
281
|
+
NO
|
|
282
|
+
OTHERS
|
|
283
|
+
ordering-term:
|
|
284
|
+
show
|
|
285
|
+
expr
|
|
286
|
+
COLLATE
|
|
287
|
+
collation-name
|
|
288
|
+
DESC
|
|
289
|
+
ASC
|
|
290
|
+
NULLS
|
|
291
|
+
FIRST
|
|
292
|
+
NULLS
|
|
293
|
+
LAST
|
|
294
|
+
raise-function:
|
|
295
|
+
show
|
|
296
|
+
RAISE
|
|
297
|
+
(
|
|
298
|
+
ROLLBACK
|
|
299
|
+
,
|
|
300
|
+
expr
|
|
301
|
+
)
|
|
302
|
+
IGNORE
|
|
303
|
+
ABORT
|
|
304
|
+
FAIL
|
|
305
|
+
foreign-key-clause:
|
|
306
|
+
show
|
|
307
|
+
REFERENCES
|
|
308
|
+
foreign-table
|
|
309
|
+
(
|
|
310
|
+
column-name
|
|
311
|
+
)
|
|
312
|
+
,
|
|
313
|
+
ON
|
|
314
|
+
DELETE
|
|
315
|
+
SET
|
|
316
|
+
NULL
|
|
317
|
+
UPDATE
|
|
318
|
+
SET
|
|
319
|
+
DEFAULT
|
|
320
|
+
CASCADE
|
|
321
|
+
RESTRICT
|
|
322
|
+
NO
|
|
323
|
+
ACTION
|
|
324
|
+
MATCH
|
|
325
|
+
name
|
|
326
|
+
NOT
|
|
327
|
+
DEFERRABLE
|
|
328
|
+
INITIALLY
|
|
329
|
+
DEFERRED
|
|
330
|
+
INITIALLY
|
|
331
|
+
IMMEDIATE
|
|
332
|
+
literal-value:
|
|
333
|
+
show
|
|
334
|
+
CURRENT_TIMESTAMP
|
|
335
|
+
numeric-literal
|
|
336
|
+
string-literal
|
|
337
|
+
blob-literal
|
|
338
|
+
NULL
|
|
339
|
+
TRUE
|
|
340
|
+
FALSE
|
|
341
|
+
CURRENT_TIME
|
|
342
|
+
CURRENT_DATE
|
|
343
|
+
signed-number:
|
|
344
|
+
show
|
|
345
|
+
+
|
|
346
|
+
numeric-literal
|
|
347
|
+
-
|
|
348
|
+
type-name:
|
|
349
|
+
show
|
|
350
|
+
name
|
|
351
|
+
(
|
|
352
|
+
signed-number
|
|
353
|
+
,
|
|
354
|
+
signed-number
|
|
355
|
+
)
|
|
356
|
+
(
|
|
357
|
+
signed-number
|
|
358
|
+
)
|
|
359
|
+
signed-number:
|
|
360
|
+
show
|
|
361
|
+
+
|
|
362
|
+
numeric-literal
|
|
363
|
+
-
|
|
364
|
+
select-stmt:
|
|
365
|
+
show
|
|
366
|
+
WITH
|
|
367
|
+
RECURSIVE
|
|
368
|
+
common-table-expression
|
|
369
|
+
,
|
|
370
|
+
SELECT
|
|
371
|
+
DISTINCT
|
|
372
|
+
result-column
|
|
373
|
+
,
|
|
374
|
+
ALL
|
|
375
|
+
FROM
|
|
376
|
+
table-or-subquery
|
|
377
|
+
join-clause
|
|
378
|
+
,
|
|
379
|
+
WHERE
|
|
380
|
+
expr
|
|
381
|
+
GROUP
|
|
382
|
+
BY
|
|
383
|
+
expr
|
|
384
|
+
HAVING
|
|
385
|
+
expr
|
|
386
|
+
,
|
|
387
|
+
WINDOW
|
|
388
|
+
window-name
|
|
389
|
+
AS
|
|
390
|
+
window-defn
|
|
391
|
+
,
|
|
392
|
+
VALUES
|
|
393
|
+
(
|
|
394
|
+
expr
|
|
395
|
+
)
|
|
396
|
+
,
|
|
397
|
+
,
|
|
398
|
+
compound-operator
|
|
399
|
+
select-core
|
|
400
|
+
ORDER
|
|
401
|
+
BY
|
|
402
|
+
LIMIT
|
|
403
|
+
expr
|
|
404
|
+
ordering-term
|
|
405
|
+
,
|
|
406
|
+
OFFSET
|
|
407
|
+
expr
|
|
408
|
+
,
|
|
409
|
+
expr
|
|
410
|
+
common-table-expression:
|
|
411
|
+
show
|
|
412
|
+
table-name
|
|
413
|
+
(
|
|
414
|
+
column-name
|
|
415
|
+
)
|
|
416
|
+
AS
|
|
417
|
+
NOT
|
|
418
|
+
MATERIALIZED
|
|
419
|
+
(
|
|
420
|
+
select-stmt
|
|
421
|
+
)
|
|
422
|
+
,
|
|
423
|
+
compound-operator:
|
|
424
|
+
show
|
|
425
|
+
UNION
|
|
426
|
+
UNION
|
|
427
|
+
INTERSECT
|
|
428
|
+
EXCEPT
|
|
429
|
+
ALL
|
|
430
|
+
expr:
|
|
431
|
+
show
|
|
432
|
+
literal-value
|
|
433
|
+
bind-parameter
|
|
434
|
+
schema-name
|
|
435
|
+
.
|
|
436
|
+
table-name
|
|
437
|
+
.
|
|
438
|
+
column-name
|
|
439
|
+
unary-operator
|
|
440
|
+
expr
|
|
441
|
+
expr
|
|
442
|
+
binary-operator
|
|
443
|
+
expr
|
|
444
|
+
function-name
|
|
445
|
+
(
|
|
446
|
+
function-arguments
|
|
447
|
+
)
|
|
448
|
+
filter-clause
|
|
449
|
+
over-clause
|
|
450
|
+
(
|
|
451
|
+
expr
|
|
452
|
+
)
|
|
453
|
+
,
|
|
454
|
+
CAST
|
|
455
|
+
(
|
|
456
|
+
expr
|
|
457
|
+
AS
|
|
458
|
+
type-name
|
|
459
|
+
)
|
|
460
|
+
expr
|
|
461
|
+
COLLATE
|
|
462
|
+
collation-name
|
|
463
|
+
expr
|
|
464
|
+
NOT
|
|
465
|
+
LIKE
|
|
466
|
+
GLOB
|
|
467
|
+
REGEXP
|
|
468
|
+
MATCH
|
|
469
|
+
expr
|
|
470
|
+
expr
|
|
471
|
+
ESCAPE
|
|
472
|
+
expr
|
|
473
|
+
expr
|
|
474
|
+
ISNULL
|
|
475
|
+
NOTNULL
|
|
476
|
+
NOT
|
|
477
|
+
NULL
|
|
478
|
+
expr
|
|
479
|
+
IS
|
|
480
|
+
NOT
|
|
481
|
+
DISTINCT
|
|
482
|
+
FROM
|
|
483
|
+
expr
|
|
484
|
+
expr
|
|
485
|
+
NOT
|
|
486
|
+
BETWEEN
|
|
487
|
+
expr
|
|
488
|
+
AND
|
|
489
|
+
expr
|
|
490
|
+
expr
|
|
491
|
+
NOT
|
|
492
|
+
IN
|
|
493
|
+
(
|
|
494
|
+
select-stmt
|
|
495
|
+
)
|
|
496
|
+
expr
|
|
497
|
+
,
|
|
498
|
+
schema-name
|
|
499
|
+
.
|
|
500
|
+
table-function
|
|
501
|
+
(
|
|
502
|
+
expr
|
|
503
|
+
)
|
|
504
|
+
table-name
|
|
505
|
+
,
|
|
506
|
+
NOT
|
|
507
|
+
EXISTS
|
|
508
|
+
(
|
|
509
|
+
select-stmt
|
|
510
|
+
)
|
|
511
|
+
CASE
|
|
512
|
+
expr
|
|
513
|
+
WHEN
|
|
514
|
+
expr
|
|
515
|
+
THEN
|
|
516
|
+
expr
|
|
517
|
+
ELSE
|
|
518
|
+
expr
|
|
519
|
+
END
|
|
520
|
+
raise-function
|
|
521
|
+
filter-clause:
|
|
522
|
+
show
|
|
523
|
+
FILTER
|
|
524
|
+
(
|
|
525
|
+
WHERE
|
|
526
|
+
expr
|
|
527
|
+
)
|
|
528
|
+
function-arguments:
|
|
529
|
+
show
|
|
530
|
+
DISTINCT
|
|
531
|
+
expr
|
|
532
|
+
,
|
|
533
|
+
*
|
|
534
|
+
ORDER
|
|
535
|
+
BY
|
|
536
|
+
ordering-term
|
|
537
|
+
,
|
|
538
|
+
literal-value:
|
|
539
|
+
show
|
|
540
|
+
CURRENT_TIMESTAMP
|
|
541
|
+
numeric-literal
|
|
542
|
+
string-literal
|
|
543
|
+
blob-literal
|
|
544
|
+
NULL
|
|
545
|
+
TRUE
|
|
546
|
+
FALSE
|
|
547
|
+
CURRENT_TIME
|
|
548
|
+
CURRENT_DATE
|
|
549
|
+
over-clause:
|
|
550
|
+
show
|
|
551
|
+
OVER
|
|
552
|
+
window-name
|
|
553
|
+
(
|
|
554
|
+
base-window-name
|
|
555
|
+
PARTITION
|
|
556
|
+
BY
|
|
557
|
+
expr
|
|
558
|
+
,
|
|
559
|
+
ORDER
|
|
560
|
+
BY
|
|
561
|
+
ordering-term
|
|
562
|
+
,
|
|
563
|
+
frame-spec
|
|
564
|
+
)
|
|
565
|
+
frame-spec:
|
|
566
|
+
show
|
|
567
|
+
GROUPS
|
|
568
|
+
BETWEEN
|
|
569
|
+
UNBOUNDED
|
|
570
|
+
PRECEDING
|
|
571
|
+
AND
|
|
572
|
+
UNBOUNDED
|
|
573
|
+
FOLLOWING
|
|
574
|
+
RANGE
|
|
575
|
+
ROWS
|
|
576
|
+
UNBOUNDED
|
|
577
|
+
PRECEDING
|
|
578
|
+
expr
|
|
579
|
+
PRECEDING
|
|
580
|
+
CURRENT
|
|
581
|
+
ROW
|
|
582
|
+
expr
|
|
583
|
+
PRECEDING
|
|
584
|
+
CURRENT
|
|
585
|
+
ROW
|
|
586
|
+
expr
|
|
587
|
+
FOLLOWING
|
|
588
|
+
expr
|
|
589
|
+
PRECEDING
|
|
590
|
+
CURRENT
|
|
591
|
+
ROW
|
|
592
|
+
expr
|
|
593
|
+
FOLLOWING
|
|
594
|
+
EXCLUDE
|
|
595
|
+
CURRENT
|
|
596
|
+
ROW
|
|
597
|
+
EXCLUDE
|
|
598
|
+
GROUP
|
|
599
|
+
EXCLUDE
|
|
600
|
+
TIES
|
|
601
|
+
EXCLUDE
|
|
602
|
+
NO
|
|
603
|
+
OTHERS
|
|
604
|
+
raise-function:
|
|
605
|
+
show
|
|
606
|
+
RAISE
|
|
607
|
+
(
|
|
608
|
+
ROLLBACK
|
|
609
|
+
,
|
|
610
|
+
expr
|
|
611
|
+
)
|
|
612
|
+
IGNORE
|
|
613
|
+
ABORT
|
|
614
|
+
FAIL
|
|
615
|
+
type-name:
|
|
616
|
+
show
|
|
617
|
+
name
|
|
618
|
+
(
|
|
619
|
+
signed-number
|
|
620
|
+
,
|
|
621
|
+
signed-number
|
|
622
|
+
)
|
|
623
|
+
(
|
|
624
|
+
signed-number
|
|
625
|
+
)
|
|
626
|
+
signed-number:
|
|
627
|
+
show
|
|
628
|
+
+
|
|
629
|
+
numeric-literal
|
|
630
|
+
-
|
|
631
|
+
join-clause:
|
|
632
|
+
show
|
|
633
|
+
table-or-subquery
|
|
634
|
+
join-operator
|
|
635
|
+
table-or-subquery
|
|
636
|
+
join-constraint
|
|
637
|
+
join-constraint:
|
|
638
|
+
show
|
|
639
|
+
USING
|
|
640
|
+
(
|
|
641
|
+
column-name
|
|
642
|
+
)
|
|
643
|
+
,
|
|
644
|
+
ON
|
|
645
|
+
expr
|
|
646
|
+
join-operator:
|
|
647
|
+
show
|
|
648
|
+
NATURAL
|
|
649
|
+
LEFT
|
|
650
|
+
OUTER
|
|
651
|
+
JOIN
|
|
652
|
+
,
|
|
653
|
+
RIGHT
|
|
654
|
+
FULL
|
|
655
|
+
INNER
|
|
656
|
+
CROSS
|
|
657
|
+
ordering-term:
|
|
658
|
+
show
|
|
659
|
+
expr
|
|
660
|
+
COLLATE
|
|
661
|
+
collation-name
|
|
662
|
+
DESC
|
|
663
|
+
ASC
|
|
664
|
+
NULLS
|
|
665
|
+
FIRST
|
|
666
|
+
NULLS
|
|
667
|
+
LAST
|
|
668
|
+
result-column:
|
|
669
|
+
show
|
|
670
|
+
expr
|
|
671
|
+
AS
|
|
672
|
+
column-alias
|
|
673
|
+
*
|
|
674
|
+
table-name
|
|
675
|
+
.
|
|
676
|
+
*
|
|
677
|
+
table-or-subquery:
|
|
678
|
+
show
|
|
679
|
+
schema-name
|
|
680
|
+
.
|
|
681
|
+
table-name
|
|
682
|
+
AS
|
|
683
|
+
table-alias
|
|
684
|
+
INDEXED
|
|
685
|
+
BY
|
|
686
|
+
index-name
|
|
687
|
+
NOT
|
|
688
|
+
INDEXED
|
|
689
|
+
table-function-name
|
|
690
|
+
(
|
|
691
|
+
expr
|
|
692
|
+
)
|
|
693
|
+
,
|
|
694
|
+
AS
|
|
695
|
+
table-alias
|
|
696
|
+
(
|
|
697
|
+
select-stmt
|
|
698
|
+
)
|
|
699
|
+
(
|
|
700
|
+
table-or-subquery
|
|
701
|
+
)
|
|
702
|
+
,
|
|
703
|
+
join-clause
|
|
704
|
+
window-defn:
|
|
705
|
+
show
|
|
706
|
+
(
|
|
707
|
+
base-window-name
|
|
708
|
+
PARTITION
|
|
709
|
+
BY
|
|
710
|
+
expr
|
|
711
|
+
,
|
|
712
|
+
ORDER
|
|
713
|
+
BY
|
|
714
|
+
ordering-term
|
|
715
|
+
,
|
|
716
|
+
frame-spec
|
|
717
|
+
)
|
|
718
|
+
frame-spec:
|
|
719
|
+
show
|
|
720
|
+
GROUPS
|
|
721
|
+
BETWEEN
|
|
722
|
+
UNBOUNDED
|
|
723
|
+
PRECEDING
|
|
724
|
+
AND
|
|
725
|
+
UNBOUNDED
|
|
726
|
+
FOLLOWING
|
|
727
|
+
RANGE
|
|
728
|
+
ROWS
|
|
729
|
+
UNBOUNDED
|
|
730
|
+
PRECEDING
|
|
731
|
+
expr
|
|
732
|
+
PRECEDING
|
|
733
|
+
CURRENT
|
|
734
|
+
ROW
|
|
735
|
+
expr
|
|
736
|
+
PRECEDING
|
|
737
|
+
CURRENT
|
|
738
|
+
ROW
|
|
739
|
+
expr
|
|
740
|
+
FOLLOWING
|
|
741
|
+
expr
|
|
742
|
+
PRECEDING
|
|
743
|
+
CURRENT
|
|
744
|
+
ROW
|
|
745
|
+
expr
|
|
746
|
+
FOLLOWING
|
|
747
|
+
EXCLUDE
|
|
748
|
+
CURRENT
|
|
749
|
+
ROW
|
|
750
|
+
EXCLUDE
|
|
751
|
+
GROUP
|
|
752
|
+
EXCLUDE
|
|
753
|
+
TIES
|
|
754
|
+
EXCLUDE
|
|
755
|
+
NO
|
|
756
|
+
OTHERS
|
|
757
|
+
table-constraint:
|
|
758
|
+
show
|
|
759
|
+
CONSTRAINT
|
|
760
|
+
name
|
|
761
|
+
PRIMARY
|
|
762
|
+
KEY
|
|
763
|
+
(
|
|
764
|
+
indexed-column
|
|
765
|
+
AUTOINCREMENT
|
|
766
|
+
)
|
|
767
|
+
UNIQUE
|
|
768
|
+
(
|
|
769
|
+
indexed-column
|
|
770
|
+
)
|
|
771
|
+
conflict-clause
|
|
772
|
+
,
|
|
773
|
+
CHECK
|
|
774
|
+
(
|
|
775
|
+
expr
|
|
776
|
+
)
|
|
777
|
+
FOREIGN
|
|
778
|
+
KEY
|
|
779
|
+
(
|
|
780
|
+
column-name
|
|
781
|
+
)
|
|
782
|
+
foreign-key-clause
|
|
783
|
+
,
|
|
784
|
+
conflict-clause:
|
|
785
|
+
show
|
|
786
|
+
ON
|
|
787
|
+
CONFLICT
|
|
788
|
+
ROLLBACK
|
|
789
|
+
ABORT
|
|
790
|
+
FAIL
|
|
791
|
+
IGNORE
|
|
792
|
+
REPLACE
|
|
793
|
+
expr:
|
|
794
|
+
show
|
|
795
|
+
literal-value
|
|
796
|
+
bind-parameter
|
|
797
|
+
schema-name
|
|
798
|
+
.
|
|
799
|
+
table-name
|
|
800
|
+
.
|
|
801
|
+
column-name
|
|
802
|
+
unary-operator
|
|
803
|
+
expr
|
|
804
|
+
expr
|
|
805
|
+
binary-operator
|
|
806
|
+
expr
|
|
807
|
+
function-name
|
|
808
|
+
(
|
|
809
|
+
function-arguments
|
|
810
|
+
)
|
|
811
|
+
filter-clause
|
|
812
|
+
over-clause
|
|
813
|
+
(
|
|
814
|
+
expr
|
|
815
|
+
)
|
|
816
|
+
,
|
|
817
|
+
CAST
|
|
818
|
+
(
|
|
819
|
+
expr
|
|
820
|
+
AS
|
|
821
|
+
type-name
|
|
822
|
+
)
|
|
823
|
+
expr
|
|
824
|
+
COLLATE
|
|
825
|
+
collation-name
|
|
826
|
+
expr
|
|
827
|
+
NOT
|
|
828
|
+
LIKE
|
|
829
|
+
GLOB
|
|
830
|
+
REGEXP
|
|
831
|
+
MATCH
|
|
832
|
+
expr
|
|
833
|
+
expr
|
|
834
|
+
ESCAPE
|
|
835
|
+
expr
|
|
836
|
+
expr
|
|
837
|
+
ISNULL
|
|
838
|
+
NOTNULL
|
|
839
|
+
NOT
|
|
840
|
+
NULL
|
|
841
|
+
expr
|
|
842
|
+
IS
|
|
843
|
+
NOT
|
|
844
|
+
DISTINCT
|
|
845
|
+
FROM
|
|
846
|
+
expr
|
|
847
|
+
expr
|
|
848
|
+
NOT
|
|
849
|
+
BETWEEN
|
|
850
|
+
expr
|
|
851
|
+
AND
|
|
852
|
+
expr
|
|
853
|
+
expr
|
|
854
|
+
NOT
|
|
855
|
+
IN
|
|
856
|
+
(
|
|
857
|
+
select-stmt
|
|
858
|
+
)
|
|
859
|
+
expr
|
|
860
|
+
,
|
|
861
|
+
schema-name
|
|
862
|
+
.
|
|
863
|
+
table-function
|
|
864
|
+
(
|
|
865
|
+
expr
|
|
866
|
+
)
|
|
867
|
+
table-name
|
|
868
|
+
,
|
|
869
|
+
NOT
|
|
870
|
+
EXISTS
|
|
871
|
+
(
|
|
872
|
+
select-stmt
|
|
873
|
+
)
|
|
874
|
+
CASE
|
|
875
|
+
expr
|
|
876
|
+
WHEN
|
|
877
|
+
expr
|
|
878
|
+
THEN
|
|
879
|
+
expr
|
|
880
|
+
ELSE
|
|
881
|
+
expr
|
|
882
|
+
END
|
|
883
|
+
raise-function
|
|
884
|
+
filter-clause:
|
|
885
|
+
show
|
|
886
|
+
FILTER
|
|
887
|
+
(
|
|
888
|
+
WHERE
|
|
889
|
+
expr
|
|
890
|
+
)
|
|
891
|
+
function-arguments:
|
|
892
|
+
show
|
|
893
|
+
DISTINCT
|
|
894
|
+
expr
|
|
895
|
+
,
|
|
896
|
+
*
|
|
897
|
+
ORDER
|
|
898
|
+
BY
|
|
899
|
+
ordering-term
|
|
900
|
+
,
|
|
901
|
+
ordering-term:
|
|
902
|
+
show
|
|
903
|
+
expr
|
|
904
|
+
COLLATE
|
|
905
|
+
collation-name
|
|
906
|
+
DESC
|
|
907
|
+
ASC
|
|
908
|
+
NULLS
|
|
909
|
+
FIRST
|
|
910
|
+
NULLS
|
|
911
|
+
LAST
|
|
912
|
+
literal-value:
|
|
913
|
+
show
|
|
914
|
+
CURRENT_TIMESTAMP
|
|
915
|
+
numeric-literal
|
|
916
|
+
string-literal
|
|
917
|
+
blob-literal
|
|
918
|
+
NULL
|
|
919
|
+
TRUE
|
|
920
|
+
FALSE
|
|
921
|
+
CURRENT_TIME
|
|
922
|
+
CURRENT_DATE
|
|
923
|
+
over-clause:
|
|
924
|
+
show
|
|
925
|
+
OVER
|
|
926
|
+
window-name
|
|
927
|
+
(
|
|
928
|
+
base-window-name
|
|
929
|
+
PARTITION
|
|
930
|
+
BY
|
|
931
|
+
expr
|
|
932
|
+
,
|
|
933
|
+
ORDER
|
|
934
|
+
BY
|
|
935
|
+
ordering-term
|
|
936
|
+
,
|
|
937
|
+
frame-spec
|
|
938
|
+
)
|
|
939
|
+
frame-spec:
|
|
940
|
+
show
|
|
941
|
+
GROUPS
|
|
942
|
+
BETWEEN
|
|
943
|
+
UNBOUNDED
|
|
944
|
+
PRECEDING
|
|
945
|
+
AND
|
|
946
|
+
UNBOUNDED
|
|
947
|
+
FOLLOWING
|
|
948
|
+
RANGE
|
|
949
|
+
ROWS
|
|
950
|
+
UNBOUNDED
|
|
951
|
+
PRECEDING
|
|
952
|
+
expr
|
|
953
|
+
PRECEDING
|
|
954
|
+
CURRENT
|
|
955
|
+
ROW
|
|
956
|
+
expr
|
|
957
|
+
PRECEDING
|
|
958
|
+
CURRENT
|
|
959
|
+
ROW
|
|
960
|
+
expr
|
|
961
|
+
FOLLOWING
|
|
962
|
+
expr
|
|
963
|
+
PRECEDING
|
|
964
|
+
CURRENT
|
|
965
|
+
ROW
|
|
966
|
+
expr
|
|
967
|
+
FOLLOWING
|
|
968
|
+
EXCLUDE
|
|
969
|
+
CURRENT
|
|
970
|
+
ROW
|
|
971
|
+
EXCLUDE
|
|
972
|
+
GROUP
|
|
973
|
+
EXCLUDE
|
|
974
|
+
TIES
|
|
975
|
+
EXCLUDE
|
|
976
|
+
NO
|
|
977
|
+
OTHERS
|
|
978
|
+
ordering-term:
|
|
979
|
+
show
|
|
980
|
+
expr
|
|
981
|
+
COLLATE
|
|
982
|
+
collation-name
|
|
983
|
+
DESC
|
|
984
|
+
ASC
|
|
985
|
+
NULLS
|
|
986
|
+
FIRST
|
|
987
|
+
NULLS
|
|
988
|
+
LAST
|
|
989
|
+
raise-function:
|
|
990
|
+
show
|
|
991
|
+
RAISE
|
|
992
|
+
(
|
|
993
|
+
ROLLBACK
|
|
994
|
+
,
|
|
995
|
+
expr
|
|
996
|
+
)
|
|
997
|
+
IGNORE
|
|
998
|
+
ABORT
|
|
999
|
+
FAIL
|
|
1000
|
+
type-name:
|
|
1001
|
+
show
|
|
1002
|
+
name
|
|
1003
|
+
(
|
|
1004
|
+
signed-number
|
|
1005
|
+
,
|
|
1006
|
+
signed-number
|
|
1007
|
+
)
|
|
1008
|
+
(
|
|
1009
|
+
signed-number
|
|
1010
|
+
)
|
|
1011
|
+
signed-number:
|
|
1012
|
+
show
|
|
1013
|
+
+
|
|
1014
|
+
numeric-literal
|
|
1015
|
+
-
|
|
1016
|
+
foreign-key-clause:
|
|
1017
|
+
show
|
|
1018
|
+
REFERENCES
|
|
1019
|
+
foreign-table
|
|
1020
|
+
(
|
|
1021
|
+
column-name
|
|
1022
|
+
)
|
|
1023
|
+
,
|
|
1024
|
+
ON
|
|
1025
|
+
DELETE
|
|
1026
|
+
SET
|
|
1027
|
+
NULL
|
|
1028
|
+
UPDATE
|
|
1029
|
+
SET
|
|
1030
|
+
DEFAULT
|
|
1031
|
+
CASCADE
|
|
1032
|
+
RESTRICT
|
|
1033
|
+
NO
|
|
1034
|
+
ACTION
|
|
1035
|
+
MATCH
|
|
1036
|
+
name
|
|
1037
|
+
NOT
|
|
1038
|
+
DEFERRABLE
|
|
1039
|
+
INITIALLY
|
|
1040
|
+
DEFERRED
|
|
1041
|
+
INITIALLY
|
|
1042
|
+
IMMEDIATE
|
|
1043
|
+
indexed-column:
|
|
1044
|
+
show
|
|
1045
|
+
column-name
|
|
1046
|
+
COLLATE
|
|
1047
|
+
collation-name
|
|
1048
|
+
DESC
|
|
1049
|
+
expr
|
|
1050
|
+
ASC
|
|
1051
|
+
table-options:
|
|
1052
|
+
show
|
|
1053
|
+
WITHOUT
|
|
1054
|
+
ROWID
|
|
1055
|
+
STRICT
|
|
1056
|
+
,
|
|
1057
|
+
2. The CREATE TABLE command
|
|
1058
|
+
The "CREATE TABLE" command is used to create a new table in an SQLite
|
|
1059
|
+
database. A CREATE TABLE command specifies the following attributes of the
|
|
1060
|
+
new table:
|
|
1061
|
+
The name of the new table.
|
|
1062
|
+
The database in which the new table is created. Tables may be
|
|
1063
|
+
created in the main database, the temp database, or in any attached
|
|
1064
|
+
database.
|
|
1065
|
+
The name of each column in the table.
|
|
1066
|
+
The declared type of each column in the table.
|
|
1067
|
+
A default value or expression for each column in the table.
|
|
1068
|
+
A default collation sequence to use with each column.
|
|
1069
|
+
An optional PRIMARY KEY for the table. Both single column and
|
|
1070
|
+
composite (multiple column) primary keys are supported.
|
|
1071
|
+
Zero or more constraints on the table content.
|
|
1072
|
+
SQLite supports UNIQUE, NOT NULL, CHECK and FOREIGN KEY constraints.
|
|
1073
|
+
Optionally, a generated column constraint.
|
|
1074
|
+
Whether the table is a WITHOUT ROWID table.
|
|
1075
|
+
Whether the table is subject to strict type checking .
|
|
1076
|
+
Every CREATE TABLE statement must specify a name for the new table.
|
|
1077
|
+
Table names that begin with "sqlite_" are reserved for internal use. It
|
|
1078
|
+
is an error to attempt to create a table with a name that starts with
|
|
1079
|
+
"sqlite_".
|
|
1080
|
+
If a schema-name is specified, it must be either "main",
|
|
1081
|
+
"temp", or the name of an attached database . In this case
|
|
1082
|
+
the new table is created in the named database. If the "TEMP" or "TEMPORARY"
|
|
1083
|
+
keyword occurs between the "CREATE" and "TABLE" then the new table is
|
|
1084
|
+
created in the temp database. It is an error to specify both a
|
|
1085
|
+
schema-name and the TEMP or TEMPORARY keyword, unless the
|
|
1086
|
+
schema-name is "temp".
|
|
1087
|
+
If no schema name is specified and the
|
|
1088
|
+
TEMP keyword is not present then the table is created in the main
|
|
1089
|
+
database.
|
|
1090
|
+
It is usually an error to attempt to create a new table in a database that
|
|
1091
|
+
already contains a table, index or view of the same name. However, if the
|
|
1092
|
+
"IF NOT EXISTS" clause is specified as part of the CREATE TABLE statement and
|
|
1093
|
+
a table or view of the same name already exists, the CREATE TABLE command
|
|
1094
|
+
simply has no effect (and no error message is returned). An error is still
|
|
1095
|
+
returned if the table cannot be created because of an existing index, even
|
|
1096
|
+
if the "IF NOT EXISTS" clause is specified.
|
|
1097
|
+
It is not an error to create a table that has the same name as an
|
|
1098
|
+
existing trigger .
|
|
1099
|
+
Tables are removed using the DROP TABLE statement.
|
|
1100
|
+
2.1. CREATE TABLE ... AS SELECT Statements
|
|
1101
|
+
A "CREATE TABLE ... AS SELECT" statement creates and populates a database
|
|
1102
|
+
table based on the results of a SELECT statement. The table has the same
|
|
1103
|
+
number of columns as the SELECT statement returns. The name of
|
|
1104
|
+
each column is the same as the name of the corresponding column in the result
|
|
1105
|
+
set of the SELECT statement. The declared type of each column is determined
|
|
1106
|
+
by the expression affinity of the corresponding expression in the result set
|
|
1107
|
+
of the SELECT statement, as follows:
|
|
1108
|
+
Expression Affinity Column Declared Type
|
|
1109
|
+
TEXT "TEXT"
|
|
1110
|
+
NUMERIC "NUM"
|
|
1111
|
+
INTEGER "INT"
|
|
1112
|
+
REAL "REAL"
|
|
1113
|
+
BLOB (a.k.a "NONE") "" (empty string)
|
|
1114
|
+
A table created using CREATE TABLE AS has no PRIMARY KEY and no
|
|
1115
|
+
constraints of any kind. The default value of each column is NULL. The default
|
|
1116
|
+
collation sequence for each column of the new table is BINARY.
|
|
1117
|
+
Tables created using CREATE TABLE AS are initially populated with the
|
|
1118
|
+
rows of data returned by the SELECT statement. Rows are assigned contiguously
|
|
1119
|
+
ascending rowid values, starting with 1, in the order that they
|
|
1120
|
+
are returned by the SELECT statement.
|
|
1121
|
+
3. Column Definitions
|
|
1122
|
+
Unless it is a CREATE TABLE ... AS SELECT statement, a CREATE TABLE includes
|
|
1123
|
+
one or more column definitions , optionally followed by a list of
|
|
1124
|
+
table constraints . Each column definition consists of the
|
|
1125
|
+
name of the column, optionally followed by the declared type of the column,
|
|
1126
|
+
then one or more optional column constraints . Included in
|
|
1127
|
+
the definition of "column constraints" for the purposes of the previous
|
|
1128
|
+
statement are the COLLATE and DEFAULT clauses, even though these are not really
|
|
1129
|
+
constraints in the sense that they do not restrict the data that the table may
|
|
1130
|
+
contain. The other constraints - NOT NULL, CHECK, UNIQUE, PRIMARY KEY and
|
|
1131
|
+
FOREIGN KEY constraints - impose restrictions on the table data.
|
|
1132
|
+
The number of columns in a table is limited by the SQLITE_MAX_COLUMN
|
|
1133
|
+
compile-time parameter. A single row of a table cannot store more than
|
|
1134
|
+
SQLITE_MAX_LENGTH bytes of data. Both of these limits can be lowered at
|
|
1135
|
+
runtime using the sqlite3_limit() C/C++ interface.
|
|
1136
|
+
3.1. Column Data Types
|
|
1137
|
+
Unlike most SQL databases, SQLite does not restrict the type of data that
|
|
1138
|
+
may be inserted into a column based on the columns declared type. Instead,
|
|
1139
|
+
SQLite uses dynamic typing . The declared type of a column is used to
|
|
1140
|
+
determine the affinity of the column only.
|
|
1141
|
+
3.2. The DEFAULT clause
|
|
1142
|
+
The DEFAULT clause specifies a default value to use for the column if no
|
|
1143
|
+
value is explicitly provided by the user when doing an INSERT . If there
|
|
1144
|
+
is no explicit DEFAULT clause attached to a column definition, then the
|
|
1145
|
+
default value of the column is NULL. An explicit DEFAULT clause may specify
|
|
1146
|
+
that the default value is NULL, a string constant, a blob constant, a
|
|
1147
|
+
signed-number, or any constant expression enclosed in parentheses. A
|
|
1148
|
+
default value may also be one of the special case-independent keywords
|
|
1149
|
+
CURRENT_TIME, CURRENT_DATE or CURRENT_TIMESTAMP. For the purposes of the
|
|
1150
|
+
DEFAULT clause, an expression is considered constant if it
|
|
1151
|
+
contains no sub-queries, column or table references, bound parameters ,
|
|
1152
|
+
or string literals enclosed in double-quotes instead of single-quotes.
|
|
1153
|
+
Each time a row is inserted into the table by an INSERT statement that
|
|
1154
|
+
does not provide explicit values for all table columns the values stored in
|
|
1155
|
+
the new row are determined by their default values, as follows:
|
|
1156
|
+
If the default value of the column is a constant NULL, text, blob or
|
|
1157
|
+
signed-number value, then that value is used directly in the new row.
|
|
1158
|
+
If the default value of a column is an expression in parentheses, then
|
|
1159
|
+
the expression is evaluated once for each row inserted and the results
|
|
1160
|
+
used in the new row.
|
|
1161
|
+
If the default value of a column is CURRENT_TIME, CURRENT_DATE or
|
|
1162
|
+
CURRENT_TIMESTAMP, then the value used in the new row is a text
|
|
1163
|
+
representation of the current UTC date and/or time. For CURRENT_TIME, the
|
|
1164
|
+
format of the value is "HH:MM:SS". For CURRENT_DATE, "YYYY-MM-DD". The
|
|
1165
|
+
format for CURRENT_TIMESTAMP is "YYYY-MM-DD HH:MM:SS".
|
|
1166
|
+
3.3. The COLLATE clause
|
|
1167
|
+
The COLLATE clause specifies the name of a collating sequence to use as
|
|
1168
|
+
the default collation sequence for the column. If no COLLATE clause is
|
|
1169
|
+
specified, the default collation sequence is BINARY .
|
|
1170
|
+
3.4. The GENERATED ALWAYS AS clause
|
|
1171
|
+
A column that includes a GENERATED ALWAYS AS clause is a generated column .
|
|
1172
|
+
Generated columns are supported beginning with SQLite version 3.31.0 (2020-01-22).
|
|
1173
|
+
See the separate documentation for details on the capabilities and
|
|
1174
|
+
limitations of generated columns.
|
|
1175
|
+
3.5. The PRIMARY KEY
|
|
1176
|
+
Each table in SQLite may have at most one PRIMARY KEY. If the
|
|
1177
|
+
keywords PRIMARY KEY are added to a column definition, then the primary key
|
|
1178
|
+
for the table consists of that single column. Or, if a PRIMARY KEY clause
|
|
1179
|
+
is specified as a table-constraint , then the primary key of the table
|
|
1180
|
+
consists of the list of columns specified as part of the PRIMARY KEY clause.
|
|
1181
|
+
The PRIMARY KEY clause must contain only column names — the use of
|
|
1182
|
+
expressions in an indexed-column of a PRIMARY KEY is not supported.
|
|
1183
|
+
An error is raised if more than one PRIMARY KEY clause appears in a
|
|
1184
|
+
CREATE TABLE statement. The PRIMARY KEY is optional for ordinary tables
|
|
1185
|
+
but is required for WITHOUT ROWID tables.
|
|
1186
|
+
If a table has a single column primary key and the declared type of that
|
|
1187
|
+
column is "INTEGER" and the table is not a WITHOUT ROWID table,
|
|
1188
|
+
then the column is known as an INTEGER PRIMARY KEY .
|
|
1189
|
+
See below for a description of the special properties and behaviors
|
|
1190
|
+
associated with an INTEGER PRIMARY KEY .
|
|
1191
|
+
Each row in a table with a primary key must have a unique combination
|
|
1192
|
+
of values in its primary key columns. For the purposes of determining
|
|
1193
|
+
the uniqueness of primary key values, NULL values are considered distinct from
|
|
1194
|
+
all other values, including other NULLs. If an INSERT or UPDATE
|
|
1195
|
+
statement attempts to modify the table content so that two or more rows
|
|
1196
|
+
have identical primary key values, that is a constraint violation.
|
|
1197
|
+
According to the SQL standard, PRIMARY KEY should always imply NOT NULL.
|
|
1198
|
+
Unfortunately, due to a bug in some early versions, this is not the
|
|
1199
|
+
case in SQLite. Unless the column is an INTEGER PRIMARY KEY or
|
|
1200
|
+
the table is a WITHOUT ROWID table or a STRICT table
|
|
1201
|
+
or the column is declared NOT NULL,
|
|
1202
|
+
SQLite allows NULL values in a PRIMARY KEY column. SQLite could be fixed to
|
|
1203
|
+
conform to the standard, but doing so might break legacy applications.
|
|
1204
|
+
Hence, it has been decided to merely document the fact that SQLite
|
|
1205
|
+
allows NULLs in most PRIMARY KEY columns.
|
|
1206
|
+
3.6. UNIQUE constraints
|
|
1207
|
+
A UNIQUE constraint is similar to a PRIMARY KEY constraint, except
|
|
1208
|
+
that a single table may have any number of UNIQUE constraints. For each
|
|
1209
|
+
UNIQUE constraint on the table, each row must contain a unique combination
|
|
1210
|
+
of values in the columns identified by the UNIQUE constraint.
|
|
1211
|
+
For the purposes of UNIQUE constraints, NULL values
|
|
1212
|
+
are considered distinct from all other values, including other NULLs.
|
|
1213
|
+
As with PRIMARY KEYs, a UNIQUE table-constraint clause must contain
|
|
1214
|
+
only column names — the use of
|
|
1215
|
+
expressions in an indexed-column of a UNIQUE table-constraint
|
|
1216
|
+
is not supported.
|
|
1217
|
+
In most cases, UNIQUE and PRIMARY KEY
|
|
1218
|
+
constraints are implemented by creating a unique index in the database.
|
|
1219
|
+
(The exceptions are INTEGER PRIMARY KEY and PRIMARY KEYs on
|
|
1220
|
+
WITHOUT ROWID tables.)
|
|
1221
|
+
Hence, the following schemas are logically equivalent:
|
|
1222
|
+
CREATE TABLE t1(a, b UNIQUE);
|
|
1223
|
+
CREATE TABLE t1(a, b PRIMARY KEY);
|
|
1224
|
+
CREATE TABLE t1(a, b);
|
|
1225
|
+
CREATE UNIQUE INDEX t1b ON t1(b);
|
|
1226
|
+
3.7. CHECK constraints
|
|
1227
|
+
A CHECK constraint may be attached to a column definition or
|
|
1228
|
+
specified as a table constraint. In practice it makes no difference. Each
|
|
1229
|
+
time a new row is inserted into the table or an existing row is updated,
|
|
1230
|
+
the expression associated with each CHECK constraint is evaluated and
|
|
1231
|
+
cast to a NUMERIC value in the same way as a CAST expression . If the
|
|
1232
|
+
result is zero (integer value 0 or real value 0.0), then a constraint
|
|
1233
|
+
violation has occurred. If the CHECK expression evaluates to NULL, or
|
|
1234
|
+
any other non-zero value, it is not a constraint violation.
|
|
1235
|
+
The expression of a CHECK constraint may not contain a subquery.
|
|
1236
|
+
CHECK constraints are only verified when the table is written, not when
|
|
1237
|
+
it is read. Furthermore, verification of CHECK constraints can be
|
|
1238
|
+
temporarily disabled using the " PRAGMA ignore_check_constraints=ON; "
|
|
1239
|
+
statement. Hence, it is possible that a query might produce results that
|
|
1240
|
+
violate the CHECK constraints.
|
|
1241
|
+
3.8. NOT NULL constraints
|
|
1242
|
+
A NOT NULL constraint may only be attached to a column definition,
|
|
1243
|
+
not specified as a table constraint. Not surprisingly, a NOT NULL
|
|
1244
|
+
constraint dictates that the associated column may not contain a NULL value.
|
|
1245
|
+
Attempting to set the column value to NULL when inserting a new row or
|
|
1246
|
+
updating an existing one causes a constraint violation. NOT NULL
|
|
1247
|
+
constraints are not verified during queries, so a query of a column might
|
|
1248
|
+
produce a NULL value even though the column is marked as NOT NULL, if the
|
|
1249
|
+
database file is corrupt.
|
|
1250
|
+
4. Constraint enforcement
|
|
1251
|
+
Constraints are checked during INSERT and UPDATE and by
|
|
1252
|
+
PRAGMA integrity_check and PRAGMA quick_check and sometimes
|
|
1253
|
+
by ALTER TABLE . Queries and DELETE
|
|
1254
|
+
statements do not normally verify constraints.
|
|
1255
|
+
Hence, if a database file has been corrupted (perhaps by an external
|
|
1256
|
+
program making direct changes to the database file without going through
|
|
1257
|
+
the SQLite library) a query might return data that violates a constraint.
|
|
1258
|
+
For example:
|
|
1259
|
+
Enforcement of CHECK constraints can be temporarily disabled using
|
|
1260
|
+
the PRAGMA ignore_check_constraints=ON; statement.
|
|
1261
|
+
4.1. Response to constraint violations
|
|
1262
|
+
The response to a constraint violation is determined by the
|
|
1263
|
+
constraint conflict resolution algorithm . Each
|
|
1264
|
+
PRIMARY KEY, UNIQUE, NOT NULL and CHECK constraint has a default conflict
|
|
1265
|
+
resolution algorithm. PRIMARY KEY, UNIQUE and NOT NULL constraints may be
|
|
1266
|
+
explicitly assigned another default conflict resolution algorithm by
|
|
1267
|
+
including a conflict-clause in their definitions.
|
|
1268
|
+
Or, if a constraint definition does not include a conflict-clause ,
|
|
1269
|
+
the default conflict resolution algorithm is ABORT.
|
|
1270
|
+
The conflict resolution algorithm for CHECK constraints is always ABORT.
|
|
1271
|
+
(For historical compatibility only, table CHECK constraints are allowed
|
|
1272
|
+
to have a conflict resolution clause, but that has no effect.)
|
|
1273
|
+
Different constraints within the
|
|
1274
|
+
same table may have different default conflict resolution algorithms. See
|
|
1275
|
+
the section titled ON CONFLICT for additional information.
|
|
1276
|
+
5. ROWIDs and the INTEGER PRIMARY KEY
|
|
1277
|
+
Except for WITHOUT ROWID tables, all rows within SQLite tables
|
|
1278
|
+
have a 64-bit signed integer key that uniquely identifies the row within its table.
|
|
1279
|
+
This integer is usually
|
|
1280
|
+
called the "rowid". The rowid value can be accessed using one of the special
|
|
1281
|
+
case-independent names "rowid", "oid", or "_rowid_" in place of a column name.
|
|
1282
|
+
If a table contains a user defined column named "rowid", "oid" or "_rowid_",
|
|
1283
|
+
then that name always refers the explicitly declared column and cannot be used
|
|
1284
|
+
to retrieve the integer rowid value.
|
|
1285
|
+
The rowid (and "oid" and "_rowid_") is omitted in WITHOUT ROWID tables.
|
|
1286
|
+
WITHOUT ROWID tables are only available in SQLite version 3.8.2
|
|
1287
|
+
(2013-12-06) and later.
|
|
1288
|
+
A table that lacks the WITHOUT ROWID clause is called a "rowid table".
|
|
1289
|
+
The data for rowid tables is stored as a B-Tree structure containing
|
|
1290
|
+
one entry for each table row, using the rowid value as the key. This means that
|
|
1291
|
+
retrieving or sorting records by rowid is fast. Searching for a record with a
|
|
1292
|
+
specific rowid, or for all records with rowids within a specified range is
|
|
1293
|
+
around twice as fast as a similar search made by specifying any other PRIMARY
|
|
1294
|
+
KEY or indexed value.
|
|
1295
|
+
With one exception noted below, if a rowid table has a primary key that consists
|
|
1296
|
+
of a single column and the declared type of that column is "INTEGER" in any mixture of
|
|
1297
|
+
upper and lower case, then the column becomes an alias for the rowid. Such a
|
|
1298
|
+
column is usually referred to as an "integer primary key". A PRIMARY KEY column
|
|
1299
|
+
only becomes an integer primary key if the declared type name is exactly
|
|
1300
|
+
"INTEGER". Other integer type names like "INT" or "BIGINT" or "SHORT INTEGER"
|
|
1301
|
+
or "UNSIGNED INTEGER" causes the primary key column to behave as an ordinary
|
|
1302
|
+
table column with integer affinity and a unique index, not as an alias for
|
|
1303
|
+
the rowid.
|
|
1304
|
+
The exception mentioned above is that if the declaration of a column with
|
|
1305
|
+
declared type "INTEGER" includes an "PRIMARY KEY DESC" clause, it does not
|
|
1306
|
+
become an alias for the rowid and is not classified as an integer primary key.
|
|
1307
|
+
This quirk is not by design. It is due to a bug in early versions of SQLite.
|
|
1308
|
+
But fixing the bug could result in backwards incompatibilities.
|
|
1309
|
+
Hence, the original behavior has been retained (and documented) because odd
|
|
1310
|
+
behavior in a corner case is far better than a compatibility break. This means
|
|
1311
|
+
that the following three table declarations all cause the column "x" to be an
|
|
1312
|
+
alias for the rowid (an integer primary key):
|
|
1313
|
+
CREATE TABLE t(x INTEGER PRIMARY KEY ASC, y, z);
|
|
1314
|
+
CREATE TABLE t(x INTEGER, y, z, PRIMARY KEY(x ASC));
|
|
1315
|
+
CREATE TABLE t(x INTEGER, y, z, PRIMARY KEY(x DESC));
|
|
1316
|
+
But the following declaration does not result in "x" being an alias for
|
|
1317
|
+
the rowid:
|
|
1318
|
+
CREATE TABLE t(x INTEGER PRIMARY KEY DESC, y, z);
|
|
1319
|
+
Rowid values may be modified using an UPDATE statement in the same
|
|
1320
|
+
way as any other column value can, either using one of the built-in aliases
|
|
1321
|
+
("rowid", "oid" or "_rowid_") or by using an alias created by an integer
|
|
1322
|
+
primary key. Similarly, an INSERT statement may provide a value to use as the
|
|
1323
|
+
rowid for each row inserted. Unlike normal SQLite columns, an integer primary
|
|
1324
|
+
key or rowid column must contain integer values. Integer primary key or rowid
|
|
1325
|
+
columns are not able to hold floating point values, strings, BLOBs, or NULLs.
|
|
1326
|
+
If an UPDATE statement attempts to set an integer primary key or rowid column
|
|
1327
|
+
to a NULL or blob value, or to a string or real value that cannot be losslessly
|
|
1328
|
+
converted to an integer, a "datatype mismatch" error occurs and the statement
|
|
1329
|
+
is aborted. If an INSERT statement attempts to insert a blob value, or a string
|
|
1330
|
+
or real value that cannot be losslessly converted to an integer into an
|
|
1331
|
+
integer primary key or rowid column, a "datatype mismatch" error occurs and the
|
|
1332
|
+
statement is aborted.
|
|
1333
|
+
If an INSERT statement attempts to insert a NULL value into a rowid or
|
|
1334
|
+
integer primary key column, the system chooses an integer value to use as the
|
|
1335
|
+
rowid automatically. A detailed description of how this is done is provided
|
|
1336
|
+
separately .
|
|
1337
|
+
The parent key of a foreign key constraint is not allowed to
|
|
1338
|
+
use the rowid. The parent key must use named columns only.
|
|
1339
|
+
This page was last updated on 2025-04-30 20:02:34Z
|