]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
new section for keywords, more docs for attached databases , links, cleanup (CVS...
authorjplyon <jplyon@noemail.net>
Sun, 4 May 2003 07:02:55 +0000 (07:02 +0000)
committerjplyon <jplyon@noemail.net>
Sun, 4 May 2003 07:02:55 +0000 (07:02 +0000)
FossilOrigin-Name: 87e1b6a936972670771cf90670aeb4308ba0a30a

manifest
manifest.uuid
www/lang.tcl

index 420f9c9156294f09f5e690eb99a5b0a11549d55d..e15d2e4885a807b6bce24cb6ec601d955b5a0847 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C More\sdocumentation\supdates.\s(CVS\s951)
-D 2003-05-03T19:04:04
+C new\ssection\sfor\skeywords,\smore\sdocs\sfor\sattached\sdatabases\s,\slinks,\scleanup\s(CVS\s952)
+D 2003-05-04T07:02:55
 F Makefile.in 004acec253ecdde985c8ecd5b7c9accdb210378f
 F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906
 F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
@@ -155,7 +155,7 @@ F www/faq.tcl 12d1788d4abcfe1ff3054e17605df2418883bf6f
 F www/fileformat.tcl d9b586416c0d099b82e02e469d532c9372f98f3f
 F www/formatchng.tcl cbaf0f410096c71f86a7537cf9249fa04b9a659c
 F www/index.tcl b155eba45136d19e7aa6ba979d4093180c335cf7
-F www/lang.tcl 46fb1a380021aa1e7a51104b53b4066e54ba9b64
+F www/lang.tcl 56f4c1996795204317c850ecf039c851692625d4
 F www/mingw.tcl d96b451568c5d28545fefe0c80bee3431c73f69c
 F www/nulls.tcl 29497dac2bc5b437aa7e2e94577dad4d8933ed26
 F www/omitted.tcl 118062f40a203fcb88b8d68ef1d7c0073ac191ec
@@ -165,7 +165,7 @@ F www/speed.tcl cb4c10a722614aea76d2c51f32ee43400d5951be
 F www/sqlite.tcl ae3dcfb077e53833b59d4fcc94d8a12c50a44098
 F www/tclsqlite.tcl 1db15abeb446aad0caf0b95b8b9579720e4ea331
 F www/vdbe.tcl 2013852c27a02a091d39a766bc87cff329f21218
-P fd28c5229ece1d90e24d0ecaa518d8df5a4f55f0
-R 0f44dbdd9ad557cbceb63cfdf312e27b
-U drh
-Z 7676704ebf2d2713ee0ac3dc2cc0e3d3
+P 24b9b569240d2108b17420d85cafdc718c67269f
+R f59caf097b77c12dfe5196947fa850d1
+U jplyon
+Z 15d8de3d7ad598167e85986bd9fd5378
index b74d9be41e38c155a35b530841447e984930513a..ed71258db1f8a0fc1b35c6ff2eebc0ade8f70255 100644 (file)
@@ -1 +1 @@
-24b9b569240d2108b17420d85cafdc718c67269f
\ No newline at end of file
+87e1b6a936972670771cf90670aeb4308ba0a30a
\ No newline at end of file
index 90f03f1ebd8128cd3e33bd43366f9c1aa3d8f319..b17d2092f2779e50a8749d9d5eef56c203e42835 100644 (file)
@@ -1,7 +1,7 @@
 #
 # Run this Tcl script to generate the sqlite.html file.
 #
-set rcsid {$Id: lang.tcl,v 1.52 2003/05/03 19:04:04 drh Exp $}
+set rcsid {$Id: lang.tcl,v 1.53 2003/05/04 07:02:55 jplyon Exp $}
 
 puts {<html>
 <head>
@@ -29,7 +29,8 @@ that are part of the syntactic markup itself are shown in black roman.</p>
 
 <p>This document is just an overview of the SQL syntax implemented
 by SQLite.  Many low-level productions are omitted.  For detailed information
-on the language that SQLite understands, refer to the source code.</p>
+on the language that SQLite understands, refer to the source code and
+the grammar file "parse.y".</p>
 
 
 <p>SQLite implements the follow syntax:</p>
@@ -52,14 +53,17 @@ foreach {section} [lsort -index 0 -dictionary {
   {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} attachdatabase}
-  {{DETACH DATABASE} detachdatabase}
+  {{ATTACH DATABASE} attach}
+  {{DETACH DATABASE} detach}
 }] {
   puts "<li><a href=\"#[lindex $section 1]\">[lindex $section 0]</a></li>"
 }
@@ -112,21 +116,39 @@ proc Example {text} {
 }
 
 
-Section {ATTACH DATABASE} attachdatabase
+Section {ATTACH DATABASE} attach
 
 Syntax {sql-statement} {
 ATTACH [DATABASE] <database-filename> AS <database-name>
 }
 
 puts {
-<p>The ATTACH DATABASE statement lets you add a preexisting 
-database file to the current database connection.</p>
-
-<p>You can read and write to the attached database, but you cannot 
-CREATE TABLE or DROP TABLE in the attached database. You can only 
-CREATE and DROP in the original database.</p>
-
-<p>With an attached database, transactions are not atomic. 
+<p>The ATTACH DATABASE statement adds a preexisting database 
+file to the current database connection.  If the filename contains 
+punctuation characters it must be quoted.  The names 'main' and 
+'temp' refer to the main database and the database used for 
+temporary tables.  These cannot be detached.  Attached databases 
+are removed using the <a href="#detach">DETACH DATABASE</a> 
+statement.</p>
+
+<p>You can read from and write to an attached database, but you cannot 
+alter the schema of an attached database.  You can only CREATE and 
+DROP in the original database.</p>
+
+<p>You cannot create a new table with the same name as a table in 
+an attached database, but you can attach a database which contains
+tables whose names are duplicates of tables in the main database.</p>
+
+<p>Tables in an attached database can be referred to using the syntax 
+<i>database-name.table-name</i>.  If an attached table doesn't have 
+a duplicate table name in the main database, it doesn't require a 
+database name prefix.  When a database is attached, all of its 
+tables which don't have duplicate names become the 'default' table
+of that name.  Any tables of that name attached afterwards require the table 
+prefix. If the 'default' table of a given name is detached, then 
+the last table of that name attached becomes the new default.</p>
+
+<p>When there are attached databases, transactions are not atomic. 
 Transactions continue to be atomic within each individual
 database file. But if your machine crashes in the middle
 of a COMMIT where you have updated two or more database
@@ -158,12 +180,17 @@ ROLLBACK [TRANSACTION [<name>]]
 
 puts {
 <p>Beginning in version 2.0, SQLite supports transactions with
-rollback and atomic commit.</p>
+rollback and atomic commit.  See <a href="#attach">ATTACH</a> for
+an exception when there are attached databases.</p>
+
+<p>The optional transaction name is ignored. SQLite currently 
+doesn't allow nested transactions.  Attempting to start a new 
+transaction inside another is an error.</p>
 
 <p>
 No changes can be made to the database except within a transaction.
 Any command that changes the database (basically, any SQL command
-other than SELECT) will automatically starts a transaction if
+other than SELECT) will automatically start a transaction if
 one is not already in effect.  Automatically started transactions
 are committed at the conclusion of the command.
 </p>
@@ -199,7 +226,6 @@ Syntax {comment} {<SQL-comment> | <C-comment>
 } {C-comment} {/STAR <multiple-lines> [STAR/]
 }
 
-
 puts {
 <p> Comments aren't SQL commands, but can occur in SQL queries. They are 
 treated as whitespace by the parser. They can begin anywhere whitespace 
@@ -221,11 +247,10 @@ C comments do not nest. SQL comments inside a C comment will be ignored.
 Section COPY copy
 
 Syntax {sql-statement} {
-COPY [ OR <conflict-algorithm> ] <table-name> FROM <filename>
+COPY [ OR <conflict-algorithm> ] [<database-name> .] <table-name> FROM <filename>
 [ USING DELIMITERS <delim> ]
 }
 
-
 puts {
 <p>The COPY command is an extension used to load large amounts of
 data into a table.  It is modeled after a similar command found
@@ -263,13 +288,12 @@ Section {CREATE INDEX} createindex
 
 Syntax {sql-statement} {
 CREATE [TEMP | TEMPORARY] [UNIQUE] INDEX <index-name> 
-ON <table-name> ( <column-name> [, <column-name>]* )
+ON [<database-name> .] <table-name> ( <column-name> [, <column-name>]* )
 [ ON CONFLICT <conflict-algorithm> ]
 } {column-name} {
 <name> [ ASC | DESC ]
 }
 
-
 puts {
 <p>The CREATE INDEX command consists of the keywords "CREATE INDEX" followed
 by the name of the new index, the keyword "ON", the name of a previously
@@ -303,6 +327,10 @@ being indexed is temporary.  Everytime the database is opened,
 all CREATE INDEX statements
 are read from the <b>sqlite_master</b> table and used to regenerate
 SQLite's internal representation of the index layout.</p>
+
+<p>Non-temporary indexes cannot be added on tables in attached 
+databases.  They are removed with the <a href="#dropindex">DROP INDEX</a> 
+command.</p>
 }
 
 
@@ -412,6 +440,10 @@ in place of the original command.
 The text of CREATE TEMPORARY TABLE statements are stored in the
 <b>sqlite_temp_master</b> table.
 </p>
+
+<p>Tables are removed using the <a href="#droptable">DROP TABLE</a> 
+statement.  Non-temporary tables in an attached database cannot be 
+dropped.</p>
 }
 
 
@@ -419,13 +451,13 @@ Section {CREATE TRIGGER} createtrigger
 
 Syntax {sql-statement} {
 CREATE [TEMP | TEMPORARY] TRIGGER <trigger-name> [ BEFORE | AFTER ]
-<database-event> ON <table-name>
+<database-event> ON [<database-name> .] <table-name>
 <trigger-action>
 }
 
 Syntax {sql-statement} {
 CREATE [TEMP | TEMPORARY] TRIGGER <trigger-name> INSTEAD OF
-<database-event> ON <view-name>
+<database-event> ON [<database-name> .] <view-name>
 <trigger-action>
 }
 
@@ -437,7 +469,7 @@ UPDATE OF <column-list>
 }
 
 Syntax {trigger-action} {
-[ FOR EACH ROW ] [ WHEN <expression> ] 
+[ FOR EACH ROW | FOR EACH STATEMENT ] [ WHEN <expression> ] 
 BEGIN 
   <trigger-step> ; [ <trigger-step> ; ]*
 END
@@ -565,6 +597,10 @@ the statement that caused the trigger program to execute and any subsequent
     to execute is itself part of a trigger program, then that trigger program
     resumes execution at the beginning of the next step.
 </p>
+
+<p>Triggers are removed using the <a href="#droptrigger">DROP TRIGGER</a>
+statement.  Non-temporary triggers cannot be added on a table in an 
+attached database.</p>
 }
 
 
@@ -580,14 +616,17 @@ statement.  Once the view is created, it can be used in the FROM clause
 of another SELECT in place of a table name.
 </p>
 
-<p>You cannot COPY, INSERT or UPDATE a view.  Views are read-only.</p>
+<p>You cannot COPY, INSERT or UPDATE a view.  Views are read-only 
+in SQLite.  Views are removed with the <a href="#dropview">DROP VIEW</a> 
+command.  Non-temporary views cannot be created on tables in an attached 
+database.</p>
 }
 
 
 Section DELETE delete
 
 Syntax {sql-statement} {
-DELETE FROM <table-name> [WHERE <expr>]
+DELETE FROM [<database-name> .] <table-name> [WHERE <expr>]
 }
 
 puts {
@@ -602,15 +641,15 @@ the expression are removed.</p>
 }
 
 
-Section {DETACH DATABASE} detachdatabase
+Section {DETACH DATABASE} detach
 
 Syntax {sql-command} {
 DETACH [DATABASE] <database-name>
 }
 
 puts {
-<p>This statement detaches an additional database file previoiusly attached
-using the ATTACH DATABASE statement.</p>
+<p>This statement detaches an additional database file previously attached
+using the <a href="#attach">ATTACH DATABASE</a> statement.</p>
 
 <p>This statement will fail if SQLite is in the middle of a transaction.</p>
 }
@@ -619,14 +658,15 @@ using the ATTACH DATABASE statement.</p>
 Section {DROP INDEX} dropindex
 
 Syntax {sql-command} {
-DROP INDEX <index-name>
+DROP INDEX [<database-name> .] <index-name>
 }
 
 puts {
-<p>The DROP INDEX statement consists of the keywords "DROP INDEX" followed
-by the name of the index.  The index named is completely removed from
+<p>The DROP INDEX statement removes an index added with the <a href="#createindex">
+CREATE INDEX</a> statement.  The index named is completely removed from
 the disk.  The only way to recover the index is to reenter the
-appropriate CREATE INDEX command.</p>
+appropriate CREATE INDEX command.  Non-temporary indexes on tables in 
+an attached database cannot be dropped.</p>
 }
 
 
@@ -637,19 +677,25 @@ DROP TABLE <table-name>
 }
 
 puts {
-<p>The DROP TABLE statement consists of the keywords "DROP TABLE" followed
-by the name of the table.  The table named is completely removed from
-the disk.  The table can not be recovered.  All indices associated with
-the table are also deleted.</p>}
+<p>The DROP TABLE statement removes a table added with the <a href=
+"#createtable">CREATE TABLE</a> statement.  The name specified is the
+table name.  It is completely removed from the database schema and the 
+disk file.  The table can not be recovered.  All indices associated 
+with the table are also deleted.  Non-temporary tables in an attached 
+database cannot be dropped.</p>
+}
 
 
 Section {DROP TRIGGER} droptrigger
 Syntax {sql-statement} {
-DROP TRIGGER <trigger-name>
+DROP TRIGGER [<database-name> .] <trigger-name>
 }
 puts { 
-  <p>Used to drop a trigger from the database schema. Note that triggers
-  are automatically dropped when the associated table is dropped.</p>
+<p>The DROP TRIGGER statement removes a trigger created by the 
+<a href="#createtrigger">CREATE TRIGGER</a> statement.  The trigger is 
+deleted from the database schema. Note that triggers are automatically 
+dropped when the associated table is dropped.  Non-temporary triggers 
+cannot be dropped on attached tables.</p>
 }
 
 
@@ -660,9 +706,12 @@ DROP VIEW <view-name>
 }
 
 puts {
-<p>The DROP VIEW statement consists of the keywords "DROP VIEW" followed
-by the name of the view.  The view named is removed from the database.
-But no actual data is modified.</p>}
+<p>The DROP VIEW statement removes a view created by the <a href=
+"#createview">CREATE VIEW</a> statement.  The name specified is the 
+view name.  It is removed from the database schema, but no actual data 
+in the underlying base tables is modified.  Non-temporary views in 
+attached databases cannot be dropped.</p>
+}
 
 
 Section EXPLAIN explain
@@ -695,6 +744,7 @@ Syntax {expr} {
 ( <expr> ) |
 <column-name> |
 <table-name> . <column-name> |
+<database-name> . <table-name> . <column-name> |
 <literal-value> |
 <function-name> ( <expr-list> | STAR ) |
 <expr> (+) |
@@ -985,8 +1035,8 @@ The usual sort order is used to determine the minimum.</td>
 Section INSERT insert
 
 Syntax {sql-statement} {
-INSERT [OR <conflict-algorithm>] INTO <table-name> [(<column-list>)] VALUES(<value-list>) |
-INSERT [OR <conflict-algorithm>] INTO <table-name> [(<column-list>)] <select-statement>
+INSERT [OR <conflict-algorithm>] INTO [<database-name> .] <table-name> [(<column-list>)] VALUES(<value-list>) |
+INSERT [OR <conflict-algorithm>] INTO [<database-name> .] <table-name> [(<column-list>)] <select-statement>
 }
 
 puts {
@@ -1305,15 +1355,15 @@ Unknown pragmas are ignored.</p>
 Section REPLACE replace
 
 Syntax {sql-statement} {
-REPLACE INTO <table-name> [( <column-list> )] VALUES ( <value-list> ) |
-REPLACE INTO <table-name> [( <column-list> )] <select-statement>
+REPLACE INTO [<database-name> .] <table-name> [( <column-list> )] VALUES ( <value-list> ) |
+REPLACE INTO [<database-name> .] <table-name> [( <column-list> )] <select-statement>
 }
 
 puts {
 <p>The REPLACE command is an alias for the "INSERT OR REPLACE" variant
-of the <a href="#insert">INSERT command</a>.  This alias is provided for
+of the <a href="#insert">INSERT</a> command.  This alias is provided for
 compatibility with MySQL.  See the 
-<a href="#insert">INSERT command</a> documentation for additional
+<a href="#insert">INSERT</a> command documentation for additional
 information.</p>  
 }
 
@@ -1338,7 +1388,7 @@ STAR | <table-name> . STAR | <expr> [ [AS] <string> ]
 <table-name> [AS <alias>] |
 ( <select> ) [AS <alias>]
 } {join-op} {
-, | [NATURAL] [LEFT | RIGHT | FULL] [OUTER | INNER] JOIN
+, | [NATURAL] [LEFT | RIGHT | FULL] [OUTER | INNER | CROSS] JOIN
 } {join-args} {
 [ON <expr>] [USING ( <id-list> )]
 } {sort-expr-list} {
@@ -1361,6 +1411,11 @@ puts {for that one expression.  If the expression is the name of}
 puts "a table followed by [Operator .*] then the result is all columns"
 puts {in that one table.</p>
 
+<p>The DISTINCT keyword causes a subset of result rows to be returned, 
+in which each result row is different.  NULL values are not treated as 
+distinct from eachother.  The default behavior is that all result rows 
+be returned, which can be made explicit with the keyword ALL.</p>
+
 <p>The query is executed against one or more tables specified after
 the FROM keyword.  If multiple tables names are separated by commas,
 then the query is against the cross join of the various tables.
@@ -1413,7 +1468,7 @@ are connected into a compound, they group from left to right.</p>
 Section UPDATE update
 
 Syntax {sql-statement} {
-UPDATE [ OR <conflict-algorithm> ] <table-name>
+UPDATE [ OR <conflict-algorithm> ] [<database-name> .] <table-name>
 SET <assignment> [, <assignment>]*
 [WHERE <expr>]
 } {assignment} {
@@ -1461,6 +1516,33 @@ command has no effect on an in-memory database.</p>
 }
 
 
+Section {SQLite keywords} keywords
+
+puts {
+<p>The following keywords are used by SQLite. Most are either reserved 
+words in SQL-92 or were listed as potential reserved words.  Those which 
+aren't are shown in italics.  Not all of these words are actually used
+by SQLite.  SQLite doesn't currently enforce reserved words, so most of
+these can actually be used for the names of SQLite objects such as 
+tables, columns, and views, but they must be generally be enclosed by 
+brackes or quotes to avoid confusing the parser.</p>
+
+<p><i>_ROWID_</i> <i>ABORT</i> AFTER ALL AND AS ASC <i>ATTACH</i> 
+BEFORE BEGIN BETWEEN BY CASCADE CASE CHECK <i>CLUSTER</i> COLLATE 
+COMMIT <i>CONFLICT</i> CONSTRAINT <i>COPY</i> CREATE CROSS 
+<i>DATABASE</i> DEFAULT DEFERRED DEFERRABLE DELETE <i>DELIMITERS</i> 
+DESC <i>DETACH</i> DISTINCT DROP EACH ELSE END EXCEPT <i>EXPLAIN</i> 
+<i>FAIL</i> FOR FOREIGN FROM FULL <i>GLOB</i> GROUP HAVING IGNORE 
+IMMEDIATE IN <i>INDEX</i> INITIALLY INNER INSERT <i>INSTEAD</i> 
+INTERSECT INTO IS <i>ISNULL</i> JOIN KEY LEFT LIKE LIMIT MATCH NATURAL 
+NOT <i>NOTNULL</i> NULL OF <i>OFFSET</i> ON OR ORDER OUTER <i>PRAGMA</i> 
+PRIMARY <i>RAISE</i> REFERENCES <i>REPLACE</i> RESTRICT RIGHT ROLLBACK 
+<i>ROW</i> <i>ROWID</i> SELECT SET <i>STATEMENT</i> TABLE <i>TEMP</i> 
+TEMPORARY THEN TRANSACTION TRIGGER UNION UNIQUE UPDATE USING <i>VACUUM</i> 
+VALUES VIEW WHEN WHERE</p>
+}
+
+
 puts {
 <p><hr /></p>
 <p><a href="index.html"><img src="/goback.jpg" border=0 />