@polycode-projects/the-mechanical-code-talker 2.3.0 → 2.5.0
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/README.md +127 -28
- package/ROADMAP.md +3 -2
- package/bin/tmct.mjs +17 -90
- 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/corpus/seon/README.md +1 -0
- package/corpus/tier2/generate.mjs +18 -18
- package/corpus/tier2/manifest.json +3 -3
- package/data/games/hanoi-3.txt +8 -2
- package/package.json +24 -5
- package/src/adapters/corpus-lanes.mjs +13 -0
- package/src/adapters/graph-build.mjs +5 -7
- package/src/adapters/import-closure.mjs +28 -0
- package/src/adapters/memory/blocks.mjs +5 -4
- package/src/adapters/memory/core.mjs +78 -5
- package/src/adapters/memory/shacl.mjs +12 -0
- package/src/adapters/providers/graph-service.mjs +12 -5
- package/src/adapters/tracked-files.mjs +17 -0
- package/src/domain/ask-vocab.mjs +2 -0
- package/src/domain/ask.mjs +225 -13
- package/src/domain/cli-verbs.mjs +201 -0
- package/src/domain/codegraph.mjs +142 -56
- package/src/domain/completions/graph-adapter.mjs +1 -1
- package/src/domain/completions/group.mjs +3 -17
- package/src/domain/completions/infer.mjs +4 -13
- package/src/domain/completions/rank.mjs +6 -19
- package/src/domain/grammar/lexicon-core.json +1 -1
- package/src/domain/hash.mjs +36 -13
- package/src/domain/interpret/fuzzy.mjs +7 -2
- package/src/domain/interpret/normalize.mjs +9 -0
- package/src/domain/interpret/strategies/keywords.mjs +19 -9
- package/src/domain/memory/capability.mjs +22 -3
- package/src/domain/memory/touched-facts.mjs +17 -0
- package/src/domain/module-paths.mjs +9 -0
- package/src/domain/persona/tiers.mjs +1 -1
- package/src/domain/planning.mjs +37 -0
- package/src/domain/prose.mjs +10 -2
- package/src/domain/relative-specifiers.mjs +12 -0
- package/src/domain/router/registry.mjs +3 -2
- package/src/domain/router/results.mjs +5 -18
- package/src/domain/seeded-random.mjs +33 -0
- package/src/domain/syllogise.mjs +10 -7
- package/src/domain/text-stats.mjs +31 -0
- package/src/services/chat.mjs +720 -182
- package/src/services/extract-facts.mjs +155 -0
- package/src/services/import-file.mjs +2 -2
- package/src/services/ledger-viz.mjs +6 -1
- package/src/services/sentences.mjs +26 -0
- package/src/surfaces/web/memory-ask-browser.bundle.js +11390 -360
- package/src/tools/graph-load.mjs +7 -1
- package/src/tools/readme-docs.mjs +113 -0
- package/src/tools/schema-docs.mjs +2 -2
- package/corpus/namenet/generate.mjs +0 -309
- package/corpus/wordnet/generate.mjs +0 -332
- package/src/adapters/prose-tokens.mjs +0 -98
- package/src/adapters/wordnet-source.mjs +0 -70
- package/src/domain/corpus-matrix.mjs +0 -87
- package/src/domain/inflect.mjs +0 -67
- package/src/domain/licences.mjs +0 -68
- package/src/domain/markdown-links.mjs +0 -55
- package/src/domain/persona/codegen.mjs +0 -123
- package/src/domain/publish-gate.mjs +0 -41
- package/src/domain/schemaorg/turtle.mjs +0 -25
- package/src/domain/semcor/parse.mjs +0 -87
- package/src/domain/version-stamp.mjs +0 -36
- package/src/domain/wordnet/yaml.mjs +0 -133
|
@@ -0,0 +1,473 @@
|
|
|
1
|
+
SQLite Frequently Asked Questions
|
|
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
|
+
Frequently Asked Questions
|
|
21
|
+
How do I create an AUTOINCREMENT field?
|
|
22
|
+
What datatypes does SQLite support?
|
|
23
|
+
SQLite lets me insert a string into a database column of type integer!
|
|
24
|
+
Why doesn't SQLite allow me to use '0' and '0.0' as the primary
|
|
25
|
+
key on two different rows of the same table?
|
|
26
|
+
Can multiple applications or multiple instances of the same
|
|
27
|
+
application access a single database file at the same time?
|
|
28
|
+
Is SQLite threadsafe?
|
|
29
|
+
How do I list all tables/indices contained in an SQLite database
|
|
30
|
+
Are there any known size limits to SQLite databases?
|
|
31
|
+
What is the maximum size of a VARCHAR in SQLite?
|
|
32
|
+
Does SQLite support a BLOB type?
|
|
33
|
+
How do I add, delete or rename columns from an existing table in SQLite?
|
|
34
|
+
I deleted a lot of data but the database file did not get any
|
|
35
|
+
smaller. Is this a bug?
|
|
36
|
+
Can I use SQLite in my commercial product without paying royalties?
|
|
37
|
+
How do I use a string literal that contains an embedded single-quote (')
|
|
38
|
+
character?
|
|
39
|
+
What is an SQLITE_SCHEMA error, and why am I getting one?
|
|
40
|
+
I get some compiler warnings when I compile SQLite.
|
|
41
|
+
Isn't this a problem? Doesn't it indicate poor code quality?
|
|
42
|
+
Case-insensitive matching of Unicode characters does not work.
|
|
43
|
+
INSERT is really slow - I can only do few dozen INSERTs per second
|
|
44
|
+
I accidentally deleted some important information from my SQLite database.
|
|
45
|
+
How can I recover it?
|
|
46
|
+
What is an SQLITE_CORRUPT error? What does it mean for the database
|
|
47
|
+
to be "malformed"? Why am I getting this error?
|
|
48
|
+
Does SQLite support foreign keys?
|
|
49
|
+
I get a compiler error if I use the SQLITE_OMIT_...
|
|
50
|
+
compile-time options when building SQLite.
|
|
51
|
+
My WHERE clause expression column1="column1" does not work.
|
|
52
|
+
It causes every row of the table to be returned, not just the rows
|
|
53
|
+
where column1 has the value "column1".
|
|
54
|
+
How are the syntax diagrams (a.k.a. "railroad" diagrams) for
|
|
55
|
+
SQLite generated?
|
|
56
|
+
The SQL standard requires that a UNIQUE constraint be enforced even if
|
|
57
|
+
one or more of the columns in the constraint are NULL, but SQLite does
|
|
58
|
+
not do this. Isn't that a bug?
|
|
59
|
+
What is the Export Control Classification Number (ECCN) for SQLite?
|
|
60
|
+
My query does not return the column name that I expect. Is this a bug?
|
|
61
|
+
Where did my database go? (Or: How did my database become empty?)
|
|
62
|
+
(1) How do I create an AUTOINCREMENT field?
|
|
63
|
+
Short answer: A column declared INTEGER PRIMARY KEY will
|
|
64
|
+
autoincrement.
|
|
65
|
+
Longer answer:
|
|
66
|
+
If you declare a column of a table to be INTEGER PRIMARY KEY , then
|
|
67
|
+
whenever you insert a NULL
|
|
68
|
+
into that column of the table, the NULL is automatically converted
|
|
69
|
+
into an integer which is one greater than the largest value of that
|
|
70
|
+
column over all other rows in the table, or 1 if the table is empty.
|
|
71
|
+
Or, if the largest existing integer key 9223372036854775807 is in use then an
|
|
72
|
+
unused key value is chosen at random.
|
|
73
|
+
For example, suppose you have a table like this:
|
|
74
|
+
With this table, the statement
|
|
75
|
+
is logically equivalent to saying:
|
|
76
|
+
There is a function named
|
|
77
|
+
sqlite3_last_insert_rowid() which will return the integer key
|
|
78
|
+
for the most recent insert operation.
|
|
79
|
+
Note that the integer key is one greater than the largest
|
|
80
|
+
key that was in the table just prior to the insert. The new key
|
|
81
|
+
will be unique over all keys currently in the table, but it might
|
|
82
|
+
overlap with keys that have been previously deleted from the
|
|
83
|
+
table. To create keys that are unique over the lifetime of the
|
|
84
|
+
table, add the AUTOINCREMENT keyword to the INTEGER PRIMARY KEY
|
|
85
|
+
declaration. Then the key chosen will be one more than the
|
|
86
|
+
largest key that has ever existed in that table. If the largest
|
|
87
|
+
possible key has previously existed in that table, then the INSERT
|
|
88
|
+
will fail with an SQLITE_FULL error code.
|
|
89
|
+
(2) What datatypes does SQLite support?
|
|
90
|
+
SQLite uses dynamic typing . Content can be stored as INTEGER,
|
|
91
|
+
REAL, TEXT, BLOB, or as NULL.
|
|
92
|
+
(3) SQLite lets me insert a string into a database column of type integer!
|
|
93
|
+
This is a feature, not a bug. SQLite uses dynamic typing .
|
|
94
|
+
It does not enforce data type constraints. Data of any type can
|
|
95
|
+
(usually) be inserted into any column. You can put arbitrary length
|
|
96
|
+
strings into integer columns, floating point numbers in boolean columns,
|
|
97
|
+
or dates in character columns. The datatype you assign to a column in the
|
|
98
|
+
CREATE TABLE command does not restrict what data can be put into
|
|
99
|
+
that column. Every column is able to hold
|
|
100
|
+
an arbitrary length string. (There is one exception: Columns of
|
|
101
|
+
type INTEGER PRIMARY KEY may only hold a 64-bit signed integer.
|
|
102
|
+
An error will result
|
|
103
|
+
if you try to put anything other than an integer into an
|
|
104
|
+
INTEGER PRIMARY KEY column.)
|
|
105
|
+
But SQLite does use the declared type of a column as a hint
|
|
106
|
+
that you prefer values in that format. So, for example, if a
|
|
107
|
+
column is of type INTEGER and you try to insert a string into
|
|
108
|
+
that column, SQLite will attempt to convert the string into an
|
|
109
|
+
integer. If it can, it inserts the integer instead. If not,
|
|
110
|
+
it inserts the string. This feature is called type affinity .
|
|
111
|
+
(4) Why doesn't SQLite allow me to use '0' and '0.0' as the primary
|
|
112
|
+
key on two different rows of the same table?
|
|
113
|
+
This problem occurs when your primary key is a numeric type. Change the
|
|
114
|
+
datatype of your primary key to TEXT and it should work.
|
|
115
|
+
Every row must have a unique primary key. For a column with a
|
|
116
|
+
numeric type, SQLite thinks that '0' and '0.0' are the
|
|
117
|
+
same value because they compare equal to one another numerically.
|
|
118
|
+
(See the previous question.) Hence the values are not unique.
|
|
119
|
+
(5) Can multiple applications or multiple instances of the same
|
|
120
|
+
application access a single database file at the same time?
|
|
121
|
+
Multiple processes can have the same database open at the same
|
|
122
|
+
time. Multiple processes can be doing a SELECT
|
|
123
|
+
at the same time. But only one process can be making changes to
|
|
124
|
+
the database at any moment in time, however.
|
|
125
|
+
SQLite uses reader/writer locks to control access to the database.
|
|
126
|
+
(Under Win95/98/ME which lacks support for reader/writer locks, a
|
|
127
|
+
probabilistic simulation is used instead.)
|
|
128
|
+
But use caution: this locking mechanism might
|
|
129
|
+
not work correctly if the database file is kept on an NFS filesystem.
|
|
130
|
+
This is because fcntl() file locking is broken on many NFS implementations.
|
|
131
|
+
You should avoid putting SQLite database files on NFS if multiple
|
|
132
|
+
processes might try to access the file at the same time. On Windows,
|
|
133
|
+
Microsoft's documentation says that locking may not work under FAT
|
|
134
|
+
filesystems if you are not running the Share.exe daemon. People who
|
|
135
|
+
have a lot of experience with Windows tell me that file locking of
|
|
136
|
+
network files is very buggy and is not dependable. If what they
|
|
137
|
+
say is true, sharing an SQLite database between two or more Windows
|
|
138
|
+
machines might cause unexpected problems.
|
|
139
|
+
We are aware of no other embedded SQL database engine that
|
|
140
|
+
supports as much concurrency as SQLite. SQLite allows multiple processes
|
|
141
|
+
to have the database file open at once, and for multiple processes to
|
|
142
|
+
read the database at once. When any process wants to write, it must
|
|
143
|
+
lock the entire database file for the duration of its update. But that
|
|
144
|
+
normally only takes a few milliseconds. Other processes just wait on
|
|
145
|
+
the writer to finish then continue about their business. Other embedded
|
|
146
|
+
SQL database engines typically only allow a single process to connect to
|
|
147
|
+
the database at once.
|
|
148
|
+
However, client/server database engines (such as PostgreSQL, MySQL,
|
|
149
|
+
or Oracle) usually support a higher level of concurrency and allow
|
|
150
|
+
multiple processes to be writing to the same database at the same time.
|
|
151
|
+
This is possible in a client/server database because there is always a
|
|
152
|
+
single well-controlled server process available to coordinate access.
|
|
153
|
+
If your application has a need for a lot of concurrency, then you should
|
|
154
|
+
consider using a client/server database. But experience suggests that
|
|
155
|
+
most applications need much less concurrency than their designers imagine.
|
|
156
|
+
When SQLite tries to access a file that is locked by another
|
|
157
|
+
process, the default behavior is to return SQLITE_BUSY. You can
|
|
158
|
+
adjust this behavior from C code using the
|
|
159
|
+
sqlite3_busy_handler() or sqlite3_busy_timeout()
|
|
160
|
+
API functions.
|
|
161
|
+
(6) Is SQLite threadsafe?
|
|
162
|
+
Threads are evil .
|
|
163
|
+
Avoid them.
|
|
164
|
+
SQLite is threadsafe. We make this concession since many users choose
|
|
165
|
+
to ignore the advice given in the previous paragraph.
|
|
166
|
+
But in order to be thread-safe, SQLite must be compiled
|
|
167
|
+
with the SQLITE_THREADSAFE preprocessor macro set to 1. Both the Windows
|
|
168
|
+
and Linux precompiled binaries in the distribution are compiled this way.
|
|
169
|
+
If you are unsure if the SQLite library you are linking against is compiled
|
|
170
|
+
to be threadsafe you can call the sqlite3_threadsafe()
|
|
171
|
+
interface to find out.
|
|
172
|
+
SQLite is threadsafe because it uses mutexes to serialize
|
|
173
|
+
access to common data structures. However, the work of acquiring and
|
|
174
|
+
releasing these mutexes will slow SQLite down slightly. Hence, if you
|
|
175
|
+
do not need SQLite to be threadsafe, you should disable the mutexes
|
|
176
|
+
for maximum performance. See the threading mode documentation for
|
|
177
|
+
additional information.
|
|
178
|
+
Under Unix, you should not carry an open SQLite database across
|
|
179
|
+
a fork() system call into the child process.
|
|
180
|
+
(7) How do I list all tables/indices contained in an SQLite database
|
|
181
|
+
If you are running the sqlite3 command-line access program
|
|
182
|
+
you can type " .tables " to get a list of all tables. Or you
|
|
183
|
+
can type " .schema " to see the complete database schema including
|
|
184
|
+
all tables and indices. Either of these commands can be followed by
|
|
185
|
+
a LIKE pattern that will restrict the tables that are displayed.
|
|
186
|
+
From within a C/C++ program (or a script using Tcl/Ruby/Perl/Python
|
|
187
|
+
bindings) you can get access to table and index names by doing a SELECT
|
|
188
|
+
on a special table named " SQLITE_SCHEMA ". Every SQLite database
|
|
189
|
+
has an SQLITE_SCHEMA table that defines the schema for the database.
|
|
190
|
+
The SQLITE_SCHEMA table looks like this:
|
|
191
|
+
For tables, the type field will always be 'table' and the
|
|
192
|
+
name field will be the name of the table. So to get a list of
|
|
193
|
+
all tables in the database, use the following SELECT command:
|
|
194
|
+
For indices, type is equal to 'index' , name is the
|
|
195
|
+
name of the index and tbl_name is the name of the table to which
|
|
196
|
+
the index belongs. For both tables and indices, the sql field is
|
|
197
|
+
the text of the original CREATE TABLE or CREATE INDEX statement that
|
|
198
|
+
created the table or index. For automatically created indices (used
|
|
199
|
+
to implement the PRIMARY KEY or UNIQUE constraints) the sql field
|
|
200
|
+
is NULL.
|
|
201
|
+
The SQLITE_SCHEMA table cannot be modified using UPDATE, INSERT,
|
|
202
|
+
or DELETE (except under
|
|
203
|
+
extraordinary conditions ).
|
|
204
|
+
The SQLITE_SCHEMA table is automatically updated by commands like
|
|
205
|
+
CREATE TABLE, CREATE INDEX, DROP TABLE, and DROP INDEX.
|
|
206
|
+
Temporary tables do not appear in the SQLITE_SCHEMA table. Temporary
|
|
207
|
+
tables and their indices and triggers occur in another special table
|
|
208
|
+
named SQLITE_TEMP_SCHEMA. SQLITE_TEMP_SCHEMA works just like SQLITE_SCHEMA
|
|
209
|
+
except that it is only visible to the application that created the
|
|
210
|
+
temporary tables. To get a list of all tables, both permanent and
|
|
211
|
+
temporary, one can use a command similar to the following:
|
|
212
|
+
(8) Are there any known size limits to SQLite databases?
|
|
213
|
+
See limits.html for a full discussion of
|
|
214
|
+
the limits of SQLite.
|
|
215
|
+
(9) What is the maximum size of a VARCHAR in SQLite?
|
|
216
|
+
SQLite does not enforce the length of a VARCHAR. You can declare
|
|
217
|
+
a VARCHAR(10) and SQLite will be happy to store a 500-million character
|
|
218
|
+
string there. And it will keep all 500-million characters intact.
|
|
219
|
+
Your content is never truncated. SQLite understands the column type
|
|
220
|
+
of "VARCHAR( N )" to be the same as "TEXT", regardless of the value
|
|
221
|
+
of N .
|
|
222
|
+
(10) Does SQLite support a BLOB type?
|
|
223
|
+
SQLite allows you to store BLOB data in any
|
|
224
|
+
column, even columns that are declared to hold some other type.
|
|
225
|
+
BLOBs can even be used as PRIMARY KEYs.
|
|
226
|
+
(11) How do I add, delete or rename columns from an existing table in SQLite?
|
|
227
|
+
SQLite has limited ALTER TABLE support that you can use to
|
|
228
|
+
add, rename or drop columns or to change the name of a table
|
|
229
|
+
as detailed at ALTER TABLE .
|
|
230
|
+
If you want to make more complex changes in the structure or
|
|
231
|
+
constraints of a table or its columns, you will have to recreate it.
|
|
232
|
+
You can save existing data to a temporary table, drop the
|
|
233
|
+
old table, create the new table, then copy the data back in from
|
|
234
|
+
the temporary table. See
|
|
235
|
+
Making Other Kinds Of Table Schema Changes for procedure.
|
|
236
|
+
(12) I deleted a lot of data but the database file did not get any
|
|
237
|
+
smaller. Is this a bug?
|
|
238
|
+
No. When you delete information from an SQLite database, the
|
|
239
|
+
unused disk space is added to an internal "free-list" and is reused
|
|
240
|
+
the next time you insert data. The disk space is not lost. But
|
|
241
|
+
neither is it returned to the operating system.
|
|
242
|
+
If you delete a lot of data and want to shrink the database file,
|
|
243
|
+
run the VACUUM command.
|
|
244
|
+
VACUUM will reconstruct
|
|
245
|
+
the database from scratch. This will leave the database with an empty
|
|
246
|
+
free-list and a file that is minimal in size. Note, however, that the
|
|
247
|
+
VACUUM can take some time to run and it can use up to twice
|
|
248
|
+
as much temporary disk space as the original file while it is running.
|
|
249
|
+
An alternative to using the VACUUM command
|
|
250
|
+
is auto-vacuum mode, enabled using the
|
|
251
|
+
auto_vacuum pragma .
|
|
252
|
+
(13) Can I use SQLite in my commercial product without paying royalties?
|
|
253
|
+
Yes. SQLite is in the
|
|
254
|
+
public domain . No claim of ownership is made
|
|
255
|
+
to any part of the code. You can do anything you want with it.
|
|
256
|
+
(14) How do I use a string literal that contains an embedded single-quote (')
|
|
257
|
+
character?
|
|
258
|
+
The SQL standard specifies that single-quotes in strings are escaped
|
|
259
|
+
by putting two single quotes in a row. SQL works like the Pascal programming
|
|
260
|
+
language in this regard. Example:
|
|
261
|
+
(15) What is an SQLITE_SCHEMA error, and why am I getting one?
|
|
262
|
+
An SQLITE_SCHEMA error is returned when a
|
|
263
|
+
prepared SQL statement is no longer valid and cannot be executed.
|
|
264
|
+
When this occurs, the statement must be recompiled from SQL using
|
|
265
|
+
the sqlite3_prepare() API.
|
|
266
|
+
An SQLITE_SCHEMA error can only occur when using the sqlite3_prepare() ,
|
|
267
|
+
and sqlite3_step() interfaces to run SQL.
|
|
268
|
+
You will never receive an SQLITE_SCHEMA error from
|
|
269
|
+
sqlite3_exec() . Nor will you receive an error if you
|
|
270
|
+
prepare statements using sqlite3_prepare_v2() instead of
|
|
271
|
+
sqlite3_prepare() .
|
|
272
|
+
The sqlite3_prepare_v2() interface creates a
|
|
273
|
+
prepared statement that will automatically recompile itself if
|
|
274
|
+
the schema changes. The easiest way to deal with
|
|
275
|
+
SQLITE_SCHEMA errors is to always use sqlite3_prepare_v2()
|
|
276
|
+
instead of sqlite3_prepare() .
|
|
277
|
+
(17) I get some compiler warnings when I compile SQLite.
|
|
278
|
+
Isn't this a problem? Doesn't it indicate poor code quality?
|
|
279
|
+
Quality assurance in SQLite is done using
|
|
280
|
+
full-coverage testing ,
|
|
281
|
+
not by compiler warnings or other static code analysis tools.
|
|
282
|
+
In other words, we verify that SQLite actually gets the
|
|
283
|
+
correct answer, not that it merely satisfies stylistic constraints.
|
|
284
|
+
Most of the SQLite code base is devoted purely to testing.
|
|
285
|
+
The SQLite test suite runs tens of thousands of separate test cases and
|
|
286
|
+
many of those test cases are parameterized so that hundreds of millions
|
|
287
|
+
of tests involving billions of SQL statements are run and evaluated
|
|
288
|
+
for correctness prior to every release. The developers use code
|
|
289
|
+
coverage tools to verify that all paths through the code are tested.
|
|
290
|
+
Whenever a bug is found in SQLite, new test cases are written to
|
|
291
|
+
exhibit the bug so that the bug cannot recur undetected in the future.
|
|
292
|
+
During testing, the SQLite library is compiled with special
|
|
293
|
+
instrumentation that allows the test scripts to simulate a wide
|
|
294
|
+
variety of failures in order to verify that SQLite recovers
|
|
295
|
+
correctly. Memory allocation is carefully tracked and no memory
|
|
296
|
+
leaks occur, even following memory allocation failures. A custom
|
|
297
|
+
VFS layer is used to simulate operating system crashes and power
|
|
298
|
+
failures in order to ensure that transactions are atomic across
|
|
299
|
+
these events. A mechanism for deliberately injecting I/O errors
|
|
300
|
+
shows that SQLite is resilient to such malfunctions. (As an
|
|
301
|
+
experiment, try inducing these kinds of errors on other SQL database
|
|
302
|
+
engines and see what happens!)
|
|
303
|
+
We also run SQLite using Valgrind
|
|
304
|
+
on Linux and verify that it detects no problems.
|
|
305
|
+
Some people say that we should eliminate all warnings because
|
|
306
|
+
benign warnings mask real warnings that might arise in future changes.
|
|
307
|
+
This is true enough. But in reply, the developers observe that all
|
|
308
|
+
warnings have already been fixed in the builds
|
|
309
|
+
used for SQLite development (various versions of GCC, MSVC,
|
|
310
|
+
and clang).
|
|
311
|
+
Compiler warnings usually only arise from compilers or compile-time
|
|
312
|
+
options that the SQLite developers do not use themselves.
|
|
313
|
+
(18) Case-insensitive matching of Unicode characters does not work.
|
|
314
|
+
The default configuration of SQLite only supports case-insensitive
|
|
315
|
+
comparisons of ASCII characters. The reason for this is that doing
|
|
316
|
+
full Unicode case-insensitive comparisons and case conversions
|
|
317
|
+
requires tables and logic that would nearly double the size of
|
|
318
|
+
the SQLite library. The
|
|
319
|
+
SQLite developers reason that any application that needs full
|
|
320
|
+
Unicode case support probably already has the necessary tables and
|
|
321
|
+
functions and so SQLite should not take up space to
|
|
322
|
+
duplicate this ability.
|
|
323
|
+
Instead of providing full Unicode case support by default,
|
|
324
|
+
SQLite provides the ability to link against external
|
|
325
|
+
Unicode comparison and conversion routines.
|
|
326
|
+
The application can overload the built-in NOCASE collating
|
|
327
|
+
sequence (using sqlite3_create_collation() ) and the built-in
|
|
328
|
+
like() , upper() , and lower() functions
|
|
329
|
+
(using sqlite3_create_function() ).
|
|
330
|
+
The SQLite source code includes an "ICU" extension that does
|
|
331
|
+
these overloads. Or, developers can write their own overloads
|
|
332
|
+
based on their own Unicode-aware comparison routines already
|
|
333
|
+
contained within their project.
|
|
334
|
+
(19) INSERT is really slow - I can only do few dozen INSERTs per second
|
|
335
|
+
Actually, SQLite will easily do 50,000 or more INSERT statements per second
|
|
336
|
+
on an average desktop computer. But it will only do a few dozen transactions
|
|
337
|
+
per second. Transaction speed is limited by the rotational speed of
|
|
338
|
+
your disk drive. A transaction normally requires two complete rotations
|
|
339
|
+
of the disk platter, which on a 7200RPM disk drive limits you to about
|
|
340
|
+
60 transactions per second.
|
|
341
|
+
Transaction speed is limited by disk drive speed because (by default)
|
|
342
|
+
SQLite actually waits until the data really is safely stored on the disk
|
|
343
|
+
surface before the transaction is complete. That way, if you suddenly lose
|
|
344
|
+
power or if your OS crashes, your data is still safe. For details,
|
|
345
|
+
read about atomic commit in SQLite. .
|
|
346
|
+
By default, each INSERT statement is its own transaction. But if you
|
|
347
|
+
surround multiple INSERT statements with BEGIN ... COMMIT then all the
|
|
348
|
+
inserts are grouped into a single transaction. The time needed to commit
|
|
349
|
+
the transaction is amortized over all the enclosed insert statements and
|
|
350
|
+
so the time per insert statement is greatly reduced.
|
|
351
|
+
Another option is to run PRAGMA synchronous=OFF . This command will
|
|
352
|
+
cause SQLite to not wait on data to reach the disk surface, which will make
|
|
353
|
+
write operations appear to be much faster. But if you lose power in the
|
|
354
|
+
middle of a transaction, your database file might go corrupt.
|
|
355
|
+
Update 2024-11-19: The text above is a really old answer.
|
|
356
|
+
SQLite will do far more than 50K inserts/second now, and everybody uses SSD
|
|
357
|
+
nowadays, making the performance faster still. But the gist of the answer
|
|
358
|
+
above remains correct: Putting multiple operations inside a single
|
|
359
|
+
transaction can improve performance dramatically by avoiding the overhead
|
|
360
|
+
of transaction control after each individual operation.
|
|
361
|
+
(20) I accidentally deleted some important information from my SQLite database.
|
|
362
|
+
How can I recover it?
|
|
363
|
+
If you have a backup copy of your database file, recover the information
|
|
364
|
+
from your backup.
|
|
365
|
+
If you do not have a backup, recovery is very difficult. You might
|
|
366
|
+
be able to find partial string data in a binary dump of the raw database
|
|
367
|
+
file. Recovering numeric data might also be possible given special tools,
|
|
368
|
+
though to our knowledge no such tools exist. SQLite is sometimes compiled
|
|
369
|
+
with the SQLITE_SECURE_DELETE option which overwrites all deleted content
|
|
370
|
+
with zeros. If that is the case then recovery is clearly impossible.
|
|
371
|
+
Recovery is also impossible if you have run VACUUM since the data was
|
|
372
|
+
deleted. If SQLITE_SECURE_DELETE is not used and VACUUM has not been run,
|
|
373
|
+
then some of the deleted content might still be in the database file, in
|
|
374
|
+
areas marked for reuse. But, again, there exist no procedures or tools
|
|
375
|
+
that we know of to help you recover that data.
|
|
376
|
+
(21) What is an SQLITE_CORRUPT error? What does it mean for the database
|
|
377
|
+
to be "malformed"? Why am I getting this error?
|
|
378
|
+
An SQLITE_CORRUPT error is returned when SQLite detects an error
|
|
379
|
+
in the structure, format, or other control elements of the
|
|
380
|
+
database file.
|
|
381
|
+
SQLite does not corrupt database files without external help.
|
|
382
|
+
If your application crashes in the middle of an
|
|
383
|
+
update, your data is safe. The database is safe even if your OS
|
|
384
|
+
crashes or takes a power loss. The crash-resistance of SQLite has
|
|
385
|
+
been extensively studied and tested and is attested by years of real-world
|
|
386
|
+
experience by billions of users.
|
|
387
|
+
That said, there are a number of things that external programs or bugs
|
|
388
|
+
in your hardware or OS can do to corrupt a database file. See
|
|
389
|
+
How To Corrupt An SQLite Database File for
|
|
390
|
+
further information.
|
|
391
|
+
You can use PRAGMA integrity_check
|
|
392
|
+
to do a thorough but time intensive test of the database integrity.
|
|
393
|
+
You can use PRAGMA quick_check to do a faster
|
|
394
|
+
but less thorough test of the database integrity.
|
|
395
|
+
Depending how badly your database is corrupted, you may be able to
|
|
396
|
+
recover some of the data by using the CLI to dump the schema and contents
|
|
397
|
+
to a file and then recreate. Unfortunately, once humpty-dumpty falls off
|
|
398
|
+
the wall, it is generally not possible to put him back together again.
|
|
399
|
+
(22) Does SQLite support foreign keys?
|
|
400
|
+
As of version 3.6.19 (2009-10-14),
|
|
401
|
+
SQLite supports foreign key constraints . But enforcement
|
|
402
|
+
of foreign key constraints is turned off by default (for backwards compatibility).
|
|
403
|
+
To enable foreign key constraint enforcement, run
|
|
404
|
+
PRAGMA foreign_keys=ON or compile with
|
|
405
|
+
-DSQLITE_DEFAULT_FOREIGN_KEYS=1 .
|
|
406
|
+
(23) I get a compiler error if I use the SQLITE_OMIT_...
|
|
407
|
+
compile-time options when building SQLite.
|
|
408
|
+
The SQLITE_OMIT_... compile-time options only work
|
|
409
|
+
when building from canonical source files. They do not work
|
|
410
|
+
when you build from the SQLite amalgamation or from the pre-processed
|
|
411
|
+
source files.
|
|
412
|
+
It is possible to build a special amalgamation that will work with
|
|
413
|
+
a predetermined set of SQLITE_OMIT_... options. Instructions for doing
|
|
414
|
+
so can be found with the SQLITE_OMIT_... documentation .
|
|
415
|
+
(24) My WHERE clause expression column1="column1" does not work.
|
|
416
|
+
It causes every row of the table to be returned, not just the rows
|
|
417
|
+
where column1 has the value "column1".
|
|
418
|
+
Use single-quotes, not double-quotes, around string literals in SQL.
|
|
419
|
+
This is what the SQL standard requires. Your WHERE clause expression
|
|
420
|
+
should read: column1='column1'
|
|
421
|
+
SQL uses double-quotes around identifiers (column or table names) that
|
|
422
|
+
contains special characters or which are keywords. So double-quotes are
|
|
423
|
+
a way of escaping identifier names. Hence, when you say
|
|
424
|
+
column1="column1" that is equivalent to
|
|
425
|
+
column1=column1 which is obviously always true.
|
|
426
|
+
(25) How are the syntax diagrams (a.k.a. "railroad" diagrams) for
|
|
427
|
+
SQLite generated?
|
|
428
|
+
Each diagram is hand-written using the Pikchr
|
|
429
|
+
diagramming language. These hand-written specifications are converted into
|
|
430
|
+
SVG and inserted inline in the HTML files as part of the documentation build process.
|
|
431
|
+
Many historical versions of the SQLite documentation used a different process for
|
|
432
|
+
generating the syntax diagrams. The historical process was based on Tcl/Tk and is
|
|
433
|
+
described at http://wiki.tcl-lang.org/21708 . The newer Pikchr-based syntax diagrams
|
|
434
|
+
first landed on trunk on 2020-09-26.
|
|
435
|
+
(26) The SQL standard requires that a UNIQUE constraint be enforced even if
|
|
436
|
+
one or more of the columns in the constraint are NULL, but SQLite does
|
|
437
|
+
not do this. Isn't that a bug?
|
|
438
|
+
Perhaps you are referring to the following statement from SQL92:
|
|
439
|
+
A unique constraint is satisfied if and only if no two rows in a
|
|
440
|
+
table have the same non-null values in the unique columns.
|
|
441
|
+
That statement is ambiguous, having at least two possible interpretations:
|
|
442
|
+
A unique constraint is satisfied if and only if no two rows in a
|
|
443
|
+
table have the same values and have non-null values in the unique columns.
|
|
444
|
+
A unique constraint is satisfied if and only if no two rows in a
|
|
445
|
+
table have the same values in the subset of unique columns that are not null.
|
|
446
|
+
SQLite follows interpretation (1), as does PostgreSQL, MySQL, Oracle,
|
|
447
|
+
and Firebird. It is true that Informix and Microsoft SQL Server use
|
|
448
|
+
interpretation (2), however we the SQLite developers hold that
|
|
449
|
+
interpretation (1) is the most natural reading
|
|
450
|
+
of the requirement and we also want to maximize compatibility with other
|
|
451
|
+
SQL database engines, and most other database engines also go with (1),
|
|
452
|
+
so that is what SQLite does.
|
|
453
|
+
(27) What is the Export Control Classification Number (ECCN) for SQLite?
|
|
454
|
+
After careful review of the Commerce Control List (CCL), we are convinced
|
|
455
|
+
that the core public-domain SQLite source code is not described by any ECCN,
|
|
456
|
+
hence the ECCN should be reported as EAR99 .
|
|
457
|
+
The above is true for the core public-domain SQLite. If you extend
|
|
458
|
+
SQLite by adding new code, or if you statically link SQLite with your
|
|
459
|
+
application, that might change the ECCN in your particular case.
|
|
460
|
+
(28) My query does not return the column name that I expect. Is this a bug?
|
|
461
|
+
If the columns of your result set are named by AS clauses, then SQLite
|
|
462
|
+
is guaranteed to use the identifier to the right of the AS keyword as the
|
|
463
|
+
column name. If the result set does not use an AS clause, then SQLite
|
|
464
|
+
is free to name the column anything it wants.
|
|
465
|
+
See the sqlite3_column_name() documentation for further information.
|
|
466
|
+
(29) Where did my database go? (Or: How did my database become empty?)
|
|
467
|
+
Unless opened with flags to prevent it, a SQLite database is created
|
|
468
|
+
if it does not already exist. Newly created databases are initially empty.
|
|
469
|
+
This can confuse people who inadvertantly open different database files
|
|
470
|
+
in different contexts, due to either a typo in the filename
|
|
471
|
+
or use of a relative pathname that is used with
|
|
472
|
+
differing current directories for the opening processes.
|
|
473
|
+
This page was last updated on 2024-11-26 23:53:35Z
|