/ Check-in [049abcb3]
Login

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

Overview
Comment::-) (CVS 86)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 049abcb37def4200fb8f4ad7cea60a1d53ee3219
User & Date: drh 2000-06-08 21:53:06
Context
2000-06-09
01:58
:-) (CVS 87) check-in: 3661b5ff user: drh tags: trunk
2000-06-08
21:53
:-) (CVS 86) check-in: 049abcb3 user: drh tags: trunk
19:43
:-) (CVS 85) check-in: 8b1c151b user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to Makefile.in.

   181    181   
   182    182   changes.html:	$(TOP)/www/changes.tcl
   183    183   	tclsh $(TOP)/www/changes.tcl >changes.html
   184    184   
   185    185   fileformat.html:	$(TOP)/www/fileformat.tcl
   186    186   	tclsh $(TOP)/www/fileformat.tcl >fileformat.html
   187    187   
          188  +lang.html:	$(TOP)/www/lang.tcl
          189  +	tclsh $(TOP)/www/lang.tcl >lang.html
          190  +
   188    191   # Files to be published on the website.
   189    192   #
   190    193   PUBLISH = \
   191    194     sqlite.tar.gz \
   192    195     index.html \
   193    196     sqlite.html \
   194    197     changes.html \
   195    198     fileformat.html \
          199  +  lang.html \
   196    200     c_interface.html
   197    201   
   198    202   website:	$(PUBLISH)
   199    203   
   200    204   publish:	$(PUBLISH)
   201    205   	scp $(PUBLISH) hwaci@oak.he.net:public_html/sw/sqlite
   202    206   
   203    207   clean:	
   204    208   	rm -f *.o sqlite libsqlite.a sqlite.h
   205    209   	rm -f lemon lempar.c parse.* sqlite.tar.gz
   206    210   	rm -f $(PUBLISH)
   207    211   	rm -f *.da *.bb *.bbg gmon.out

Added www/lang.tcl.

            1  +#
            2  +# Run this Tcl script to generate the sqlite.html file.
            3  +#
            4  +set rcsid {$Id: lang.tcl,v 1.1 2000/06/08 21:53:06 drh Exp $}
            5  +
            6  +puts {<html>
            7  +<head>
            8  +  <title>Query Language Understood By SQLite</title>
            9  +</head>
           10  +<body bgcolor=white>
           11  +<h1 align=center>
           12  +SQL As Understood By SQLite
           13  +</h1>}
           14  +puts "<p align=center>
           15  +(This page was last modified on [lrange $rcsid 3 4] GMT)
           16  +</p>"
           17  +
           18  +puts {
           19  +<p>The SQLite library understands most of the standard SQL
           20  +language.  But it does omit some features while at the same time
           21  +adding a few features of its own.  This document attempts to
           22  +describe percisely what parts of the SQL language SQLite does
           23  +and does not support.</p>
           24  +
           25  +<p>In all of the syntax diagrams that follow, literal text is shown in
           26  +bold blue.  Non-terminal symbols are shown in italic red.  Operators
           27  +that are part of the syntactic markup itself are shown in black roman.</p>
           28  +
           29  +<p>This document is just an overview of the SQL syntax implemented
           30  +by SQLite.  Many low-level productions are omitted.  For detailed information
           31  +on the language that SQLite understands, refer to the source code.</p>
           32  +
           33  +<h2>CREATE TABLE</h2>
           34  +
           35  +<p>The basic structure of a CREATE TABLE statement is as follows:</p>
           36  +}
           37  +
           38  +proc Syntax {args} {
           39  +  puts {<table cellpadding="15">}
           40  +  foreach {rule body} $args {
           41  +    puts "<tr><td align=\"right\" valign=\"top\">"
           42  +    puts "<i><font color=\"#ff3434\">$rule</font></i>&nbsp;::=</td>"
           43  +    regsub -all < $body {%LT} body
           44  +    regsub -all > $body {%GT} body
           45  +    regsub -all %LT $body {</font></b><i><font color="#ff3434">} body
           46  +    regsub -all %GT $body {</font></i><b><font color="#2c2cf0">} body
           47  +    regsub -all {[]|[*?]} $body {</font></b>&<b><font color="#2c2cf0">} body
           48  +    regsub -all "\n" [string trim $body] "<br>\n" body
           49  +    regsub -all "\n  *" $body "\n\\&nbsp;\\&nbsp;\\&nbsp;\\&nbsp;" body
           50  +    regsub -all {[|,*()]} $body {<big>&</big>} body
           51  +    puts "<td><b><font color=\"#2c2cf0\">$body</font></b></td></tr>"
           52  +  }
           53  +  puts {</table>}
           54  +}
           55  +
           56  +Syntax {sql-command} {
           57  +CREATE TABLE <table-name> (
           58  +  <column-def> [, <column-def>]*
           59  +  [, <constraint>]*
           60  +)
           61  +} {column-def} {
           62  +<name> <type> [<column-constraint>]*
           63  +} {type} {
           64  +<typename> |
           65  +<typename> ( <number> ) |
           66  +<typename> ( <number> , <number> )
           67  +} {column-constraint} {
           68  +NOT NULL |
           69  +PRIMARY KEY [<sort-order>] |
           70  +UNIQUE |
           71  +CHECK ( <expr> )
           72  +} {constraint} {
           73  +PRIMARY KEY ( <name> [, <name>]* ) |
           74  +UNIQUE ( <name> [, <name>]* ) |
           75  +CHECK ( <expr> )
           76  +}
           77  +
           78  +puts {
           79  +<p>A CREATE TABLE statement is basically the keywords "CREATE TABLE"
           80  +followed by the name of a new table and a parenthesized list of column
           81  +definitions and constraints.  The table name can be either an identifier
           82  +or a string.  The only reserved table name is "<b>sqlite_master</b>" which
           83  +is the name of the table that records the database schema.</p>
           84  +
           85  +<p>Each column definition is the name of the column followed by the
           86  +datatype for that column, then one or more optional column constraints.
           87  +The datatype for the column is ignored.  All information
           88  +is stored as null-terminated strings.  The constraints are also ignored,
           89  +except that the PRIMARY KEY constraint will cause an index to be automatically
           90  +created that implements the primary key.  The name of the primary
           91  +key index will be the table name
           92  +with "<b>__primary_key</b>" appended.  The index used for a primary key
           93  +does not show up in the <b>sqlite_master</b> table, but a GDBM file is
           94  +created for that index.</p>
           95  +
           96  +<p>There are no arbitrary limits on the size of columns, on the number
           97  +of columns, or on the number of constraints in a table.</p>
           98  +
           99  +<p>The exact text
          100  +of each CREATE TABLE statement is stored in the <b>sqlite_master</b>
          101  +table.  Everytime the database is opened, all CREATE TABLE statements
          102  +are read from the <b>sqlite_master</b> table and used to regenerate
          103  +SQLite's internal representation of the table layout.</p>
          104  +}
          105  +
          106  +puts {<h2>CREATE INDEX</h2>
          107  +}
          108  +
          109  +Syntax {sql-statement} {
          110  +CREATE INDEX <index-name> 
          111  +ON <table-name> ( <column-name> [, <column-name>]* )
          112  +} {column-name} {
          113  +<name> [ ASC | DESC ]
          114  +}
          115  +
          116  +puts {
          117  +<p>The CREATE INDEX command consists of the keywords "CREATE INDEX" followed
          118  +by the name of the new index, the keyword "ON" the name of a previously
          119  +created table that is to be indexed, and a parenthesized list of names of
          120  +columns in the table that are used for the index key.
          121  +Each column name can be followed by one of the "ASC" or "DESC" keywords
          122  +to indicate sort order, but since GDBM does not implement ordered keys,
          123  +these keywords are ignored.</p>
          124  +
          125  +<p>There are no arbitrary limits on the number of indices that can be
          126  +attached to a single table, nor on the number of columns in an index.</p>
          127  +
          128  +<p>The exact text
          129  +of each CREATE INDEX statement is stored in the <b>sqlite_master</b>
          130  +table.  Everytime the database is opened, all CREATE INDEX statements
          131  +are read from the <b>sqlite_master</b> table and used to regenerate
          132  +SQLite's internal representation of the index layout.</p>
          133  +
          134  +<h2>DROP TABLE</h2>
          135  +}
          136  +
          137  +Syntax {sql-command} {
          138  +DROP TABLE <table-name>
          139  +}
          140  +
          141  +puts {
          142  +<p>The DROP TABLE statement consists of the keywords "DROP TABLE" followed
          143  +by the name of the table.  The table named is completely removed from
          144  +the disk.  The table can not be recovered.  All indices associated with
          145  +the table are also reversibly deleted.</p>
          146  +
          147  +<h2>DROP INDEX</h2>
          148  +}
          149  +
          150  +Syntax {sql-command} {
          151  +DROP INDEX <index-name>
          152  +}
          153  +
          154  +puts {
          155  +<p>The DROP INDEX statement consists of the keywords "DROP INDEX" followed
          156  +by the name of the index.  The index named is completely removed from
          157  +the disk.  The only way to recover the index is to reenter the
          158  +appropriate CREATE INDEX command.</p>
          159  +
          160  +<h2>VACUUM</h2>
          161  +}
          162  +
          163  +Syntax {sql-statement} {
          164  +VACUUM [<index-or-table-name>]
          165  +}
          166  +
          167  +puts {
          168  +<p>The VACUUM command is an SQLite extension modelled after a similar
          169  +command found in PostgreSQL.  If VACUUM is invoked with the name of a
          170  +table or index, then the <b>gdbm_reorganize()</b> function is called
          171  +on the corresponding GDBM file.  If VACUUM is invoked with no arguments,
          172  +then <b>gdbm_reorganize()</b> is call on every GDBM file in the database.</p>
          173  +
          174  +<p>It is a good idea to run VACUUM after creating large indices,
          175  +especially indices where a single index value refers to many
          176  +entries in the data table.  Reorganizing these indices will make
          177  +the underlying GDBM file much smaller and will help queries to
          178  +run much faster.</p>
          179  +
          180  +}
          181  +
          182  +puts {
          183  +<p><hr /></p>
          184  +<p><a href="index.html"><img src="/goback.jpg" border=0 />
          185  +Back to the SQLite Home Page</a>
          186  +</p>
          187  +
          188  +</body></html>}