1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-12-24 14:17:58 +03:00

Add user documentation for the "pragma auto_vacuum" command. (CVS 2084)

FossilOrigin-Name: fe200eaf373998574cc059086bfc93d6c44ec5a3
This commit is contained in:
danielk1977
2004-11-10 05:48:57 +00:00
parent 752e679a1e
commit 2a03c3a326
10 changed files with 385 additions and 294 deletions

View File

@@ -371,7 +371,7 @@ sqlite3_analyzer$(EXE): $(TOP)/src/tclsqlite.c libsqlite3.a $(TESTSRC) \
-e 's,^,",' \
-e 's,$$,\\n",' \
$(TOP)/tool/spaceanal.tcl >spaceanal_tcl.h
$(TCCX) $(TCL_FLAGS) -DTCLSH=2 -DSQLITE_TEST=1 -static -o \
$(TCCX) $(TCL_FLAGS) -DTCLSH=2 -DSQLITE_TEST=1 -o \
sqlite3_analyzer$(EXE) $(TESTSRC) $(TOP)/src/tclsqlite.c \
libsqlite3.a $(LIBTCL) $(THREADLIB)
@@ -438,6 +438,9 @@ index.html: $(TOP)/www/index.tcl last_change
lang.html: $(TOP)/www/lang.tcl
tclsh $(TOP)/www/lang.tcl >lang.html
pragma.html: $(TOP)/www/pragma.tcl
tclsh $(TOP)/www/pragma.tcl >pragma.html
lockingv3.html: $(TOP)/www/lockingv3.tcl
tclsh $(TOP)/www/lockingv3.tcl >lockingv3.html
@@ -509,6 +512,7 @@ DOC = \
oldnews.html \
omitted.html \
opcode.html \
pragma.html \
quickstart.html \
speed.html \
sqlite.gif \

View File

@@ -1,5 +1,5 @@
C Have\s"DEFAULT\sCURRENT_TIME"\s&\sco.\swork\seven\sif\sSQLITE_OMIT_DATETIME_FUNCS\sis\sdefined.\s(CVS\s2083)
D 2004-11-09T16:13:33
C Add\suser\sdocumentation\sfor\sthe\s"pragma\sauto_vacuum"\scommand.\s(CVS\s2084)
D 2004-11-10T05:48:57
F Makefile.in c4d2416860f472a1e3393714d0372074197565df
F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457
F README a01693e454a00cc117967e3f9fdab2d4d52e9bc1
@@ -16,7 +16,7 @@ F doc/lemon.html f0f682f50210928c07e562621c3b7e8ab912a538
F doc/report1.txt a031aaf37b185e4fa540223cb516d3bccec7eeac
F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895
F ltmain.sh f6b283068efa69f06eb8aa1fe4bddfdbdeb35826
F main.mk 594a756a761111da9415ca4b1ca7cbf3d269a3a3
F main.mk 32367381f4e75d7c13f24a739495e60a7b622256
F mkdll.sh 468d4f41d3ea98221371df4825cfbffbaac4d7e4
F mkopcodec.awk 14a794f7b206976afc416b30fe8e0fc97f3434e9
F mkopcodeh.awk 4090944e4de0a2ccb99aa0083290f73bce4db406
@@ -221,40 +221,41 @@ F www/arch2.fig ae2432145c26cfa148fa0116589517ad3cd5fc65
F www/arch2.gif 6f2d47c4e0c5842c0d6b5513fd8249393d7c7003
F www/arch2b.fig d22a2c9642d584b89d4088b1e51e2bb0f7c04bed
F www/audit.tcl 90e09d580f79c7efec0c7d6f447b7ec5c2dce5c0
F www/c_interface.tcl 83b39203e1ded4c2dab97f42edf31279a308efcb
F www/c_interface.tcl ea5a73b330a7006df87d0a4029569301bbd72029
F www/capi3.tcl 5c1cb163f4d2a54e2d0e22dcc399dd71245c8b89
F www/capi3ref.tcl aa8b12a1c633c5aaca03657e8ed04c963cb698c6
F www/changes.tcl f2b34859843d9f06a0611eb6d44af767891b09ef
F www/common.tcl 2ea19d725e67bac2cd0fb67c375ae9ce1d4b3e5b
F www/common.tcl 690d0f159cc5b83590707797acbcd031af8079a6
F www/conflict.tcl cdd0f4b59b0ba6d61f67e6a38f3ae45853bacb30
F www/copyright-release.html 294e011760c439c44951a6bfecd4c81a1ae359e8
F www/copyright-release.pdf cfca3558fc97095e57c6117d08f1f5b80d95125a
F www/copyright.tcl 82c9670c7ddb0311912ab7fe24703f33c531066c
F www/datatype3.tcl dea659d2dcc1f3d6eefdb8a2f52c04de3cdb6476
F www/datatypes.tcl 7c786d2e8ff434346764534ec015966d17efce60
F www/docs.tcl 4b5f7fca464e66ed7f929063a8b2b9e101ba902d
F www/docs.tcl 90de269f52212eb15534553faf6f1588ad77cd45
F www/download.tcl e9cebc67ac35c9c026b94ec01383ab8a7cf367f0
F www/dynload.tcl 02eb8273aa78cfa9070dd4501dca937fb22b466c
F www/faq.tcl bce6f03a9d00366e7f9eba9174167930b9f1b4ad
F www/faq.tcl abe360e630d8134bc6242c5e3664969c397eac6e
F www/fileformat.tcl 900c95b9633abc3dcfc384d9ddd8eb4876793059
F www/formatchng.tcl bfbf14dbf5181e771d06da7797767b0200b36d8a
F www/index.tcl 0c923045904426f5b5313a5563c4759277603567
F www/lang.tcl ba4fbca6342938f0240efdd84e83d5badcd72667
F www/lang.tcl 7904dbc26918e44c34b522bfc03d7b4671adabaf
F www/lockingv3.tcl f59b19d6c8920a931f096699d6faaf61c05db55f
F www/mingw.tcl d96b451568c5d28545fefe0c80bee3431c73f69c
F www/nulls.tcl ec35193f92485b87b90a994a01d0171b58823fcf
F www/oldnews.tcl 7aa4478e64631859770a5fe4b413919ba6ee8a08
F www/omitted.tcl 7bd62b6f0f53b60c5360895b16b3af8407bbca03
F www/opcode.tcl dafa030a5a3cc24a2f9fd4cfbfb7d7323d2151b0
F www/pragma.tcl f954f5c5eb98b4ba33c09d4fd866600e78b0aacb
F www/quickstart.tcl 6f6f694b6139be2d967b1492eb9a6bdf7058aa60
F www/speed.tcl de99c82c4729a10b6733463636f15473c4ec95bc
F www/sqlite.tcl b51fd15f0531a54874de785a9efba323eecd5975
F www/support.tcl 3955da0fd82be68cc5c83d347c05095e80967051
F www/tclsqlite.tcl 560ecd6a916b320e59f2917317398f3d59b7cc25
F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9
F www/vdbe.tcl 095f106d93875c94b47367384ebc870517431618
F www/version3.tcl 092a01f5ef430d2c4acc0ae558d74c4bb89638a0
F www/whentouse.tcl fdacb0ba2d39831e8a6240d05a490026ad4c4e4c
P 0d27c8ff48f327ad82dd5b5b3b47b8d221f119b7
R 50983ef3488aaf796e19a0b73688d49a
P f81b9c1c022772378aad32ec45d0027beeb36574
R bfd59cfe949547755a65241f31d7d209
U danielk1977
Z a02b42aae687ca01ff2682d8d73ff8dd
Z e40615b74d37b060e4ae6d8ae3079d56

View File

@@ -1 +1 @@
f81b9c1c022772378aad32ec45d0027beeb36574
fe200eaf373998574cc059086bfc93d6c44ec5a3

View File

@@ -1,7 +1,7 @@
#
# Run this Tcl script to generate the sqlite.html file.
#
set rcsid {$Id: c_interface.tcl,v 1.41 2004/08/30 14:58:12 drh Exp $}
set rcsid {$Id: c_interface.tcl,v 1.42 2004/11/10 05:48:57 danielk1977 Exp $}
source common.tcl
header {The C language interface to the SQLite library}
puts {
@@ -136,13 +136,13 @@ argv[i] == 0
<p>The names of the columns are contained in first <i>argc</i>
entries of the fourth argument.
If the <a href="lang.html#pragma_show_datatypes">SHOW_DATATYPES</a> pragma
If the <a href="pragma.html#pragma_show_datatypes">SHOW_DATATYPES</a> pragma
is on (it is off by default) then
the second <i>argc</i> entries in the 4th argument are the datatypes
for the corresponding columns.
</p>
<p>If the <a href="lang.html#pragma_empty_result_callbacks">
<p>If the <a href="pragma.html#pragma_empty_result_callbacks">
EMPTY_RESULT_CALLBACKS</a> pragma is set to ON and the result of
a query is an empty set, then the callback is invoked once with the
third parameter (argv) set to 0. In other words

View File

@@ -55,3 +55,41 @@ proc footer {{rcsid {}}} {
}
puts {</body></html>}
}
# The following two procs, Syntax and Section, are used to ensure
# consistent formatting in the "lang.html" and "pragma.html" pages.
#
proc Syntax {args} {
puts {<table cellpadding="10">}
foreach {rule body} $args {
puts "<tr><td align=\"right\" valign=\"top\">"
puts "<i><font color=\"#ff3434\">$rule</font></i>&nbsp;::=</td>"
regsub -all < $body {%LT} body
regsub -all > $body {%GT} body
regsub -all %LT $body {</font></b><i><font color="#ff3434">} body
regsub -all %GT $body {</font></i><b><font color="#2c2cf0">} body
regsub -all {[]|[*?]} $body {</font></b>&<b><font color="#2c2cf0">} body
regsub -all "\n" [string trim $body] "<br>\n" body
regsub -all "\n *" $body "\n\\&nbsp;\\&nbsp;\\&nbsp;\\&nbsp;" body
regsub -all {[|,.*()]} $body {<big>&</big>} body
regsub -all { = } $body { <big>=</big> } body
regsub -all {STAR} $body {<big>*</big>} body
## These metacharacters must be handled to undo being
## treated as SQL punctuation characters above.
regsub -all {RPPLUS} $body {</font></b>)+<b><font color="#2c2cf0">} body
regsub -all {LP} $body {</font></b>(<b><font color="#2c2cf0">} body
regsub -all {RP} $body {</font></b>)<b><font color="#2c2cf0">} body
## Place the left-hand side of the rule in the 2nd table column.
puts "<td><b><font color=\"#2c2cf0\">$body</font></b></td></tr>"
}
puts {</table>}
}
proc Section {name {label {}}} {
puts "\n<hr />"
if {$label!=""} {
puts "<a name=\"$label\"></a>"
}
puts "<h1>$name</h1>\n"
}

View File

@@ -1,7 +1,7 @@
# This script generates the "docs.html" page that describes various
# sources of documentation available for SQLite.
#
set rcsid {$Id: docs.tcl,v 1.6 2004/09/18 18:00:24 drh Exp $}
set rcsid {$Id: docs.tcl,v 1.7 2004/11/10 05:48:57 danielk1977 Exp $}
source common.tcl
header {SQLite Documentation}
puts {
@@ -28,6 +28,11 @@ doc {SQL Syntax} {lang.html} {
SQLite.
}
doc {Pragma commands} {pragma.html} {
This document describes SQLite performance tuning options and other
special purpose database commands.
}
doc {Version 2 C/C++ API} {c_interface.html} {
A description of the C/C++ interface bindings for SQLite through version
2.8

View File

@@ -1,7 +1,7 @@
#
# Run this script to generated a faq.html output file
#
set rcsid {$Id: faq.tcl,v 1.26 2004/10/10 17:24:55 drh Exp $}
set rcsid {$Id: faq.tcl,v 1.27 2004/11/10 05:48:57 danielk1977 Exp $}
source common.tcl
header {SQLite Frequently Asked Questions</title>}
@@ -399,6 +399,10 @@ faq {
on the Linux box where SQLite is developed) and it can use up to twice
as much temporary disk space as the original file while it is running.
</p>
<p>As of SQLite version 3.1, an alternative to using the VACUUM command
is auto-vacuum mode, enabled using the
<a href="pragma.html#pragma_auto_vacuum">auto_vacuum pragma</a>.</p>
}
faq {

View File

@@ -1,7 +1,7 @@
#
# Run this Tcl script to generate the sqlite.html file.
#
set rcsid {$Id: lang.tcl,v 1.74 2004/10/10 17:24:55 drh Exp $}
set rcsid {$Id: lang.tcl,v 1.75 2004/11/10 05:48:57 danielk1977 Exp $}
source common.tcl
header {Query Language Understood by SQLite}
puts {
@@ -30,34 +30,35 @@ the grammar file "parse.y".</p>
}
foreach {section} [lsort -index 0 -dictionary {
{{CREATE TABLE} createtable}
{{CREATE INDEX} createindex}
{VACUUM vacuum}
{{DROP TABLE} droptable}
{{DROP INDEX} dropindex}
{INSERT insert}
{REPLACE replace}
{DELETE delete}
{UPDATE update}
{SELECT select}
{comment comment}
{COPY copy}
{EXPLAIN explain}
{expression expr}
{{BEGIN TRANSACTION} transaction}
{{COMMIT TRANSACTION} transaction}
{{END TRANSACTION} transaction}
{{ROLLBACK TRANSACTION} transaction}
{PRAGMA pragma}
{{ON CONFLICT clause} conflict}
{{CREATE VIEW} createview}
{{DROP VIEW} dropview}
{{CREATE TRIGGER} createtrigger}
{{DROP TRIGGER} droptrigger}
{{ATTACH DATABASE} attach}
{{DETACH DATABASE} detach}
{{CREATE TABLE} #createtable}
{{CREATE INDEX} #createindex}
{VACUUM #vacuum}
{{DROP TABLE} #droptable}
{{DROP INDEX} #dropindex}
{INSERT #insert}
{REPLACE #replace}
{DELETE #delete}
{UPDATE #update}
{SELECT #select}
{comment #comment}
{COPY #copy}
{EXPLAIN #explain}
{expression #expr}
{{BEGIN TRANSACTION} #transaction}
{{COMMIT TRANSACTION} #transaction}
{{END TRANSACTION} #transaction}
{{ROLLBACK TRANSACTION} #transaction}
{PRAGMA pragma.html}
{{ON CONFLICT clause} #conflict}
{{CREATE VIEW} #createview}
{{DROP VIEW} #dropview}
{{CREATE TRIGGER} #createtrigger}
{{DROP TRIGGER} #droptrigger}
{{ATTACH DATABASE} #attach}
{{DETACH DATABASE} #detach}
}] {
puts "<li><a href=\"#[lindex $section 1]\">[lindex $section 0]</a></li>"
foreach {s_title s_tag} $section {}
puts "<li><a href=\"$s_tag\">$s_title</a></li>"
}
puts {</ul></p>
@@ -65,31 +66,6 @@ puts {</ul></p>
the sequel.</p>
}
proc Syntax {args} {
puts {<table cellpadding="10">}
foreach {rule body} $args {
puts "<tr><td align=\"right\" valign=\"top\">"
puts "<i><font color=\"#ff3434\">$rule</font></i>&nbsp;::=</td>"
regsub -all < $body {%LT} body
regsub -all > $body {%GT} body
regsub -all %LT $body {</font></b><i><font color="#ff3434">} body
regsub -all %GT $body {</font></i><b><font color="#2c2cf0">} body
regsub -all {[]|[*?]} $body {</font></b>&<b><font color="#2c2cf0">} body
regsub -all "\n" [string trim $body] "<br>\n" body
regsub -all "\n *" $body "\n\\&nbsp;\\&nbsp;\\&nbsp;\\&nbsp;" body
regsub -all {[|,.*()]} $body {<big>&</big>} body
regsub -all { = } $body { <big>=</big> } body
regsub -all {STAR} $body {<big>*</big>} body
## These metacharacters must be handled to undo being
## treated as SQL punctuation characters above.
regsub -all {RPPLUS} $body {</font></b>)+<b><font color="#2c2cf0">} body
regsub -all {LP} $body {</font></b>(<b><font color="#2c2cf0">} body
regsub -all {RP} $body {</font></b>)<b><font color="#2c2cf0">} body
## Place the left-hand side of the rule in the 2nd table column.
puts "<td><b><font color=\"#2c2cf0\">$body</font></b></td></tr>"
}
puts {</table>}
}
proc Operator {name} {
return "<font color=\"#2c2cf0\"><big>$name</big></font>"
}
@@ -99,16 +75,6 @@ proc Nonterminal {name} {
proc Keyword {name} {
return "<font color=\"#2c2cf0\">$name</font>"
}
proc Section {name {label {}}} {
puts "\n<hr />"
if {$label!=""} {
puts "<a name=\"$label\"></a>"
}
puts "<h1>$name</h1>\n"
}
proc Example {text} {
puts "<blockquote><pre>$text</pre></blockquote>"
}
@@ -1272,216 +1238,6 @@ If no algorithm is specified anywhere, the ABORT algorithm is used.</p>
# <p>For additional information, see
# <a href="conflict.html">conflict.html</a>.</p>
Section PRAGMA pragma
Syntax {sql-statement} {
PRAGMA <name> [= <value>] |
PRAGMA <function>(<arg>)
}
puts {
<p>The PRAGMA command is used to modify the operation of the SQLite library.
The pragma command is experimental and specific pragma statements may be
removed or added in future releases of SQLite. Use this command
with caution.</p>
<p>The pragmas that take an integer <b><i>value</i></b> also accept
symbolic names. The strings "<b>on</b>", "<b>true</b>", and "<b>yes</b>"
are equivalent to <b>1</b>. The strings "<b>off</b>", "<b>false</b>",
and "<b>no</b>" are equivalent to <b>0</b>. These strings are case-
insensitive, and do not require quotes. An unrecognized string will be
treated as <b>1</b>, and will not generate an error. When the <i>value</i>
is returned it is as an integer.</p>
<p>The current implementation supports the following pragmas:</p>
<ul>
<a name="pragma_cache_size"></a>
<li><p><b>PRAGMA cache_size;
<br>PRAGMA cache_size = </b><i>Number-of-pages</i><b>;</b></p>
<p>Query or change the maximum number of database disk pages that SQLite
will hold in memory at once. Each page uses about 1.5K of memory.
The default cache size is 2000. If you are doing UPDATEs or DELETEs
that change many rows of a database and you do not mind if SQLite
uses more memory, you can increase the cache size for a possible speed
improvement.</p>
<p>When you change the cache size using the cache_size pragma, the
change only endures for the current session. The cache size reverts
to the default value when the database is closed and reopened. Use
the <a href="#pragma_default_cache_size"><b>default_cache_size</b></a>
pragma to check the cache size permanently.</p></li>
<li><p><b>PRAGMA database_list;</b></p>
<p>For each open database, invoke the callback function once with
information about that database. Arguments include the index and
the name the database was attached with. The first row will be for
the main database. The second row will be for the database used to
store temporary tables.</p></li>
<a name="pragma_default_cache_size"></a>
<li><p><b>PRAGMA default_cache_size;
<br>PRAGMA default_cache_size = </b><i>Number-of-pages</i><b>;</b></p>
<p>Query or change the maximum number of database disk pages that SQLite
will hold in memory at once. Each page uses 1K on disk and about
1.5K in memory.
This pragma works like the
<a href="#pragma_cache_size"><b>cache_size</b></a>
pragma with the additional
feature that it changes the cache size persistently. With this pragma,
you can set the cache size once and that setting is retained and reused
every time you reopen the database.</p></li>
<a name="pragma_default_synchronous"></a>
<li><p><b>PRAGMA default_synchronous;
<br>PRAGMA default_synchronous = FULL; </b>(2)<b>
<br>PRAGMA default_synchronous = NORMAL; </b>(1)<b>
<br>PRAGMA default_synchronous = OFF; </b>(0)</p>
<p>Query or change the setting of the "synchronous" flag in
the database. The first (query) form will return the setting as an
integer. When synchronous is FULL (2), the SQLite database engine will
pause at critical moments to make sure that data has actually been
written to the disk surface before continuing. This ensures that if
the operating system crashes or if there is a power failure, the database
will be uncorrupted after rebooting. FULL synchronous is very
safe, but it is also slow.
When synchronous is NORMAL (1, the default), the SQLite database
engine will still pause at the most critical moments, but less often
than in FULL mode. There is a very small (though non-zero) chance that
a power failure at just the wrong time could corrupt the database in
NORMAL mode. But in practice, you are more likely to suffer
a catastrophic disk failure or some other unrecoverable hardware
fault. So NORMAL is the default mode.
With synchronous OFF (0), SQLite continues without pausing
as soon as it has handed data off to the operating system.
If the application running SQLite crashes, the data will be safe, but
the database might become corrupted if the operating system
crashes or the computer loses power before that data has been written
to the disk surface. On the other hand, some
operations are as much as 50 or more times faster with synchronous OFF.
</p>
<p>This pragma changes the synchronous mode persistently. Once changed,
the mode stays as set even if the database is closed and reopened. The
<a href="#pragma_synchronous"><b>synchronous</b></a> pragma does the same
thing but only applies the setting to the current session.
</p></li>
<a name="pragma_default_temp_store"></a>
<li><p><b>PRAGMA default_temp_store;
<br>PRAGMA default_temp_store = DEFAULT; </b>(0)<b>
<br>PRAGMA default_temp_store = MEMORY; </b>(2)<b>
<br>PRAGMA default_temp_store = FILE;</b> (1)</p>
<p>Query or change the setting of the "<b>temp_store</b>" flag stored in
the database. When temp_store is DEFAULT (0), the compile-time value
of the symbol TEMP_STORE is used for the temporary database.
When temp_store is MEMORY (2), an in-memory database is used.
When temp_store is FILE (1), a temporary database file on disk will be used.
It is possible for the library compile-time symbol TEMP_STORE to override
this setting. The following table summarizes this:</p>
<table cellpadding="2">
<tr><th>TEMP_STORE</th><th>temp_store</th><th>temp database location</th></tr>
<tr><td align="center">0</td><td align="center"><em>any</em></td><td align="center">file</td></tr>
<tr><td align="center">1</td><td align="center">0</td><td align="center">file</td></tr>
<tr><td align="center">1</td><td align="center">1</td><td align="center">file</td></tr>
<tr><td align="center">1</td><td align="center">2</td><td align="center">memory</td></tr>
<tr><td align="center">2</td><td align="center">0</td><td align="center">memory</td></tr>
<tr><td align="center">2</td><td align="center">1</td><td align="center">file</td></tr>
<tr><td align="center">2</td><td align="center">2</td><td align="center">memory</td></tr>
<tr><td align="center">3</td><td align="center"><em>any</em></td><td align="center">memory</td></tr>
</table>
<p>This pragma changes the temp_store mode for whenever the database
is opened in the future. The temp_store mode for the current session
is unchanged. Use the
<a href="#pragma_temp_store"><b>temp_store</b></a> pragma to change the
temp_store mode for the current session.</p></li>
<li><p><b>PRAGMA foreign_key_list(</b><i>table-name</i><b>);</b></p>
<p>For each foreign key that references a column in the argument
table, invoke the callback function with information about that
foreign key. The callback function will be invoked once for each
column in each foreign key.</p></li>
<li><p><b>PRAGMA index_info(</b><i>index-name</i><b>);</b></p>
<p>For each column that the named index references, invoke the
callback function
once with information about that column, including the column name,
and the column number.</p></li>
<li><p><b>PRAGMA index_list(</b><i>table-name</i><b>);</b></p>
<p>For each index on the named table, invoke the callback function
once with information about that index. Arguments include the
index name and a flag to indicate whether or not the index must be
unique.</p></li>
<li><p><b>PRAGMA integrity_check;</b></p>
<p>The command does an integrity check of the entire database. It
looks for out-of-order records, missing pages, malformed records, and
corrupt indices.
If any problems are found, then a single string is returned which is
a description of all problems. If everything is in order, "ok" is
returned.</p></li>
<li><p><b>PRAGMA parser_trace = ON; </b>(1)<b>
<br>PRAGMA parser_trace = OFF;</b> (0)</p>
<p>Turn tracing of the SQL parser inside of the
SQLite library on and off. This is used for debugging.
This only works if the library is compiled without the NDEBUG macro.
</p></li>
<a name="pragma_synchronous"></a>
<li><p><b>PRAGMA synchronous;
<br>PRAGMA synchronous = FULL; </b>(2)<b>
<br>PRAGMA synchronous = NORMAL; </b>(1)<b>
<br>PRAGMA synchronous = OFF;</b> (0)</p>
<p>Query or change the setting of the "synchronous" flag affecting
the database for the duration of the current database connection.
The synchronous flag reverts to its default value when the database
is closed and reopened. For additional information on the synchronous
flag, see the description of the <a href="#pragma_default_synchronous">
<b>default_synchronous</b></a> pragma.</p>
</li>
<li><p><b>PRAGMA table_info(</b><i>table-name</i><b>);</b></p>
<p>For each column in the named table, invoke the callback function
once with information about that column, including the column name,
data type, whether or not the column can be NULL, and the default
value for the column.</p></li>
<a name="pragma_temp_store"></a>
<li><p><b>PRAGMA temp_store;
<br>PRAGMA temp_store = DEFAULT; </b>(0)<b>
<br>PRAGMA temp_store = MEMORY; </b>(2)<b>
<br>PRAGMA temp_store = FILE;</b> (1)</p>
<p>Query or change the setting of the "temp_store" flag affecting
the database for the duration of the current database connection.
The temp_store flag reverts to its default value when the database
is closed and reopened. For additional information on the temp_store
flag, see the description of the <a href="#pragma_default_temp_store">
<b>default_temp_store</b></a> pragma. Note that it is possible for
the library compile-time options to override this setting. </p>
<p>When the temp_store setting is changed, all existing temporary
tables, indices, triggers, and viewers are immediately deleted.
</p>
</li>
<a name="pragma_vdbe_trace"></a>
<li><p><b>PRAGMA vdbe_trace = ON; </b>(1)<b>
<br>PRAGMA vdbe_trace = OFF;</b> (0)</p>
<p>Turn tracing of the virtual database engine inside of the
SQLite library on and off. This is used for debugging. See the
<a href="vdbe.html#trace">VDBE documentation</a> for more
information.</p></li>
</ul>
<p>No error message is generated if an unknown pragma is issued.
Unknown pragmas are ignored.</p>
}
Section REPLACE replace
Syntax {sql-statement} {
@@ -1661,6 +1417,10 @@ process on an attached database file.</p>
<p>This command will fail if there is an active transaction. This
command has no effect on an in-memory database.</p>
<p>As of SQLite version 3.1, an alternative to using the VACUUM command
is auto-vacuum mode, enabled using the
<a href="pragma.html#pragma_auto_vacuum">auto_vacuum pragma</a>.</p>
}

279
www/pragma.tcl Normal file
View File

@@ -0,0 +1,279 @@
#
# Run this Tcl script to generate the pragma.html file.
#
set rcsid {$Id: pragma.tcl,v 1.1 2004/11/10 05:48:57 danielk1977 Exp $}
source common.tcl
header {Pragma statements supported by SQLite}
puts {
<p>The <a href="#syntax">PRAGMA command</a> is a special command used to
modify the operation of the SQLite library or to query the library for
internal (non-table) data. The PRAGMA command is issued using the same
interface as other SQLite commands (e.g. SELECT, INSERT) but is different
different in the following important respects:
</p>
<ul>
<li>Specific pragma statements may be removed and others added in future
releases of SQLite. Use with caution!
<li>No error messages are generated if an unknown pragma is issued.
Unknown pragmas are simply ignored. This means if there is a typo in
a pragma statement the library does not inform the user of the fact.
<li>Some pragmas take effect during the SQL compilation stage, not the
execution stage. This means if using the C-language sqlite3_compile(),
sqlite3_step(), sqlite3_finalize() API (or similar in a wrapper
interface), the pragma may be applied to the library during the
sqlite3_compile() call.
<li>The pragma command is unlikely to be compatible with any other SQL
engine.
</ul>
<p>The available pragma's fall into three basic categories:</p>
<ul>
<li>Pragmas used to <a href="#schema">query the schema</a> of the current
database.
<li>Pragmas used to <a href="#modify">modify the operation</a> of the
SQLite library in some manner, or to query for the current mode of
operation.
<li>Pragmas used to <a href="#debug">debug the library</a> and verify that
database files are not corrupted.
</ul>
}
Section {PRAGMA command syntax} syntax
Syntax {sql-statement} {
PRAGMA <name> [= <value>] |
PRAGMA <function>(<arg>)
}
puts {
<p>The pragmas that take an integer <b><i>value</i></b> also accept
symbolic names. The strings "<b>on</b>", "<b>true</b>", and "<b>yes</b>"
are equivalent to <b>1</b>. The strings "<b>off</b>", "<b>false</b>",
and "<b>no</b>" are equivalent to <b>0</b>. These strings are case-
insensitive, and do not require quotes. An unrecognized string will be
treated as <b>1</b>, and will not generate an error. When the <i>value</i>
is returned it is as an integer.</p>
}
Section {Pragmas used to modify library operation} modify
puts {
<ul>
<a name="pragma_auto_vacuum"></a>
<li><p><b>PRAGMA auto_vacuum;
<br>PRAGMA auto_vacuum = </b><i>0 | 1</i><b>;</b></p>
<p> Query or set the auto-vacuum flag in the database.</p>
<p>Normally, when a transaction that deletes data from a database is
committed, the database file remains the same size. Unused database file
pages are marked as such and reused later on, when data is inserted into
the database. In this mode the <a href="lang.html#vacuum">VACUUM</a>
command is used to reclaim unused space.</p>
<p>When the auto-vacuum flag is set, the database file shrinks when a
transaction that deletes data is committed (The VACUUM command is not
useful in a database with the auto-vacuum flag set). To support this
functionality the database stores extra information internally, resulting
in slightly larger database files than would otherwise be possible.</p>
<p>It is only possible to modify the value of the auto-vacuum flag before
any tables have been created in the database. No error message is
returned if an attempt to modify the auto-vacuum flag is made after
one or more tables have been created.
</p></li>
<a name="pragma_cache_size"></a>
<li><p><b>PRAGMA cache_size;
<br>PRAGMA cache_size = </b><i>Number-of-pages</i><b>;</b></p>
<p>Query or change the maximum number of database disk pages that SQLite
will hold in memory at once. Each page uses about 1.5K of memory.
The default cache size is 2000. If you are doing UPDATEs or DELETEs
that change many rows of a database and you do not mind if SQLite
uses more memory, you can increase the cache size for a possible speed
improvement.</p>
<p>When you change the cache size using the cache_size pragma, the
change only endures for the current session. The cache size reverts
to the default value when the database is closed and reopened. Use
the <a href="#pragma_default_cache_size"><b>default_cache_size</b></a>
pragma to check the cache size permanently.</p></li>
<a name="pragma_default_cache_size"></a>
<li><p><b>PRAGMA default_cache_size;
<br>PRAGMA default_cache_size = </b><i>Number-of-pages</i><b>;</b></p>
<p>Query or change the maximum number of database disk pages that SQLite
will hold in memory at once. Each page uses 1K on disk and about
1.5K in memory.
This pragma works like the
<a href="#pragma_cache_size"><b>cache_size</b></a>
pragma with the additional
feature that it changes the cache size persistently. With this pragma,
you can set the cache size once and that setting is retained and reused
every time you reopen the database.</p></li>
<a name="pragma_default_synchronous"></a>
<li><p><b>PRAGMA default_synchronous;
<br>PRAGMA default_synchronous = FULL; </b>(2)<b>
<br>PRAGMA default_synchronous = NORMAL; </b>(1)<b>
<br>PRAGMA default_synchronous = OFF; </b>(0)</p>
<p>Query or change the setting of the "synchronous" flag in
the database. The first (query) form will return the setting as an
integer. When synchronous is FULL (2), the SQLite database engine will
pause at critical moments to make sure that data has actually been
written to the disk surface before continuing. This ensures that if
the operating system crashes or if there is a power failure, the database
will be uncorrupted after rebooting. FULL synchronous is very
safe, but it is also slow.
When synchronous is NORMAL (1, the default), the SQLite database
engine will still pause at the most critical moments, but less often
than in FULL mode. There is a very small (though non-zero) chance that
a power failure at just the wrong time could corrupt the database in
NORMAL mode. But in practice, you are more likely to suffer
a catastrophic disk failure or some other unrecoverable hardware
fault. So NORMAL is the default mode.
With synchronous OFF (0), SQLite continues without pausing
as soon as it has handed data off to the operating system.
If the application running SQLite crashes, the data will be safe, but
the database might become corrupted if the operating system
crashes or the computer loses power before that data has been written
to the disk surface. On the other hand, some
operations are as much as 50 or more times faster with synchronous OFF.
</p>
<p>This pragma changes the synchronous mode persistently. Once changed,
the mode stays as set even if the database is closed and reopened. The
<a href="#pragma_synchronous"><b>synchronous</b></a> pragma does the same
thing but only applies the setting to the current session.
</p></li>
<a name="pragma_default_temp_store"></a>
<li><p><b>PRAGMA default_temp_store;
<br>PRAGMA default_temp_store = DEFAULT; </b>(0)<b>
<br>PRAGMA default_temp_store = MEMORY; </b>(2)<b>
<br>PRAGMA default_temp_store = FILE;</b> (1)</p>
<p>Query or change the setting of the "<b>temp_store</b>" flag stored in
the database. When temp_store is DEFAULT (0), the compile-time value
of the symbol TEMP_STORE is used for the temporary database.
When temp_store is MEMORY (2), an in-memory database is used.
When temp_store is FILE (1), a temporary database file on disk will be used.
It is possible for the library compile-time symbol TEMP_STORE to override
this setting. The following table summarizes this:</p>
<table cellpadding="2">
<tr><th>TEMP_STORE</th><th>temp_store</th><th>temp database location</th></tr>
<tr><td align="center">0</td><td align="center"><em>any</em></td><td align="center">file</td></tr>
<tr><td align="center">1</td><td align="center">0</td><td align="center">file</td></tr>
<tr><td align="center">1</td><td align="center">1</td><td align="center">file</td></tr>
<tr><td align="center">1</td><td align="center">2</td><td align="center">memory</td></tr>
<tr><td align="center">2</td><td align="center">0</td><td align="center">memory</td></tr>
<tr><td align="center">2</td><td align="center">1</td><td align="center">file</td></tr>
<tr><td align="center">2</td><td align="center">2</td><td align="center">memory</td></tr>
<tr><td align="center">3</td><td align="center"><em>any</em></td><td align="center">memory</td></tr>
</table>
<p>This pragma changes the temp_store mode for whenever the database
is opened in the future. The temp_store mode for the current session
is unchanged. Use the
<a href="#pragma_temp_store"><b>temp_store</b></a> pragma to change the
temp_store mode for the current session.</p></li>
<a name="pragma_synchronous"></a>
<li><p><b>PRAGMA synchronous;
<br>PRAGMA synchronous = FULL; </b>(2)<b>
<br>PRAGMA synchronous = NORMAL; </b>(1)<b>
<br>PRAGMA synchronous = OFF;</b> (0)</p>
<p>Query or change the setting of the "synchronous" flag affecting
the database for the duration of the current database connection.
The synchronous flag reverts to its default value when the database
is closed and reopened. For additional information on the synchronous
flag, see the description of the <a href="#pragma_default_synchronous">
<b>default_synchronous</b></a> pragma.</p>
</li>
<a name="pragma_temp_store"></a>
<li><p><b>PRAGMA temp_store;
<br>PRAGMA temp_store = DEFAULT; </b>(0)<b>
<br>PRAGMA temp_store = MEMORY; </b>(2)<b>
<br>PRAGMA temp_store = FILE;</b> (1)</p>
<p>Query or change the setting of the "temp_store" flag affecting
the database for the duration of the current database connection.
The temp_store flag reverts to its default value when the database
is closed and reopened. For additional information on the temp_store
flag, see the description of the <a href="#pragma_default_temp_store">
<b>default_temp_store</b></a> pragma. Note that it is possible for
the library compile-time options to override this setting. </p>
<p>When the temp_store setting is changed, all existing temporary
tables, indices, triggers, and viewers are immediately deleted.
</p>
</li>
</ul>
}
Section {Pragma's used to query the database schema} schema
puts {
<ul>
<li><p><b>PRAGMA database_list;</b></p>
<p>For each open database, invoke the callback function once with
information about that database. Arguments include the index and
the name the database was attached with. The first row will be for
the main database. The second row will be for the database used to
store temporary tables.</p></li>
<li><p><b>PRAGMA foreign_key_list(</b><i>table-name</i><b>);</b></p>
<p>For each foreign key that references a column in the argument
table, invoke the callback function with information about that
foreign key. The callback function will be invoked once for each
column in each foreign key.</p></li>
<li><p><b>PRAGMA index_info(</b><i>index-name</i><b>);</b></p>
<p>For each column that the named index references, invoke the
callback function
once with information about that column, including the column name,
and the column number.</p></li>
<li><p><b>PRAGMA index_list(</b><i>table-name</i><b>);</b></p>
<p>For each index on the named table, invoke the callback function
once with information about that index. Arguments include the
index name and a flag to indicate whether or not the index must be
unique.</p></li>
<li><p><b>PRAGMA table_info(</b><i>table-name</i><b>);</b></p>
<p>For each column in the named table, invoke the callback function
once with information about that column, including the column name,
data type, whether or not the column can be NULL, and the default
value for the column.</p></li>
</ul>
}
Section {Pragma's used to debug the library} debug
puts {
<ul>
<li><p><b>PRAGMA integrity_check;</b></p>
<p>The command does an integrity check of the entire database. It
looks for out-of-order records, missing pages, malformed records, and
corrupt indices.
If any problems are found, then a single string is returned which is
a description of all problems. If everything is in order, "ok" is
returned.</p></li>
<li><p><b>PRAGMA parser_trace = ON; </b>(1)<b>
<br>PRAGMA parser_trace = OFF;</b> (0)</p>
<p>Turn tracing of the SQL parser inside of the
SQLite library on and off. This is used for debugging.
This only works if the library is compiled without the NDEBUG macro.
</p></li>
<a name="pragma_vdbe_trace"></a>
<li><p><b>PRAGMA vdbe_trace = ON; </b>(1)<b>
<br>PRAGMA vdbe_trace = OFF;</b> (0)</p>
<p>Turn tracing of the virtual database engine inside of the
SQLite library on and off. This is used for debugging. See the
<a href="vdbe.html#trace">VDBE documentation</a> for more
information.</p></li>
</ul>
}

View File

@@ -1,7 +1,7 @@
#
# Run this Tcl script to generate the vdbe.html file.
#
set rcsid {$Id: vdbe.tcl,v 1.12 2004/05/31 15:06:30 drh Exp $}
set rcsid {$Id: vdbe.tcl,v 1.13 2004/11/10 05:48:57 danielk1977 Exp $}
source common.tcl
header {The Virtual Database Engine of SQLite}
puts {
@@ -303,7 +303,7 @@ program, which the VDBE appends when it prepares a program to run.</p>
<h2>Tracing VDBE Program Execution</h2>
<p>If the SQLite library is compiled without the NDEBUG preprocessor
macro, then the PRAGMA <a href="lang.html#pragma_vdbe_trace">vdbe_trace
macro, then the PRAGMA <a href="pragma.html#pragma_vdbe_trace">vdbe_trace
</a> causes the VDBE to trace the execution of programs. Though this
feature was originally intended for testing and debugging, it can also
be useful in learning about how the VDBE operates.