1891 lines
		
	
	
		
			102 KiB
		
	
	
	
		
			HTML
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			1891 lines
		
	
	
		
			102 KiB
		
	
	
	
		
			HTML
		
	
	
		
			Executable File
		
	
	
	
	
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
 | 
						||
<!-- saved from url=(0040)http://www.hwaci.com/sw/sqlite/lang.html -->
 | 
						||
<HTML><HEAD><TITLE>Query Language Understood By SQLite</TITLE>
 | 
						||
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
 | 
						||
<META content="MSHTML 6.00.2800.1400" name=GENERATOR>
 | 
						||
<LINK rel="stylesheet" href="../stili/stile_p.css">
 | 
						||
</HEAD>
 | 
						||
<BODY bgcolor="#ffffff" leftmargin="5">
 | 
						||
<H1 align=center>SQL As Understood By SQLite </H1>
 | 
						||
<P align=center>(This page was last modified on 2004/01/19 05:09:24 UTC) </P>
 | 
						||
<P>The SQLite library understands most of the standard SQL language. But it does 
 | 
						||
<A href="http://www.hwaci.com/sw/sqlite/omitted.html">omit some features</A> 
 | 
						||
while at the same time adding a few features of its own. This document attempts 
 | 
						||
to describe percisely what parts of the SQL language SQLite does and does not 
 | 
						||
support. A list of <A 
 | 
						||
href="#keywords">keywords</A> is given 
 | 
						||
at the end.</P>
 | 
						||
<P>In all of the syntax diagrams that follow, literal text is shown in bold 
 | 
						||
blue. Non-terminal symbols are shown in italic red. Operators 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 and the grammar file 
 | 
						||
"parse.y".</P>
 | 
						||
<P>SQLite implements the follow syntax:</P>
 | 
						||
<P>
 | 
						||
<UL>
 | 
						||
  <LI><A href="#attach">ATTACH 
 | 
						||
  DATABASE</A> 
 | 
						||
  <LI><A href="#transaction">BEGIN 
 | 
						||
  TRANSACTION</A> 
 | 
						||
  <LI><A href="#comment">comment</A> 
 | 
						||
  <LI><A href="#transaction">COMMIT 
 | 
						||
  TRANSACTION</A> 
 | 
						||
  <LI><A href="#copy">COPY</A> 
 | 
						||
  <LI><A href="#createindex">CREATE 
 | 
						||
  INDEX</A> 
 | 
						||
  <LI><A href="#createtable">CREATE 
 | 
						||
  TABLE</A> 
 | 
						||
  <LI><A href="#createtrigger">CREATE 
 | 
						||
  TRIGGER</A> 
 | 
						||
  <LI><A href="#createview">CREATE 
 | 
						||
  VIEW</A> 
 | 
						||
  <LI><A href="#delete">DELETE</A> 
 | 
						||
  <LI><A href="#detach">DETACH 
 | 
						||
  DATABASE</A> 
 | 
						||
  <LI><A href="#dropindex">DROP 
 | 
						||
  INDEX</A> 
 | 
						||
  <LI><A href="#droptable">DROP 
 | 
						||
  TABLE</A> 
 | 
						||
  <LI><A href="#droptrigger">DROP 
 | 
						||
  TRIGGER</A> 
 | 
						||
  <LI><A href="#dropview">DROP VIEW</A> 
 | 
						||
  <LI><A href="#transaction">END 
 | 
						||
  TRANSACTION</A> 
 | 
						||
  <LI><A href="#explain">EXPLAIN</A> 
 | 
						||
  <LI><A href="#expr">expression</A> 
 | 
						||
  <LI><A href="#insert">INSERT</A> 
 | 
						||
  <LI><A href="#conflict">ON CONFLICT 
 | 
						||
  clause</A> 
 | 
						||
  <LI><A href="#pragma">PRAGMA</A> 
 | 
						||
  <LI><A href="#replace">REPLACE</A> 
 | 
						||
  <LI><A href="#transaction">ROLLBACK 
 | 
						||
  TRANSACTION</A> 
 | 
						||
  <LI><A href="#select">SELECT</A> 
 | 
						||
  <LI><A href="#update">UPDATE</A> 
 | 
						||
  <LI><A href="#vacuum">VACUUM</A> 
 | 
						||
</LI></UL>
 | 
						||
<P></P>
 | 
						||
<P>Details on the implementation of each command are provided in the sequel.</P>
 | 
						||
<HR>
 | 
						||
<A name=attach></A>
 | 
						||
<H1>ATTACH DATABASE</H1>
 | 
						||
<TABLE cellPadding=10>
 | 
						||
  <TBODY>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right><I><FONT 
 | 
						||
      color=#ff3434>sql-statement</FONT></I> ::=</TD>
 | 
						||
    <TD><B><FONT color=#2c2cf0>ATTACH </FONT></B>[<B><FONT 
 | 
						||
      color=#2c2cf0>DATABASE</FONT></B>]<B><FONT color=#2c2cf0> 
 | 
						||
      </FONT></B><I><FONT color=#ff3434>database-filename</FONT></I><B><FONT 
 | 
						||
      color=#2c2cf0> AS </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>database-name</FONT></I><B><FONT 
 | 
						||
  color=#2c2cf0></FONT></B></TD></TR></TBODY></TABLE>
 | 
						||
<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. It is also permissible to attach the 
 | 
						||
same database file multiple times.</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 
 | 
						||
files, some of those files might get the changes where others might not.</P>
 | 
						||
<P>There is a compile-time limit of 10 attached database files.</P>
 | 
						||
<P>Executing a BEGIN TRANSACTION statement locks all database files, so this 
 | 
						||
feature cannot (currently) be used to increase concurrancy.</P>
 | 
						||
<HR>
 | 
						||
<A name=transaction></A>
 | 
						||
<H1>BEGIN TRANSACTION</H1>
 | 
						||
<TABLE cellPadding=10>
 | 
						||
  <TBODY>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right><I><FONT 
 | 
						||
      color=#ff3434>sql-statement</FONT></I> ::=</TD>
 | 
						||
    <TD><B><FONT color=#2c2cf0>BEGIN </FONT></B>[<B><FONT 
 | 
						||
      color=#2c2cf0>TRANSACTION </FONT></B>[<B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B><I><FONT color=#ff3434>name</FONT></I><B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B>]<B><FONT color=#2c2cf0></FONT></B>]<B><FONT 
 | 
						||
      color=#2c2cf0> </FONT></B>[<B><FONT color=#2c2cf0>ON CONFLICT 
 | 
						||
      </FONT></B><I><FONT color=#ff3434>conflict-algorithm</FONT></I><B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B>]<B><FONT 
 | 
						||
color=#2c2cf0></FONT></B></TD></TR></TBODY></TABLE>
 | 
						||
<TABLE cellPadding=10>
 | 
						||
  <TBODY>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right><I><FONT 
 | 
						||
      color=#ff3434>sql-statement</FONT></I> ::=</TD>
 | 
						||
    <TD><B><FONT color=#2c2cf0>END </FONT></B>[<B><FONT 
 | 
						||
      color=#2c2cf0>TRANSACTION </FONT></B>[<B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B><I><FONT color=#ff3434>name</FONT></I><B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B>]<B><FONT color=#2c2cf0></FONT></B>]<B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B></TD></TR></TBODY></TABLE>
 | 
						||
<TABLE cellPadding=10>
 | 
						||
  <TBODY>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right><I><FONT 
 | 
						||
      color=#ff3434>sql-statement</FONT></I> ::=</TD>
 | 
						||
    <TD><B><FONT color=#2c2cf0>COMMIT </FONT></B>[<B><FONT 
 | 
						||
      color=#2c2cf0>TRANSACTION </FONT></B>[<B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B><I><FONT color=#ff3434>name</FONT></I><B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B>]<B><FONT color=#2c2cf0></FONT></B>]<B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B></TD></TR></TBODY></TABLE>
 | 
						||
<TABLE cellPadding=10>
 | 
						||
  <TBODY>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right><I><FONT 
 | 
						||
      color=#ff3434>sql-statement</FONT></I> ::=</TD>
 | 
						||
    <TD><B><FONT color=#2c2cf0>ROLLBACK </FONT></B>[<B><FONT 
 | 
						||
      color=#2c2cf0>TRANSACTION </FONT></B>[<B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B><I><FONT color=#ff3434>name</FONT></I><B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B>]<B><FONT color=#2c2cf0></FONT></B>]<B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B></TD></TR></TBODY></TABLE>
 | 
						||
<P>Beginning in version 2.0, SQLite supports transactions with 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 start a transaction if one is not already in effect. 
 | 
						||
Automatically started transactions are committed at the conclusion of the 
 | 
						||
command. </P>
 | 
						||
<P>Transactions can be started manually using the BEGIN command. Such 
 | 
						||
transactions usually persist until the next COMMIT or ROLLBACK command. But a 
 | 
						||
transaction will also ROLLBACK if the database is closed or if an error occurs 
 | 
						||
and the ROLLBACK conflict resolution algorithm is specified. See the documention 
 | 
						||
on the <A href="#conflict">ON 
 | 
						||
CONFLICT</A> clause for additional information about the ROLLBACK conflict 
 | 
						||
resolution algorithm. </P>
 | 
						||
<P>The optional ON CONFLICT clause at the end of a BEGIN statement can be used 
 | 
						||
to changed the default conflict resolution algorithm. The normal default is 
 | 
						||
ABORT. If an alternative is specified by the ON CONFLICT clause of a BEGIN, then 
 | 
						||
that alternative is used as the default for all commands within the transaction. 
 | 
						||
The default algorithm is overridden by ON CONFLICT clauses on individual 
 | 
						||
constraints within the CREATE TABLE or CREATE INDEX statements and by the OR 
 | 
						||
clauses on COPY, INSERT, and UPDATE commands. </P>
 | 
						||
<HR>
 | 
						||
<A name=comment></A>
 | 
						||
<H1>comment</H1>
 | 
						||
<TABLE cellPadding=10>
 | 
						||
  <TBODY>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right><I><FONT 
 | 
						||
      color=#ff3434>comment</FONT></I> ::=</TD>
 | 
						||
    <TD><B><FONT color=#2c2cf0></FONT></B><I><FONT 
 | 
						||
      color=#ff3434>SQL-comment</FONT></I><B><FONT color=#2c2cf0> 
 | 
						||
      </FONT></B><BIG>|</BIG><B><FONT color=#2c2cf0> </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>C-comment</FONT></I><B><FONT color=#2c2cf0></FONT></B></TD></TR>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right><I><FONT 
 | 
						||
      color=#ff3434>SQL-comment</FONT></I> ::=</TD>
 | 
						||
    <TD><B><FONT color=#2c2cf0>-- </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>single-line</FONT></I><B><FONT 
 | 
						||
  color=#2c2cf0></FONT></B></TD></TR>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right><I><FONT 
 | 
						||
      color=#ff3434>C-comment</FONT></I> ::=</TD>
 | 
						||
    <TD><B><FONT color=#2c2cf0>/<BIG>*</BIG> </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>multiple-lines</FONT></I><B><FONT color=#2c2cf0> 
 | 
						||
      </FONT></B>[<B><FONT color=#2c2cf0><BIG>*</BIG>/</FONT></B>]<B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B></TD></TR></TBODY></TABLE>
 | 
						||
<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 can be found, 
 | 
						||
including inside expressions that span multiple lines. </P>
 | 
						||
<P>SQL comments only extend to the end of the current line.</P>
 | 
						||
<P>C comments can span any number of lines. If there is no terminating 
 | 
						||
delimiter, they extend to the end of the input. This is not treated as an error. 
 | 
						||
A new SQL statement can begin on a line after a multiline comment ends. C 
 | 
						||
comments can be embedded anywhere whitespace can occur, including inside 
 | 
						||
expressions, and in the middle of other SQL statements. C comments do not nest. 
 | 
						||
SQL comments inside a C comment will be ignored. </P>
 | 
						||
<HR>
 | 
						||
<A name=copy></A>
 | 
						||
<H1>COPY</H1>
 | 
						||
<TABLE cellPadding=10>
 | 
						||
  <TBODY>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right><I><FONT 
 | 
						||
      color=#ff3434>sql-statement</FONT></I> ::=</TD>
 | 
						||
    <TD><B><FONT color=#2c2cf0>COPY </FONT></B>[<B><FONT color=#2c2cf0> OR 
 | 
						||
      </FONT></B><I><FONT color=#ff3434>conflict-algorithm</FONT></I><B><FONT 
 | 
						||
      color=#2c2cf0> </FONT></B>]<B><FONT color=#2c2cf0> </FONT></B>[<B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B><I><FONT 
 | 
						||
      color=#ff3434>database-name</FONT></I><B><FONT color=#2c2cf0> 
 | 
						||
      <BIG>.</BIG></FONT></B>]<B><FONT color=#2c2cf0> </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>table-name</FONT></I><B><FONT color=#2c2cf0> FROM 
 | 
						||
      </FONT></B><I><FONT color=#ff3434>filename</FONT></I><B><FONT 
 | 
						||
      color=#2c2cf0><BR></FONT></B>[<B><FONT color=#2c2cf0> USING DELIMITERS 
 | 
						||
      </FONT></B><I><FONT color=#ff3434>delim</FONT></I><B><FONT color=#2c2cf0> 
 | 
						||
      </FONT></B>]<B><FONT color=#2c2cf0></FONT></B></TD></TR></TBODY></TABLE>
 | 
						||
<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 in PostgreSQL. In fact, the 
 | 
						||
SQLite COPY command is specifically designed to be able to read the output of 
 | 
						||
the PostgreSQL dump utility <B>pg_dump</B> so that data can be easily 
 | 
						||
transferred from PostgreSQL into SQLite.</P>
 | 
						||
<P>The table-name is the name of an existing table which is to be filled with 
 | 
						||
data. The filename is a string or identifier that names a file from which data 
 | 
						||
will be read. The filename can be the <B>STDIN</B> to read data from standard 
 | 
						||
input.</P>
 | 
						||
<P>Each line of the input file is converted into a single record in the table. 
 | 
						||
Columns are separated by tabs. If a tab occurs as data within a column, then 
 | 
						||
that tab is preceded by a baskslash "\" character. A baskslash in the data 
 | 
						||
appears as two backslashes in a row. The optional USING DELIMITERS clause can 
 | 
						||
specify a delimiter other than tab.</P>
 | 
						||
<P>If a column consists of the character "\N", that column is filled with the 
 | 
						||
value NULL.</P>
 | 
						||
<P>The optional conflict-clause allows the specification of an alternative 
 | 
						||
constraint conflict resolution algorithm to use for this one command. See the 
 | 
						||
section titled <A href="#conflict">ON 
 | 
						||
CONFLICT</A> for additional information.</P>
 | 
						||
<P>When the input data source is STDIN, the input can be terminated by a line 
 | 
						||
that contains only a baskslash and a dot: "<FONT 
 | 
						||
color=#2c2cf0><BIG>\.</BIG></FONT>".</P>
 | 
						||
<HR>
 | 
						||
<A name=createindex></A>
 | 
						||
<H1>CREATE INDEX</H1>
 | 
						||
<TABLE cellPadding=10>
 | 
						||
  <TBODY>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right><I><FONT 
 | 
						||
      color=#ff3434>sql-statement</FONT></I> ::=</TD>
 | 
						||
    <TD><B><FONT color=#2c2cf0>CREATE </FONT></B>[<B><FONT 
 | 
						||
      color=#2c2cf0>UNIQUE</FONT></B>]<B><FONT color=#2c2cf0> INDEX 
 | 
						||
      </FONT></B><I><FONT color=#ff3434>index-name</FONT></I><B><FONT 
 | 
						||
      color=#2c2cf0> <BR>ON </FONT></B>[<B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B><I><FONT 
 | 
						||
      color=#ff3434>database-name</FONT></I><B><FONT color=#2c2cf0> 
 | 
						||
      <BIG>.</BIG></FONT></B>]<B><FONT color=#2c2cf0> </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>table-name</FONT></I><B><FONT color=#2c2cf0> <BIG>(</BIG> 
 | 
						||
      </FONT></B><I><FONT color=#ff3434>column-name</FONT></I><B><FONT 
 | 
						||
      color=#2c2cf0> </FONT></B>[<B><FONT color=#2c2cf0><BIG>,</BIG> 
 | 
						||
      </FONT></B><I><FONT color=#ff3434>column-name</FONT></I><B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B>]<B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B><BIG>*</BIG><B><FONT color=#2c2cf0> 
 | 
						||
      <BIG>)</BIG><BR></FONT></B>[<B><FONT color=#2c2cf0> ON CONFLICT 
 | 
						||
      </FONT></B><I><FONT color=#ff3434>conflict-algorithm</FONT></I><B><FONT 
 | 
						||
      color=#2c2cf0> </FONT></B>]<B><FONT color=#2c2cf0></FONT></B></TD></TR>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right><I><FONT 
 | 
						||
      color=#ff3434>column-name</FONT></I> ::=</TD>
 | 
						||
    <TD><B><FONT color=#2c2cf0></FONT></B><I><FONT 
 | 
						||
      color=#ff3434>name</FONT></I><B><FONT color=#2c2cf0> </FONT></B>[<B><FONT 
 | 
						||
      color=#2c2cf0> ASC </FONT></B><BIG>|</BIG><B><FONT color=#2c2cf0> DESC 
 | 
						||
      </FONT></B>]<B><FONT color=#2c2cf0></FONT></B></TD></TR></TBODY></TABLE>
 | 
						||
<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 created 
 | 
						||
table that is to be indexed, and a parenthesized list of names of columns in the 
 | 
						||
table that are used for the index key. Each column name can be followed by one 
 | 
						||
of the "ASC" or "DESC" keywords to indicate sort order, but the sort order is 
 | 
						||
ignored in the current implementation. Sorting is always done in ascending 
 | 
						||
order.</P>
 | 
						||
<P>There are no arbitrary limits on the number of indices that can be attached 
 | 
						||
to a single table, nor on the number of columns in an index.</P>
 | 
						||
<P>If the UNIQUE keyword appears between CREATE and INDEX then duplicate index 
 | 
						||
entries are not allowed. Any attempt to insert a duplicate entry will result in 
 | 
						||
an error.</P>
 | 
						||
<P>The optional conflict-clause allows the specification of an alternative 
 | 
						||
default constraint conflict resolution algorithm for this index. This only makes 
 | 
						||
sense if the UNIQUE keyword is used since otherwise there are not constraints on 
 | 
						||
the index. The default algorithm is ABORT. If a COPY, INSERT, or UPDATE 
 | 
						||
statement specifies a particular conflict resolution algorithm, that algorithm 
 | 
						||
is used in place of the default algorithm specified here. See the section titled 
 | 
						||
<A href="#conflict">ON CONFLICT</A> for 
 | 
						||
additional information.</P>
 | 
						||
<P>The exact text of each CREATE INDEX statement is stored in the 
 | 
						||
<B>sqlite_master</B> or <B>sqlite_temp_master</B> table, depending on whether 
 | 
						||
the table 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>Indexes cannot be added on tables in attached databases. Indexes are removed 
 | 
						||
with the <A href="#dropindex">DROP 
 | 
						||
INDEX</A> command.</P>
 | 
						||
<HR>
 | 
						||
<A name=createtable></A>
 | 
						||
<H1>CREATE TABLE</H1>
 | 
						||
<TABLE cellPadding=10>
 | 
						||
  <TBODY>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right><I><FONT 
 | 
						||
      color=#ff3434>sql-command</FONT></I> ::=</TD>
 | 
						||
    <TD><B><FONT color=#2c2cf0>CREATE </FONT></B>[<B><FONT color=#2c2cf0>TEMP 
 | 
						||
      </FONT></B><BIG>|</BIG><B><FONT color=#2c2cf0> 
 | 
						||
      TEMPORARY</FONT></B>]<B><FONT color=#2c2cf0> TABLE </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>table-name</FONT></I><B><FONT color=#2c2cf0> 
 | 
						||
      <BIG>(</BIG><BR>    </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>column-def</FONT></I><B><FONT color=#2c2cf0> 
 | 
						||
      </FONT></B>[<B><FONT color=#2c2cf0><BIG>,</BIG> </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>column-def</FONT></I><B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B>]<B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B><BIG>*</BIG><B><FONT 
 | 
						||
      color=#2c2cf0><BR>    </FONT></B>[<B><FONT 
 | 
						||
      color=#2c2cf0><BIG>,</BIG> </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>constraint</FONT></I><B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B>]<B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B><BIG>*</BIG><B><FONT 
 | 
						||
      color=#2c2cf0><BR><BIG>)</BIG></FONT></B></TD></TR>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right><I><FONT 
 | 
						||
      color=#ff3434>sql-command</FONT></I> ::=</TD>
 | 
						||
    <TD><B><FONT color=#2c2cf0>CREATE </FONT></B>[<B><FONT color=#2c2cf0>TEMP 
 | 
						||
      </FONT></B><BIG>|</BIG><B><FONT color=#2c2cf0> 
 | 
						||
      TEMPORARY</FONT></B>]<B><FONT color=#2c2cf0> TABLE </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>table-name</FONT></I><B><FONT color=#2c2cf0> AS 
 | 
						||
      </FONT></B><I><FONT color=#ff3434>select-statement</FONT></I><B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B></TD></TR>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right><I><FONT 
 | 
						||
      color=#ff3434>column-def</FONT></I> ::=</TD>
 | 
						||
    <TD><B><FONT color=#2c2cf0></FONT></B><I><FONT 
 | 
						||
      color=#ff3434>name</FONT></I><B><FONT color=#2c2cf0> </FONT></B>[<B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B><I><FONT color=#ff3434>type</FONT></I><B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B>]<B><FONT color=#2c2cf0> </FONT></B>[<B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B>[<B><FONT color=#2c2cf0>CONSTRAINT 
 | 
						||
      </FONT></B><I><FONT color=#ff3434>name</FONT></I><B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B>]<B><FONT color=#2c2cf0> </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>column-constraint</FONT></I><B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B>]<B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B><BIG>*</BIG><B><FONT 
 | 
						||
  color=#2c2cf0></FONT></B></TD></TR>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right><I><FONT 
 | 
						||
    color=#ff3434>type</FONT></I> ::=</TD>
 | 
						||
    <TD><B><FONT color=#2c2cf0></FONT></B><I><FONT 
 | 
						||
      color=#ff3434>typename</FONT></I><B><FONT color=#2c2cf0> 
 | 
						||
      </FONT></B><BIG>|</BIG><B><FONT color=#2c2cf0><BR></FONT></B><I><FONT 
 | 
						||
      color=#ff3434>typename</FONT></I><B><FONT color=#2c2cf0> <BIG>(</BIG> 
 | 
						||
      </FONT></B><I><FONT color=#ff3434>number</FONT></I><B><FONT color=#2c2cf0> 
 | 
						||
      <BIG>)</BIG> </FONT></B><BIG>|</BIG><B><FONT 
 | 
						||
      color=#2c2cf0><BR></FONT></B><I><FONT 
 | 
						||
      color=#ff3434>typename</FONT></I><B><FONT color=#2c2cf0> <BIG>(</BIG> 
 | 
						||
      </FONT></B><I><FONT color=#ff3434>number</FONT></I><B><FONT color=#2c2cf0> 
 | 
						||
      <BIG>,</BIG> </FONT></B><I><FONT color=#ff3434>number</FONT></I><B><FONT 
 | 
						||
      color=#2c2cf0> <BIG>)</BIG></FONT></B></TD></TR>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right><I><FONT 
 | 
						||
      color=#ff3434>column-constraint</FONT></I> ::=</TD>
 | 
						||
    <TD><B><FONT color=#2c2cf0>NOT NULL </FONT></B>[<B><FONT color=#2c2cf0> 
 | 
						||
      </FONT></B><I><FONT color=#ff3434>conflict-clause</FONT></I><B><FONT 
 | 
						||
      color=#2c2cf0> </FONT></B>]<B><FONT color=#2c2cf0> 
 | 
						||
      </FONT></B><BIG>|</BIG><B><FONT color=#2c2cf0><BR>PRIMARY KEY 
 | 
						||
      </FONT></B>[<B><FONT color=#2c2cf0></FONT></B><I><FONT 
 | 
						||
      color=#ff3434>sort-order</FONT></I><B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B>]<B><FONT color=#2c2cf0> </FONT></B>[<B><FONT 
 | 
						||
      color=#2c2cf0> </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>conflict-clause</FONT></I><B><FONT color=#2c2cf0> 
 | 
						||
      </FONT></B>]<B><FONT color=#2c2cf0> </FONT></B><BIG>|</BIG><B><FONT 
 | 
						||
      color=#2c2cf0><BR>UNIQUE </FONT></B>[<B><FONT color=#2c2cf0> 
 | 
						||
      </FONT></B><I><FONT color=#ff3434>conflict-clause</FONT></I><B><FONT 
 | 
						||
      color=#2c2cf0> </FONT></B>]<B><FONT color=#2c2cf0> 
 | 
						||
      </FONT></B><BIG>|</BIG><B><FONT color=#2c2cf0><BR>CHECK <BIG>(</BIG> 
 | 
						||
      </FONT></B><I><FONT color=#ff3434>expr</FONT></I><B><FONT color=#2c2cf0> 
 | 
						||
      <BIG>)</BIG> </FONT></B>[<B><FONT color=#2c2cf0> </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>conflict-clause</FONT></I><B><FONT color=#2c2cf0> 
 | 
						||
      </FONT></B>]<B><FONT color=#2c2cf0> </FONT></B><BIG>|</BIG><B><FONT 
 | 
						||
      color=#2c2cf0><BR>DEFAULT </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>value</FONT></I><B><FONT color=#2c2cf0></FONT></B></TD></TR>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right><I><FONT 
 | 
						||
      color=#ff3434>constraint</FONT></I> ::=</TD>
 | 
						||
    <TD><B><FONT color=#2c2cf0>PRIMARY KEY <BIG>(</BIG> </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>column-list</FONT></I><B><FONT color=#2c2cf0> <BIG>)</BIG> 
 | 
						||
      </FONT></B>[<B><FONT color=#2c2cf0> </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>conflict-clause</FONT></I><B><FONT color=#2c2cf0> 
 | 
						||
      </FONT></B>]<B><FONT color=#2c2cf0> </FONT></B><BIG>|</BIG><B><FONT 
 | 
						||
      color=#2c2cf0><BR>UNIQUE <BIG>(</BIG> </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>column-list</FONT></I><B><FONT color=#2c2cf0> <BIG>)</BIG> 
 | 
						||
      </FONT></B>[<B><FONT color=#2c2cf0> </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>conflict-clause</FONT></I><B><FONT color=#2c2cf0> 
 | 
						||
      </FONT></B>]<B><FONT color=#2c2cf0> </FONT></B><BIG>|</BIG><B><FONT 
 | 
						||
      color=#2c2cf0><BR>CHECK <BIG>(</BIG> </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>expr</FONT></I><B><FONT color=#2c2cf0> <BIG>)</BIG> 
 | 
						||
      </FONT></B>[<B><FONT color=#2c2cf0> </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>conflict-clause</FONT></I><B><FONT color=#2c2cf0> 
 | 
						||
      </FONT></B>]<B><FONT color=#2c2cf0></FONT></B></TD></TR>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right><I><FONT 
 | 
						||
      color=#ff3434>conflict-clause</FONT></I> ::=</TD>
 | 
						||
    <TD><B><FONT color=#2c2cf0>ON CONFLICT </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>conflict-algorithm</FONT></I><B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B></TD></TR></TBODY></TABLE>
 | 
						||
<P>A CREATE TABLE statement is basically the keywords "CREATE TABLE" followed by 
 | 
						||
the name of a new table and a parenthesized list of column definitions and 
 | 
						||
constraints. The table name can be either an identifier or a string. Tables 
 | 
						||
names that begin with "<B>sqlite_</B>" are reserved for use by the engine.</P>
 | 
						||
<P>Each column definition is the name of the column followed by the datatype for 
 | 
						||
that column, then one or more optional column constraints. SQLite is <A 
 | 
						||
href="http://www.hwaci.com/sw/sqlite/datatypes.html">typeless</A>. The datatype 
 | 
						||
for the column does not restrict what data may be put in that column. All 
 | 
						||
information is stored as null-terminated strings. The UNIQUE constraint causes 
 | 
						||
an index to be created on the specified columns. This index must contain unique 
 | 
						||
keys. The DEFAULT constraint specifies a default value to use when doing an 
 | 
						||
INSERT. </P>
 | 
						||
<P>Specifying a PRIMARY KEY normally just creates a UNIQUE index on the primary 
 | 
						||
key. However, if primary key is on a single column that has datatype INTEGER, 
 | 
						||
then that column is used internally as the actual key of the B-Tree for the 
 | 
						||
table. This means that the column may only hold unique integer values. (Except 
 | 
						||
for this one case, SQLite ignores the datatype specification of columns and 
 | 
						||
allows any kind of data to be put in a column regardless of its declared 
 | 
						||
datatype.) If a table does not have an INTEGER PRIMARY KEY column, then the 
 | 
						||
B-Tree key will be a automatically generated integer. The B-Tree key for a row 
 | 
						||
can always be accessed using one of the special names "<B>ROWID</B>", 
 | 
						||
"<B>OID</B>", or "<B>_ROWID_</B>". This is true regardless of whether or not 
 | 
						||
there is an INTEGER PRIMARY KEY.</P>
 | 
						||
<P>If the "TEMP" or "TEMPORARY" keyword occurs in between "CREATE" and "TABLE" 
 | 
						||
then the table that is created is only visible to the process that opened the 
 | 
						||
database and is automatically deleted when the database is closed. Any indices 
 | 
						||
created on a temporary table are also temporary. Temporary tables and indices 
 | 
						||
are stored in a separate file distinct from the main database file.</P>
 | 
						||
<P>The optional conflict-clause following each constraint allows the 
 | 
						||
specification of an alternative default constraint conflict resolution algorithm 
 | 
						||
for that constraint. The default is abort ABORT. Different constraints within 
 | 
						||
the same table may have different default conflict resolution algorithms. If an 
 | 
						||
COPY, INSERT, or UPDATE command specifies a different conflict resolution 
 | 
						||
algorithm, then that algorithm is used in place of the default algorithm 
 | 
						||
specified in the CREATE TABLE statement. See the section titled <A 
 | 
						||
href="#conflict">ON CONFLICT</A> for 
 | 
						||
additional information.</P>
 | 
						||
<P>CHECK constraints are ignored in the current implementation. Support for 
 | 
						||
CHECK constraints may be added in the future. As of version 2.3.0, NOT NULL, 
 | 
						||
PRIMARY KEY, and UNIQUE constraints all work.</P>
 | 
						||
<P>There are no arbitrary limits on the number of columns or on the number of 
 | 
						||
constraints in a table. The total amount of data in a single row is limited to 
 | 
						||
about 1 megabytes. (This limit can be increased to 16MB by changing a single 
 | 
						||
#define in the source code and recompiling.)</P>
 | 
						||
<P>The CREATE TABLE AS form defines the table to be the result set of a query. 
 | 
						||
The names of the table columns are the names of the columns in the result.</P>
 | 
						||
<P>The exact text of each CREATE TABLE statement is stored in the 
 | 
						||
<B>sqlite_master</B> table. Everytime the database is opened, all CREATE TABLE 
 | 
						||
statements are read from the <B>sqlite_master</B> table and used to regenerate 
 | 
						||
SQLite's internal representation of the table layout. If the original command 
 | 
						||
was a CREATE TABLE AS then then an equivalent CREATE TABLE statement is 
 | 
						||
synthesized and store in <B>sqlite_master</B> 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>
 | 
						||
<HR>
 | 
						||
<A name=createtrigger></A>
 | 
						||
<H1>CREATE TRIGGER</H1>
 | 
						||
<TABLE cellPadding=10>
 | 
						||
  <TBODY>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right><I><FONT 
 | 
						||
      color=#ff3434>sql-statement</FONT></I> ::=</TD>
 | 
						||
    <TD><B><FONT color=#2c2cf0>CREATE </FONT></B>[<B><FONT color=#2c2cf0>TEMP 
 | 
						||
      </FONT></B><BIG>|</BIG><B><FONT color=#2c2cf0> 
 | 
						||
      TEMPORARY</FONT></B>]<B><FONT color=#2c2cf0> TRIGGER </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>trigger-name</FONT></I><B><FONT color=#2c2cf0> 
 | 
						||
      </FONT></B>[<B><FONT color=#2c2cf0> BEFORE </FONT></B><BIG>|</BIG><B><FONT 
 | 
						||
      color=#2c2cf0> AFTER </FONT></B>]<B><FONT 
 | 
						||
      color=#2c2cf0><BR></FONT></B><I><FONT 
 | 
						||
      color=#ff3434>database-event</FONT></I><B><FONT color=#2c2cf0> ON 
 | 
						||
      </FONT></B>[<B><FONT color=#2c2cf0></FONT></B><I><FONT 
 | 
						||
      color=#ff3434>database-name</FONT></I><B><FONT color=#2c2cf0> 
 | 
						||
      <BIG>.</BIG></FONT></B>]<B><FONT color=#2c2cf0> </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>table-name</FONT></I><B><FONT 
 | 
						||
      color=#2c2cf0><BR></FONT></B><I><FONT 
 | 
						||
      color=#ff3434>trigger-action</FONT></I><B><FONT 
 | 
						||
    color=#2c2cf0></FONT></B></TD></TR></TBODY></TABLE>
 | 
						||
<TABLE cellPadding=10>
 | 
						||
  <TBODY>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right><I><FONT 
 | 
						||
      color=#ff3434>sql-statement</FONT></I> ::=</TD>
 | 
						||
    <TD><B><FONT color=#2c2cf0>CREATE </FONT></B>[<B><FONT color=#2c2cf0>TEMP 
 | 
						||
      </FONT></B><BIG>|</BIG><B><FONT color=#2c2cf0> 
 | 
						||
      TEMPORARY</FONT></B>]<B><FONT color=#2c2cf0> TRIGGER </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>trigger-name</FONT></I><B><FONT color=#2c2cf0> INSTEAD 
 | 
						||
      OF<BR></FONT></B><I><FONT color=#ff3434>database-event</FONT></I><B><FONT 
 | 
						||
      color=#2c2cf0> ON </FONT></B>[<B><FONT color=#2c2cf0></FONT></B><I><FONT 
 | 
						||
      color=#ff3434>database-name</FONT></I><B><FONT color=#2c2cf0> 
 | 
						||
      <BIG>.</BIG></FONT></B>]<B><FONT color=#2c2cf0> </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>view-name</FONT></I><B><FONT 
 | 
						||
      color=#2c2cf0><BR></FONT></B><I><FONT 
 | 
						||
      color=#ff3434>trigger-action</FONT></I><B><FONT 
 | 
						||
    color=#2c2cf0></FONT></B></TD></TR></TBODY></TABLE>
 | 
						||
<TABLE cellPadding=10>
 | 
						||
  <TBODY>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right><I><FONT 
 | 
						||
      color=#ff3434>database-event</FONT></I> ::=</TD>
 | 
						||
    <TD><B><FONT color=#2c2cf0>DELETE </FONT></B><BIG>|</BIG><B><FONT 
 | 
						||
      color=#2c2cf0> <BR>INSERT </FONT></B><BIG>|</BIG><B><FONT color=#2c2cf0> 
 | 
						||
      <BR>UPDATE </FONT></B><BIG>|</BIG><B><FONT color=#2c2cf0> <BR>UPDATE OF 
 | 
						||
      </FONT></B><I><FONT color=#ff3434>column-list</FONT></I><B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B></TD></TR></TBODY></TABLE>
 | 
						||
<TABLE cellPadding=10>
 | 
						||
  <TBODY>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right><I><FONT 
 | 
						||
      color=#ff3434>trigger-action</FONT></I> ::=</TD>
 | 
						||
    <TD><B><FONT color=#2c2cf0></FONT></B>[<B><FONT color=#2c2cf0> FOR EACH 
 | 
						||
      ROW </FONT></B><BIG>|</BIG><B><FONT color=#2c2cf0> FOR EACH STATEMENT 
 | 
						||
      </FONT></B>]<B><FONT color=#2c2cf0> </FONT></B>[<B><FONT color=#2c2cf0> 
 | 
						||
      WHEN </FONT></B><I><FONT color=#ff3434>expression</FONT></I><B><FONT 
 | 
						||
      color=#2c2cf0> </FONT></B>]<B><FONT color=#2c2cf0> <BR>BEGIN 
 | 
						||
      <BR>    </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>trigger-step</FONT></I><B><FONT color=#2c2cf0> ; 
 | 
						||
      </FONT></B>[<B><FONT color=#2c2cf0> </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>trigger-step</FONT></I><B><FONT color=#2c2cf0> ; 
 | 
						||
      </FONT></B>]<B><FONT color=#2c2cf0></FONT></B><BIG>*</BIG><B><FONT 
 | 
						||
      color=#2c2cf0><BR>END</FONT></B></TD></TR></TBODY></TABLE>
 | 
						||
<TABLE cellPadding=10>
 | 
						||
  <TBODY>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right><I><FONT 
 | 
						||
      color=#ff3434>trigger-step</FONT></I> ::=</TD>
 | 
						||
    <TD><B><FONT color=#2c2cf0></FONT></B><I><FONT 
 | 
						||
      color=#ff3434>update-statement</FONT></I><B><FONT color=#2c2cf0> 
 | 
						||
      </FONT></B><BIG>|</BIG><B><FONT color=#2c2cf0> </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>insert-statement</FONT></I><B><FONT color=#2c2cf0> 
 | 
						||
      </FONT></B><BIG>|</BIG><B><FONT color=#2c2cf0> <BR></FONT></B><I><FONT 
 | 
						||
      color=#ff3434>delete-statement</FONT></I><B><FONT color=#2c2cf0> 
 | 
						||
      </FONT></B><BIG>|</BIG><B><FONT color=#2c2cf0> </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>select-statement</FONT></I><B><FONT 
 | 
						||
    color=#2c2cf0></FONT></B></TD></TR></TBODY></TABLE>
 | 
						||
<P>The CREATE TRIGGER statement is used to add triggers to the database schema. 
 | 
						||
Triggers are database operations (the <I>trigger-action</I>) that are 
 | 
						||
automatically performed when a specified database event (the 
 | 
						||
<I>database-event</I>) occurs. </P>
 | 
						||
<P>A trigger may be specified to fire whenever a DELETE, INSERT or UPDATE of a 
 | 
						||
particular database table occurs, or whenever an UPDATE of one or more specified 
 | 
						||
columns of a table are updated.</P>
 | 
						||
<P>At this time SQLite supports only FOR EACH ROW triggers, not FOR EACH 
 | 
						||
STATEMENT triggers. Hence explicitly specifying FOR EACH ROW is optional. FOR 
 | 
						||
EACH ROW implies that the SQL statements specified as <I>trigger-steps</I> may 
 | 
						||
be executed (depending on the WHEN clause) for each database row being inserted, 
 | 
						||
updated or deleted by the statement causing the trigger to fire.</P>
 | 
						||
<P>Both the WHEN clause and the <I>trigger-steps</I> may access elements of the 
 | 
						||
row being inserted, deleted or updated using references of the form 
 | 
						||
"NEW.<I>column-name</I>" and "OLD.<I>column-name</I>", where <I>column-name</I> 
 | 
						||
is the name of a column from the table that the trigger is associated with. OLD 
 | 
						||
and NEW references may only be used in triggers on <I>trigger-event</I>s for 
 | 
						||
which they are relevant, as follows:</P>
 | 
						||
<TABLE cellPadding=10 border=0>
 | 
						||
  <TBODY>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right width=120><I>INSERT</I></TD>
 | 
						||
    <TD vAlign=top>NEW references are valid</TD></TR>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right width=120><I>UPDATE</I></TD>
 | 
						||
    <TD vAlign=top>NEW and OLD references are valid</TD></TR>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right width=120><I>DELETE</I></TD>
 | 
						||
    <TD vAlign=top>OLD references are valid</TD></TR></TBODY></TABLE>
 | 
						||
<P></P>
 | 
						||
<P>If a WHEN clause is supplied, the SQL statements specified as 
 | 
						||
<I>trigger-steps</I> are only executed for rows for which the WHEN clause is 
 | 
						||
true. If no WHEN clause is supplied, the SQL statements are executed for all 
 | 
						||
rows.</P>
 | 
						||
<P>The specified <I>trigger-time</I> determines when the <I>trigger-steps</I> 
 | 
						||
will be executed relative to the insertion, modification or removal of the 
 | 
						||
associated row.</P>
 | 
						||
<P>An ON CONFLICT clause may be specified as part of an UPDATE or INSERT 
 | 
						||
<I>trigger-step</I>. However if an ON CONFLICT clause is specified as part of 
 | 
						||
the statement causing the trigger to fire, then this conflict handling policy is 
 | 
						||
used instead.</P>
 | 
						||
<P>Triggers are automatically dropped when the table that they are associated 
 | 
						||
with is dropped.</P>
 | 
						||
<P>Triggers may be created on views, as well as ordinary tables, by specifying 
 | 
						||
INSTEAD OF in the CREATE TRIGGER statement. If one or more ON INSERT, ON DELETE 
 | 
						||
or ON UPDATE triggers are defined on a view, then it is not an error to execute 
 | 
						||
an INSERT, DELETE or UPDATE statement on the view, respectively. Thereafter, 
 | 
						||
executing an INSERT, DELETE or UPDATE on the view causes the associated triggers 
 | 
						||
to fire. The real tables underlying the view are not modified (except possibly 
 | 
						||
explicitly, by a trigger program).</P>
 | 
						||
<P><B>Example:</B></P>
 | 
						||
<P>Assuming that customer records are stored in the "customers" table, and that 
 | 
						||
order records are stored in the "orders" table, the following trigger ensures 
 | 
						||
that all associated orders are redirected when a customer changes his or her 
 | 
						||
address:</P>
 | 
						||
<BLOCKQUOTE><PRE>CREATE TRIGGER update_customer_address UPDATE OF address ON customers 
 | 
						||
  BEGIN
 | 
						||
    UPDATE orders SET address = new.address WHERE customer_name = old.name;
 | 
						||
  END;
 | 
						||
</PRE></BLOCKQUOTE>
 | 
						||
<P>With this trigger installed, executing the statement:</P>
 | 
						||
<BLOCKQUOTE><PRE>UPDATE customers SET address = '1 Main St.' WHERE name = 'Jack Jones';
 | 
						||
</PRE></BLOCKQUOTE>
 | 
						||
<P>causes the following to be automatically executed:</P>
 | 
						||
<BLOCKQUOTE><PRE>UPDATE orders SET address = '1 Main St.' WHERE customer_name = 'Jack Jones';
 | 
						||
</PRE></BLOCKQUOTE>
 | 
						||
<P>Note that currently, triggers may behave oddly when created on tables with 
 | 
						||
INTEGER PRIMARY KEY fields. If a BEFORE trigger program modifies the INTEGER 
 | 
						||
PRIMARY KEY field of a row that will be subsequently updated by the statement 
 | 
						||
that causes the trigger to fire, then the update may not occur. The workaround 
 | 
						||
is to declare the table with a PRIMARY KEY column instead of an INTEGER PRIMARY 
 | 
						||
KEY column.</P>
 | 
						||
<P>A special SQL function RAISE() may be used within a trigger-program, with the 
 | 
						||
following syntax</P>
 | 
						||
<TABLE cellPadding=10>
 | 
						||
  <TBODY>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right><I><FONT 
 | 
						||
      color=#ff3434>raise-function</FONT></I> ::=</TD>
 | 
						||
    <TD><B><FONT color=#2c2cf0>RAISE <BIG>(</BIG> ABORT<BIG>,</BIG> 
 | 
						||
      </FONT></B><I><FONT color=#ff3434>error-message</FONT></I><B><FONT 
 | 
						||
      color=#2c2cf0> <BIG>)</BIG> </FONT></B><BIG>|</BIG><B><FONT color=#2c2cf0> 
 | 
						||
      <BR>RAISE <BIG>(</BIG> FAIL<BIG>,</BIG> </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>error-message</FONT></I><B><FONT color=#2c2cf0> <BIG>)</BIG> 
 | 
						||
      </FONT></B><BIG>|</BIG><B><FONT color=#2c2cf0> <BR>RAISE <BIG>(</BIG> 
 | 
						||
      ROLLBACK<BIG>,</BIG> </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>error-message</FONT></I><B><FONT color=#2c2cf0> <BIG>)</BIG> 
 | 
						||
      </FONT></B><BIG>|</BIG><B><FONT color=#2c2cf0> <BR>RAISE <BIG>(</BIG> 
 | 
						||
      IGNORE <BIG>)</BIG></FONT></B></TD></TR></TBODY></TABLE>
 | 
						||
<P>When one of the first three forms is called during trigger-program execution, 
 | 
						||
the specified ON CONFLICT processing is performed (either ABORT, FAIL or 
 | 
						||
ROLLBACK) and the current query terminates. An error code of SQLITE_CONSTRAINT 
 | 
						||
is returned to the user, along with the specified error message.</P>
 | 
						||
<P>When RAISE(IGNORE) is called, the remainder of the current trigger program, 
 | 
						||
the statement that caused the trigger program to execute and any subsequent 
 | 
						||
trigger programs that would of been executed are abandoned. No database changes 
 | 
						||
are rolled back. If the statement that caused the trigger program 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>
 | 
						||
<HR>
 | 
						||
<A name=createview></A>
 | 
						||
<H1>CREATE VIEW</H1>
 | 
						||
<TABLE cellPadding=10>
 | 
						||
  <TBODY>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right><I><FONT 
 | 
						||
      color=#ff3434>sql-command</FONT></I> ::=</TD>
 | 
						||
    <TD><B><FONT color=#2c2cf0>CREATE </FONT></B>[<B><FONT color=#2c2cf0>TEMP 
 | 
						||
      </FONT></B><BIG>|</BIG><B><FONT color=#2c2cf0> 
 | 
						||
      TEMPORARY</FONT></B>]<B><FONT color=#2c2cf0> VIEW </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>view-name</FONT></I><B><FONT color=#2c2cf0> AS 
 | 
						||
      </FONT></B><I><FONT color=#ff3434>select-statement</FONT></I><B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B></TD></TR></TBODY></TABLE>
 | 
						||
<P>The CREATE VIEW command assigns a name to a pre-packaged <A 
 | 
						||
href="#select">SELECT</A> 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, DELETE, INSERT or UPDATE a view. Views are read-only in 
 | 
						||
SQLite. However, in many cases you can use a <A 
 | 
						||
href="#trigger">TRIGGER</A> on the view 
 | 
						||
to accomplish the same thing. 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>
 | 
						||
<HR>
 | 
						||
<A name=delete></A>
 | 
						||
<H1>DELETE</H1>
 | 
						||
<TABLE cellPadding=10>
 | 
						||
  <TBODY>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right><I><FONT 
 | 
						||
      color=#ff3434>sql-statement</FONT></I> ::=</TD>
 | 
						||
    <TD><B><FONT color=#2c2cf0>DELETE FROM </FONT></B>[<B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B><I><FONT 
 | 
						||
      color=#ff3434>database-name</FONT></I><B><FONT color=#2c2cf0> 
 | 
						||
      <BIG>.</BIG></FONT></B>]<B><FONT color=#2c2cf0> </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>table-name</FONT></I><B><FONT color=#2c2cf0> 
 | 
						||
      </FONT></B>[<B><FONT color=#2c2cf0>WHERE </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>expr</FONT></I><B><FONT color=#2c2cf0></FONT></B>]<B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B></TD></TR></TBODY></TABLE>
 | 
						||
<P>The DELETE command is used to remove records from a table. The command 
 | 
						||
consists of the "DELETE FROM" keywords followed by the name of the table from 
 | 
						||
which records are to be removed. </P>
 | 
						||
<P>Without a WHERE clause, all rows of the table are removed. If a WHERE clause 
 | 
						||
is supplied, then only those rows that match the expression are removed.</P>
 | 
						||
<HR>
 | 
						||
<A name=detach></A>
 | 
						||
<H1>DETACH DATABASE</H1>
 | 
						||
<TABLE cellPadding=10>
 | 
						||
  <TBODY>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right><I><FONT 
 | 
						||
      color=#ff3434>sql-command</FONT></I> ::=</TD>
 | 
						||
    <TD><B><FONT color=#2c2cf0>DETACH </FONT></B>[<B><FONT 
 | 
						||
      color=#2c2cf0>DATABASE</FONT></B>]<B><FONT color=#2c2cf0> 
 | 
						||
      </FONT></B><I><FONT color=#ff3434>database-name</FONT></I><B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B></TD></TR></TBODY></TABLE>
 | 
						||
<P>This statement detaches an additional database connection previously attached 
 | 
						||
using the <A href="#attach">ATTACH 
 | 
						||
DATABASE</A> statement. It is possible to have the same database file attached 
 | 
						||
multiple times using different names, and detaching one connection to a file 
 | 
						||
will leave the others intact.</P>
 | 
						||
<P>This statement will fail if SQLite is in the middle of a transaction.</P>
 | 
						||
<HR>
 | 
						||
<A name=dropindex></A>
 | 
						||
<H1>DROP INDEX</H1>
 | 
						||
<TABLE cellPadding=10>
 | 
						||
  <TBODY>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right><I><FONT 
 | 
						||
      color=#ff3434>sql-command</FONT></I> ::=</TD>
 | 
						||
    <TD><B><FONT color=#2c2cf0>DROP INDEX </FONT></B>[<B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B><I><FONT 
 | 
						||
      color=#ff3434>database-name</FONT></I><B><FONT color=#2c2cf0> 
 | 
						||
      <BIG>.</BIG></FONT></B>]<B><FONT color=#2c2cf0> </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>index-name</FONT></I><B><FONT 
 | 
						||
  color=#2c2cf0></FONT></B></TD></TR></TBODY></TABLE>
 | 
						||
<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. 
 | 
						||
Non-temporary indexes on tables in an attached database cannot be dropped.</P>
 | 
						||
<P>The DROP INDEX statement does not reduce the size of the database file. Empty 
 | 
						||
space in the database is retained for later INSERTs. To remove free space in the 
 | 
						||
database, use the <A 
 | 
						||
href="#vacuum">VACUUM</A> command.</P>
 | 
						||
<HR>
 | 
						||
<A name=droptable></A>
 | 
						||
<H1>DROP TABLE</H1>
 | 
						||
<TABLE cellPadding=10>
 | 
						||
  <TBODY>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right><I><FONT 
 | 
						||
      color=#ff3434>sql-command</FONT></I> ::=</TD>
 | 
						||
    <TD><B><FONT color=#2c2cf0>DROP TABLE </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>table-name</FONT></I><B><FONT 
 | 
						||
  color=#2c2cf0></FONT></B></TD></TR></TBODY></TABLE>
 | 
						||
<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>
 | 
						||
<P>The DROP TABLE statement does not reduce the size of the database file. Empty 
 | 
						||
space in the database is retained for later INSERTs. To remove free space in the 
 | 
						||
database, use the <A 
 | 
						||
href="#vacuum">VACUUM</A> command.</P>
 | 
						||
<HR>
 | 
						||
<A name=droptrigger></A>
 | 
						||
<H1>DROP TRIGGER</H1>
 | 
						||
<TABLE cellPadding=10>
 | 
						||
  <TBODY>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right><I><FONT 
 | 
						||
      color=#ff3434>sql-statement</FONT></I> ::=</TD>
 | 
						||
    <TD><B><FONT color=#2c2cf0>DROP TRIGGER </FONT></B>[<B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B><I><FONT 
 | 
						||
      color=#ff3434>database-name</FONT></I><B><FONT color=#2c2cf0> 
 | 
						||
      <BIG>.</BIG></FONT></B>]<B><FONT color=#2c2cf0> </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>trigger-name</FONT></I><B><FONT 
 | 
						||
  color=#2c2cf0></FONT></B></TD></TR></TBODY></TABLE>
 | 
						||
<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>
 | 
						||
<HR>
 | 
						||
<A name=dropview></A>
 | 
						||
<H1>DROP VIEW</H1>
 | 
						||
<TABLE cellPadding=10>
 | 
						||
  <TBODY>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right><I><FONT 
 | 
						||
      color=#ff3434>sql-command</FONT></I> ::=</TD>
 | 
						||
    <TD><B><FONT color=#2c2cf0>DROP VIEW </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>view-name</FONT></I><B><FONT 
 | 
						||
  color=#2c2cf0></FONT></B></TD></TR></TBODY></TABLE>
 | 
						||
<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>
 | 
						||
<HR>
 | 
						||
<A name=explain></A>
 | 
						||
<H1>EXPLAIN</H1>
 | 
						||
<TABLE cellPadding=10>
 | 
						||
  <TBODY>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right><I><FONT 
 | 
						||
      color=#ff3434>sql-statement</FONT></I> ::=</TD>
 | 
						||
    <TD><B><FONT color=#2c2cf0>EXPLAIN </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>sql-statement</FONT></I><B><FONT 
 | 
						||
  color=#2c2cf0></FONT></B></TD></TR></TBODY></TABLE>
 | 
						||
<P>The EXPLAIN command modifier is a non-standard extension. The idea comes from 
 | 
						||
a similar command found in PostgreSQL, but the operation is completely 
 | 
						||
different.</P>
 | 
						||
<P>If the EXPLAIN keyword appears before any other SQLite SQL command then 
 | 
						||
instead of actually executing the command, the SQLite library will report back 
 | 
						||
the sequence of virtual machine instructions it would have used to execute the 
 | 
						||
command had the EXPLAIN keyword not been present. For additional information 
 | 
						||
about virtual machine instructions see the <A 
 | 
						||
href="http://www.hwaci.com/sw/sqlite/arch.html">architecture description</A> or 
 | 
						||
the documentation on <A 
 | 
						||
href="http://www.hwaci.com/sw/sqlite/opcode.html">available opcodes</A> for the 
 | 
						||
virtual machine.</P>
 | 
						||
<HR>
 | 
						||
<A name=expr></A>
 | 
						||
<H1>expression</H1>
 | 
						||
<TABLE cellPadding=10>
 | 
						||
  <TBODY>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right><I><FONT 
 | 
						||
    color=#ff3434>expr</FONT></I> ::=</TD>
 | 
						||
    <TD><B><FONT color=#2c2cf0></FONT></B><I><FONT 
 | 
						||
      color=#ff3434>expr</FONT></I><B><FONT color=#2c2cf0> </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>binary-op</FONT></I><B><FONT color=#2c2cf0> 
 | 
						||
      </FONT></B><I><FONT color=#ff3434>expr</FONT></I><B><FONT color=#2c2cf0> 
 | 
						||
      </FONT></B><BIG>|</BIG><B><FONT color=#2c2cf0><BR></FONT></B><I><FONT 
 | 
						||
      color=#ff3434>expr</FONT></I><B><FONT color=#2c2cf0> </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>like-op</FONT></I><B><FONT color=#2c2cf0> 
 | 
						||
      </FONT></B><I><FONT color=#ff3434>expr</FONT></I><B><FONT color=#2c2cf0> 
 | 
						||
      </FONT></B><BIG>|</BIG><B><FONT color=#2c2cf0><BR></FONT></B><I><FONT 
 | 
						||
      color=#ff3434>unary-op</FONT></I><B><FONT color=#2c2cf0> 
 | 
						||
      </FONT></B><I><FONT color=#ff3434>expr</FONT></I><B><FONT color=#2c2cf0> 
 | 
						||
      </FONT></B><BIG>|</BIG><B><FONT color=#2c2cf0><BR><BIG>(</BIG> 
 | 
						||
      </FONT></B><I><FONT color=#ff3434>expr</FONT></I><B><FONT color=#2c2cf0> 
 | 
						||
      <BIG>)</BIG> </FONT></B><BIG>|</BIG><B><FONT 
 | 
						||
      color=#2c2cf0><BR></FONT></B><I><FONT 
 | 
						||
      color=#ff3434>column-name</FONT></I><B><FONT color=#2c2cf0> 
 | 
						||
      </FONT></B><BIG>|</BIG><B><FONT color=#2c2cf0><BR></FONT></B><I><FONT 
 | 
						||
      color=#ff3434>table-name</FONT></I><B><FONT color=#2c2cf0> <BIG>.</BIG> 
 | 
						||
      </FONT></B><I><FONT color=#ff3434>column-name</FONT></I><B><FONT 
 | 
						||
      color=#2c2cf0> </FONT></B><BIG>|</BIG><B><FONT 
 | 
						||
      color=#2c2cf0><BR></FONT></B><I><FONT 
 | 
						||
      color=#ff3434>database-name</FONT></I><B><FONT color=#2c2cf0> <BIG>.</BIG> 
 | 
						||
      </FONT></B><I><FONT color=#ff3434>table-name</FONT></I><B><FONT 
 | 
						||
      color=#2c2cf0> <BIG>.</BIG> </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>column-name</FONT></I><B><FONT color=#2c2cf0> 
 | 
						||
      </FONT></B><BIG>|</BIG><B><FONT color=#2c2cf0><BR></FONT></B><I><FONT 
 | 
						||
      color=#ff3434>literal-value</FONT></I><B><FONT color=#2c2cf0> 
 | 
						||
      </FONT></B><BIG>|</BIG><B><FONT color=#2c2cf0><BR></FONT></B><I><FONT 
 | 
						||
      color=#ff3434>function-name</FONT></I><B><FONT color=#2c2cf0> <BIG>(</BIG> 
 | 
						||
      </FONT></B><I><FONT color=#ff3434>expr-list</FONT></I><B><FONT 
 | 
						||
      color=#2c2cf0> </FONT></B><BIG>|</BIG><B><FONT color=#2c2cf0> <BIG>*</BIG> 
 | 
						||
      <BIG>)</BIG> </FONT></B><BIG>|</BIG><B><FONT 
 | 
						||
      color=#2c2cf0><BR></FONT></B><I><FONT 
 | 
						||
      color=#ff3434>expr</FONT></I><B><FONT color=#2c2cf0> ISNULL 
 | 
						||
      </FONT></B><BIG>|</BIG><B><FONT color=#2c2cf0><BR></FONT></B><I><FONT 
 | 
						||
      color=#ff3434>expr</FONT></I><B><FONT color=#2c2cf0> NOTNULL 
 | 
						||
      </FONT></B><BIG>|</BIG><B><FONT color=#2c2cf0><BR></FONT></B><I><FONT 
 | 
						||
      color=#ff3434>expr</FONT></I><B><FONT color=#2c2cf0> </FONT></B>[<B><FONT 
 | 
						||
      color=#2c2cf0>NOT</FONT></B>]<B><FONT color=#2c2cf0> BETWEEN 
 | 
						||
      </FONT></B><I><FONT color=#ff3434>expr</FONT></I><B><FONT color=#2c2cf0> 
 | 
						||
      AND </FONT></B><I><FONT color=#ff3434>expr</FONT></I><B><FONT 
 | 
						||
      color=#2c2cf0> </FONT></B><BIG>|</BIG><B><FONT 
 | 
						||
      color=#2c2cf0><BR></FONT></B><I><FONT 
 | 
						||
      color=#ff3434>expr</FONT></I><B><FONT color=#2c2cf0> </FONT></B>[<B><FONT 
 | 
						||
      color=#2c2cf0>NOT</FONT></B>]<B><FONT color=#2c2cf0> IN <BIG>(</BIG> 
 | 
						||
      </FONT></B><I><FONT color=#ff3434>value-list</FONT></I><B><FONT 
 | 
						||
      color=#2c2cf0> <BIG>)</BIG> </FONT></B><BIG>|</BIG><B><FONT 
 | 
						||
      color=#2c2cf0><BR></FONT></B><I><FONT 
 | 
						||
      color=#ff3434>expr</FONT></I><B><FONT color=#2c2cf0> </FONT></B>[<B><FONT 
 | 
						||
      color=#2c2cf0>NOT</FONT></B>]<B><FONT color=#2c2cf0> IN <BIG>(</BIG> 
 | 
						||
      </FONT></B><I><FONT color=#ff3434>select-statement</FONT></I><B><FONT 
 | 
						||
      color=#2c2cf0> <BIG>)</BIG> </FONT></B><BIG>|</BIG><B><FONT 
 | 
						||
      color=#2c2cf0><BR></FONT></B><I><FONT 
 | 
						||
      color=#ff3434>expr</FONT></I><B><FONT color=#2c2cf0> </FONT></B>[<B><FONT 
 | 
						||
      color=#2c2cf0>NOT</FONT></B>]<B><FONT color=#2c2cf0> IN 
 | 
						||
      </FONT></B>[<B><FONT color=#2c2cf0></FONT></B><I><FONT 
 | 
						||
      color=#ff3434>database-name</FONT></I><B><FONT color=#2c2cf0> 
 | 
						||
      <BIG>.</BIG></FONT></B>]<B><FONT color=#2c2cf0> </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>table-name</FONT></I><B><FONT color=#2c2cf0> 
 | 
						||
      </FONT></B><BIG>|</BIG><B><FONT color=#2c2cf0><BR><BIG>(</BIG> 
 | 
						||
      </FONT></B><I><FONT color=#ff3434>select-statement</FONT></I><B><FONT 
 | 
						||
      color=#2c2cf0> <BIG>)</BIG> </FONT></B><BIG>|</BIG><B><FONT 
 | 
						||
      color=#2c2cf0><BR>CASE </FONT></B>[<B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B><I><FONT color=#ff3434>expr</FONT></I><B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B>]<B><FONT color=#2c2cf0> </FONT></B>(<B><FONT 
 | 
						||
      color=#2c2cf0> WHEN </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>expr</FONT></I><B><FONT color=#2c2cf0> THEN 
 | 
						||
      </FONT></B><I><FONT color=#ff3434>expr</FONT></I><B><FONT color=#2c2cf0> 
 | 
						||
      </FONT></B>)+<B><FONT color=#2c2cf0> </FONT></B>[<B><FONT 
 | 
						||
      color=#2c2cf0>ELSE </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>expr</FONT></I><B><FONT color=#2c2cf0></FONT></B>]<B><FONT 
 | 
						||
      color=#2c2cf0> END</FONT></B></TD></TR>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right><I><FONT 
 | 
						||
      color=#ff3434>like-op</FONT></I> ::=</TD>
 | 
						||
    <TD><B><FONT color=#2c2cf0>LIKE </FONT></B><BIG>|</BIG><B><FONT 
 | 
						||
      color=#2c2cf0> GLOB </FONT></B><BIG>|</BIG><B><FONT color=#2c2cf0> NOT 
 | 
						||
      LIKE </FONT></B><BIG>|</BIG><B><FONT color=#2c2cf0> NOT 
 | 
						||
  GLOB</FONT></B></TD></TR></TBODY></TABLE>
 | 
						||
<P>This section is different from the others. Most other sections of this 
 | 
						||
document talks about a particular SQL command. This section does not talk about 
 | 
						||
a standalone command but about "expressions" which are subcomponents of most 
 | 
						||
other commands.</P>
 | 
						||
<P>SQLite understands the following binary operators, in order from highest to 
 | 
						||
lowest precedence:</P>
 | 
						||
<BLOCKQUOTE><PRE><FONT color=#2c2cf0><BIG>||
 | 
						||
*    /    %
 | 
						||
+    -
 | 
						||
<<   >>   &    |
 | 
						||
<    <=   >    >=
 | 
						||
=    ==   !=   <>   </BIG>IN
 | 
						||
AND   
 | 
						||
OR</FONT>
 | 
						||
</PRE></BLOCKQUOTE>
 | 
						||
<P>Supported unary operaters are these:</P>
 | 
						||
<BLOCKQUOTE><PRE><FONT color=#2c2cf0><BIG>-    +    !    ~</BIG></FONT>
 | 
						||
</PRE></BLOCKQUOTE>
 | 
						||
<P>Any SQLite value can be used as part of an expression. For arithmetic 
 | 
						||
operations, integers are treated as integers. Strings are first converted to 
 | 
						||
real numbers using <B>atof()</B>. For comparison operators, numbers compare as 
 | 
						||
numbers and strings compare using the <B>strcmp()</B> function. Note that there 
 | 
						||
are two variations of the equals and not equals operators. Equals can be either 
 | 
						||
<FONT color=#2c2cf0><BIG>=</BIG></FONT> or <FONT 
 | 
						||
color=#2c2cf0><BIG>==</BIG></FONT>. The non-equals operator can be either <FONT 
 | 
						||
color=#2c2cf0><BIG>!=</BIG></FONT> or <FONT 
 | 
						||
color=#2c2cf0><BIG><></BIG></FONT>. The <FONT 
 | 
						||
color=#2c2cf0><BIG>||</BIG></FONT> operator is "concatenate" - it joins together 
 | 
						||
the two strings of its operands. The operator <FONT 
 | 
						||
color=#2c2cf0><BIG>%</BIG></FONT> outputs the remainder of its left operand 
 | 
						||
modulo its right operand.</P><A name=like></A>
 | 
						||
<P>The LIKE operator does a wildcard comparision. The operand to the right 
 | 
						||
contains the wildcards. A percent symbol <FONT color=#2c2cf0><BIG>%</BIG></FONT> 
 | 
						||
in the right operand matches any sequence of zero or more characters on the 
 | 
						||
left. An underscore <FONT color=#2c2cf0><BIG>_</BIG></FONT> on the right matches 
 | 
						||
any single character on the left. The LIKE operator is not case sensitive and 
 | 
						||
will match upper case characters on one side against lower case characters on 
 | 
						||
the other. (A bug: SQLite only understands upper/lower case for 7-bit Latin 
 | 
						||
characters. Hence the LIKE operator is case sensitive for 8-bit iso8859 
 | 
						||
characters or UTF-8 characters. For example, the expression 
 | 
						||
<B>'a' LIKE 'A'</B> is TRUE but <B>'<27>' LIKE '<27>'</B> is 
 | 
						||
FALSE.). The infix LIKE operator is identical the user function <A 
 | 
						||
href="#likeFunc">like(<I>X</I>,<I>Y</I>)</A>. 
 | 
						||
</P><A name=glob></A>
 | 
						||
<P>The GLOB operator is similar to LIKE but uses the Unix file globbing syntax 
 | 
						||
for its wildcards. Also, GLOB is case sensitive, unlike LIKE. Both GLOB and LIKE 
 | 
						||
may be preceded by the NOT keyword to invert the sense of the test. The infix 
 | 
						||
GLOB operator is identical the user function <A 
 | 
						||
href="#globFunc">glob(<I>X</I>,<I>Y</I>)</A>.</P>
 | 
						||
<P>A column name can be any of the names defined in the CREATE TABLE statement 
 | 
						||
or one of the following special identifiers: "<B>ROWID</B>", "<B>OID</B>", or 
 | 
						||
"<B>_ROWID_</B>". These special identifiers all describe the unique random 
 | 
						||
integer key (the "row key") associated with every row of every table. The 
 | 
						||
special identifiers only refer to the row key if the CREATE TABLE statement does 
 | 
						||
not define a real column with the same name. Row keys act like read-only 
 | 
						||
columns. A row key can be used anywhere a regular column can be used, except 
 | 
						||
that you cannot change the value of a row key in an UPDATE or INSERT statement. 
 | 
						||
"SELECT * ..." does not return the row key.</P>
 | 
						||
<P>SELECT statements can appear in expressions as either the right-hand operand 
 | 
						||
of the IN operator or as a scalar quantity. In both cases, the SELECT should 
 | 
						||
have only a single column in its result. Compound SELECTs (connected with 
 | 
						||
keywords like UNION or EXCEPT) are allowed. A SELECT in an expression is 
 | 
						||
evaluated once before any other processing is performed, so none of the 
 | 
						||
expressions within the select itself can refer to quantities in the containing 
 | 
						||
expression.</P>
 | 
						||
<P>When a SELECT is the right operand of the IN operator, the IN operator 
 | 
						||
returns TRUE if the result of the left operand is any of the values generated by 
 | 
						||
the select. The IN operator may be preceded by the NOT keyword to invert the 
 | 
						||
sense of the test.</P>
 | 
						||
<P>When a SELECT appears within an expression but is not the right operand of an 
 | 
						||
IN operator, then the first row of the result of the SELECT becomes the value 
 | 
						||
used in the expression. If the SELECT yields more than one result row, all rows 
 | 
						||
after the first are ignored. If the SELECT yeilds no rows, then the value of the 
 | 
						||
SELECT is NULL.</P>
 | 
						||
<P>Both simple and aggregate functions are supported. A simple function can be 
 | 
						||
used in any expression. Simple functions return a result immediately based on 
 | 
						||
their inputs. Aggregate functions may only be used in a SELECT statement. 
 | 
						||
Aggregate functions compute their result across all rows of the result set.</P>
 | 
						||
<P>The functions shown below are available by default. Additional functions may 
 | 
						||
be written in C and added to the database engine using the <A 
 | 
						||
href="http://www.hwaci.com/sw/sqlite/c_interface.html#cfunc">sqlite_create_function()</A> 
 | 
						||
API.</P>
 | 
						||
<TABLE cellPadding=10 border=0>
 | 
						||
  <TBODY>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right width=120>abs(<I>X</I>)</TD>
 | 
						||
    <TD vAlign=top>Return the absolute value of argument <I>X</I>.</TD></TR>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right>coalesce(<I>X</I>,<I>Y</I>,...)</TD>
 | 
						||
    <TD vAlign=top>Return a copy of the first non-NULL argument. If all 
 | 
						||
      arguments are NULL then NULL is returned. There must be at least 2 
 | 
						||
      arguments.</TD></TR>
 | 
						||
  <TR><A name=globFunc></A>
 | 
						||
    <TD vAlign=top align=right>glob(<I>X</I>,<I>Y</I>)</TD>
 | 
						||
    <TD vAlign=top>This function is used to implement the "<B>Y GLOB X</B>" 
 | 
						||
      syntax of SQLite. The <A 
 | 
						||
      href="http://www.hwaci.com/sw/sqlite/c_interface.html#cfunc">sqlite_create_function()</A> 
 | 
						||
      interface can be used to override this function and thereby change the 
 | 
						||
      operation of the <A 
 | 
						||
      href="#glob">GLOB</A> 
 | 
						||
  operator.</TD></TR>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right>ifnull(<I>X</I>,<I>Y</I>)</TD>
 | 
						||
    <TD vAlign=top>Return a copy of the first non-NULL argument. If both 
 | 
						||
      arguments are NULL then NULL is returned. This behaves the same as 
 | 
						||
      <B>coalesce()</B> above.</TD></TR>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right>last_insert_rowid()</TD>
 | 
						||
    <TD vAlign=top>Return the ROWID of the last row insert from this 
 | 
						||
      connection to the database. This is the same value that would be returned 
 | 
						||
      from the <B>sqlite_last_insert_rowid()</B> API function.</TD></TR>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right>length(<I>X</I>)</TD>
 | 
						||
    <TD vAlign=top>Return the string length of <I>X</I> in characters. If 
 | 
						||
      SQLite is configured to support UTF-8, then the number of UTF-8 characters 
 | 
						||
      is returned, not the number of bytes.</TD></TR>
 | 
						||
  <TR><A name=likeFunc></A>
 | 
						||
    <TD vAlign=top align=right>like(<I>X</I>,<I>Y</I>)</TD>
 | 
						||
    <TD vAlign=top>This function is used to implement the "<B>Y LIKE X</B>" 
 | 
						||
      syntax of SQL. The <A 
 | 
						||
      href="http://www.hwaci.com/sw/sqlite/c_interface.html#cfunc">sqlite_create_function()</A> 
 | 
						||
      interface can be used to override this function and thereby change the 
 | 
						||
      operation of the <A 
 | 
						||
      href="#like">LIKE</A> 
 | 
						||
  operator.</TD></TR>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right>lower(<I>X</I>)</TD>
 | 
						||
    <TD vAlign=top>Return a copy of string <I>X</I> will all characters 
 | 
						||
      converted to lower case. The C library <B>tolower()</B> routine is used 
 | 
						||
      for the conversion, which means that this function might not work 
 | 
						||
      correctly on UTF-8 characters.</TD></TR>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right>max(<I>X</I>,<I>Y</I>,...)</TD>
 | 
						||
    <TD vAlign=top>Return the argument with the maximum value. Arguments may 
 | 
						||
      be strings in addition to numbers. The maximum value is determined by the 
 | 
						||
      usual sort order. Note that <B>max()</B> is a simple function when it has 
 | 
						||
      2 or more arguments but converts to an aggregate function if given only a 
 | 
						||
      single argument.</TD></TR>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right>min(<I>X</I>,<I>Y</I>,...)</TD>
 | 
						||
    <TD vAlign=top>Return the argument with the minimum value. Arguments may 
 | 
						||
      be strings in addition to numbers. The mminimum value is determined by the 
 | 
						||
      usual sort order. Note that <B>min()</B> is a simple function when it has 
 | 
						||
      2 or more arguments but converts to an aggregate function if given only a 
 | 
						||
      single argument.</TD></TR>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right>nullif(<I>X</I>,<I>Y</I>)</TD>
 | 
						||
    <TD vAlign=top>Return the first argument if the arguments are different, 
 | 
						||
      otherwise return NULL.</TD></TR>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right>random(*)</TD>
 | 
						||
    <TD vAlign=top>Return a random integer between -2147483648 and 
 | 
						||
    +2147483647.</TD></TR>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right>round(<I>X</I>)<BR>round(<I>X</I>,<I>Y</I>)</TD>
 | 
						||
    <TD vAlign=top>Round off the number <I>X</I> to <I>Y</I> digits to the 
 | 
						||
      right of the decimal point. If the <I>Y</I> argument is omitted, 0 is 
 | 
						||
      assumed.</TD></TR>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right>soundex(<I>X</I>)</TD>
 | 
						||
    <TD vAlign=top>Compute the soundex encoding of the string <I>X</I>. The 
 | 
						||
      string "?000" is returned if the argument is NULL. This function is 
 | 
						||
      omitted from SQLite by default. It is only available the 
 | 
						||
      -DSQLITE_SOUNDEX=1 compiler option is used when SQLite is built.</TD></TR>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right>sqlite_version(*)</TD>
 | 
						||
    <TD vAlign=top>Return the version string for the SQLite library that is 
 | 
						||
      running. Example: "2.8.0"</TD></TR>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right>substr(<I>X</I>,<I>Y</I>,<I>Z</I>)</TD>
 | 
						||
    <TD vAlign=top>Return a substring of input string <I>X</I> that begins 
 | 
						||
      with the <I>Y</I>-th character and which is <I>Z</I> characters long. The 
 | 
						||
      left-most character of <I>X</I> is number 1. If <I>Y</I> is negative the 
 | 
						||
      the first character of the substring is found by counting from the right 
 | 
						||
      rather than the left. If SQLite is configured to support UTF-8, then 
 | 
						||
      characters indices refer to actual UTF-8 characters, not bytes.</TD></TR>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right>typeof(<I>X</I>)</TD>
 | 
						||
    <TD vAlign=top>Return the type of the expression <I>X</I>. The only return 
 | 
						||
      values are "numeric" and "text". SQLite's type handling is explained in <A 
 | 
						||
      href="http://www.hwaci.com/sw/sqlite/datatypes.html">Datatypes in 
 | 
						||
      SQLite</A>.</TD></TR>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right>upper(<I>X</I>)</TD>
 | 
						||
    <TD vAlign=top>Return a copy of input string <I>X</I> converted to all 
 | 
						||
      upper-case letters. The implementation of this function uses the C library 
 | 
						||
      routine <B>toupper()</B> which means it may not work correctly on UTF-8 
 | 
						||
      strings.</TD></TR></TBODY></TABLE>
 | 
						||
<P>The following aggregate functions are available by default. Additional 
 | 
						||
aggregate functions written in C may be added using the <A 
 | 
						||
href="http://www.hwaci.com/sw/sqlite/c_interface.html#cfunc">sqlite_create_aggregate()</A> 
 | 
						||
API.</P>
 | 
						||
<TABLE cellPadding=10 border=0>
 | 
						||
  <TBODY>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right width=120>avg(<I>X</I>)</TD>
 | 
						||
    <TD vAlign=top>Return the average value of all <I>X</I> within a 
 | 
						||
  group.</TD></TR>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right>count(<I>X</I>)<BR>count(*)</TD>
 | 
						||
    <TD vAlign=top>The first form return a count of the number of times that 
 | 
						||
      <I>X</I> is not NULL in a group. The second form (with no argument) 
 | 
						||
      returns the total number of rows in the group.</TD></TR>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right>max(<I>X</I>)</TD>
 | 
						||
    <TD vAlign=top>Return the maximum value of all values in the group. The 
 | 
						||
      usual sort order is used to determine the maximum.</TD></TR>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right>min(<I>X</I>)</TD>
 | 
						||
    <TD vAlign=top>Return the minimum value of all values in the group. The 
 | 
						||
      usual sort order is used to determine the minimum.</TD></TR>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right>sum(<I>X</I>)</TD>
 | 
						||
    <TD vAlign=top>Return the numeric sum of all values in the 
 | 
						||
  group.</TD></TR></TBODY></TABLE>
 | 
						||
<HR>
 | 
						||
<A name=insert></A>
 | 
						||
<H1>INSERT</H1>
 | 
						||
<TABLE cellPadding=10>
 | 
						||
  <TBODY>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right><I><FONT 
 | 
						||
      color=#ff3434>sql-statement</FONT></I> ::=</TD>
 | 
						||
    <TD><B><FONT color=#2c2cf0>INSERT </FONT></B>[<B><FONT color=#2c2cf0>OR 
 | 
						||
      </FONT></B><I><FONT color=#ff3434>conflict-algorithm</FONT></I><B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B>]<B><FONT color=#2c2cf0> INTO 
 | 
						||
      </FONT></B>[<B><FONT color=#2c2cf0></FONT></B><I><FONT 
 | 
						||
      color=#ff3434>database-name</FONT></I><B><FONT color=#2c2cf0> 
 | 
						||
      <BIG>.</BIG></FONT></B>]<B><FONT color=#2c2cf0> </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>table-name</FONT></I><B><FONT color=#2c2cf0> 
 | 
						||
      </FONT></B>[<B><FONT color=#2c2cf0><BIG>(</BIG></FONT></B><I><FONT 
 | 
						||
      color=#ff3434>column-list</FONT></I><B><FONT 
 | 
						||
      color=#2c2cf0><BIG>)</BIG></FONT></B>]<B><FONT color=#2c2cf0> 
 | 
						||
      VALUES<BIG>(</BIG></FONT></B><I><FONT 
 | 
						||
      color=#ff3434>value-list</FONT></I><B><FONT color=#2c2cf0><BIG>)</BIG> 
 | 
						||
      </FONT></B><BIG>|</BIG><B><FONT color=#2c2cf0><BR>INSERT 
 | 
						||
      </FONT></B>[<B><FONT color=#2c2cf0>OR </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>conflict-algorithm</FONT></I><B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B>]<B><FONT color=#2c2cf0> INTO 
 | 
						||
      </FONT></B>[<B><FONT color=#2c2cf0></FONT></B><I><FONT 
 | 
						||
      color=#ff3434>database-name</FONT></I><B><FONT color=#2c2cf0> 
 | 
						||
      <BIG>.</BIG></FONT></B>]<B><FONT color=#2c2cf0> </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>table-name</FONT></I><B><FONT color=#2c2cf0> 
 | 
						||
      </FONT></B>[<B><FONT color=#2c2cf0><BIG>(</BIG></FONT></B><I><FONT 
 | 
						||
      color=#ff3434>column-list</FONT></I><B><FONT 
 | 
						||
      color=#2c2cf0><BIG>)</BIG></FONT></B>]<B><FONT color=#2c2cf0> 
 | 
						||
      </FONT></B><I><FONT color=#ff3434>select-statement</FONT></I><B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B></TD></TR></TBODY></TABLE>
 | 
						||
<P>The INSERT statement comes in two basic forms. The first form (with the 
 | 
						||
"VALUES" keyword) creates a single new row in an existing table. If no 
 | 
						||
column-list is specified then the number of values must be the same as the 
 | 
						||
number of columns in the table. If a column-list is specified, then the number 
 | 
						||
of values must match the number of specified columns. Columns of the table that 
 | 
						||
do not appear in the column list are filled with the default value, or with NULL 
 | 
						||
if not default value is specified. </P>
 | 
						||
<P>The second form of the INSERT statement takes it data from a SELECT 
 | 
						||
statement. The number of columns in the result of the SELECT must exactly match 
 | 
						||
the number of columns in the table if no column list is specified, or it must 
 | 
						||
match the number of columns name in the column list. A new entry is made in the 
 | 
						||
table for every row of the SELECT result. The SELECT may be simple or compound. 
 | 
						||
If the SELECT statement has an ORDER BY clause, the ORDER BY is ignored.</P>
 | 
						||
<P>The optional conflict-clause allows the specification of an alternative 
 | 
						||
constraint conflict resolution algorithm to use during this one command. See the 
 | 
						||
section titled <A href="#conflict">ON 
 | 
						||
CONFLICT</A> for additional information. For compatibility with MySQL, the 
 | 
						||
parser allows the use of the single keyword <A 
 | 
						||
href="#replace">REPLACE</A> as an alias 
 | 
						||
for "INSERT OR REPLACE". </P>
 | 
						||
<HR>
 | 
						||
<A name=conflict></A>
 | 
						||
<H1>ON CONFLICT clause</H1>
 | 
						||
<TABLE cellPadding=10>
 | 
						||
  <TBODY>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right><I><FONT 
 | 
						||
      color=#ff3434>conflict-clause</FONT></I> ::=</TD>
 | 
						||
    <TD><B><FONT color=#2c2cf0>ON CONFLICT </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>conflict-algorithm</FONT></I><B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B></TD></TR>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right><I><FONT 
 | 
						||
      color=#ff3434>conflict-algorithm</FONT></I> ::=</TD>
 | 
						||
    <TD><B><FONT color=#2c2cf0>ROLLBACK </FONT></B><BIG>|</BIG><B><FONT 
 | 
						||
      color=#2c2cf0> ABORT </FONT></B><BIG>|</BIG><B><FONT color=#2c2cf0> FAIL 
 | 
						||
      </FONT></B><BIG>|</BIG><B><FONT color=#2c2cf0> IGNORE 
 | 
						||
      </FONT></B><BIG>|</BIG><B><FONT color=#2c2cf0> 
 | 
						||
  REPLACE</FONT></B></TD></TR></TBODY></TABLE>
 | 
						||
<P>The ON CONFLICT clause is not a separate SQL command. It is a non-standard 
 | 
						||
clause that can appear in many other SQL commands. It is given its own section 
 | 
						||
in this document because it is not part of standard SQL and therefore might not 
 | 
						||
be familiar.</P>
 | 
						||
<P>The syntax for the ON CONFLICT clause is as shown above for the CREATE TABLE, 
 | 
						||
CREATE INDEX, and BEGIN TRANSACTION commands. For the COPY, INSERT, and UPDATE 
 | 
						||
commands, the keywords "ON CONFLICT" are replaced by "OR", to make the syntax 
 | 
						||
seem more natural. But the meaning of the clause is the same either way.</P>
 | 
						||
<P>The ON CONFLICT clause specifies an algorithm used to resolve constraint 
 | 
						||
conflicts. There are five choices: ROLLBACK, ABORT, FAIL, IGNORE, and REPLACE. 
 | 
						||
The default algorithm is ABORT. This is what they mean:</P>
 | 
						||
<DL>
 | 
						||
  <DT><B>ROLLBACK</B> 
 | 
						||
  <DD>
 | 
						||
  <P>When a constraint violation occurs, an immediate ROLLBACK occurs, thus 
 | 
						||
  ending the current transaction, and the command aborts with a return code of 
 | 
						||
  SQLITE_CONSTRAINT. If no transaction is active (other than the implied 
 | 
						||
  transaction that is created on every command) then this algorithm works the 
 | 
						||
  same as ABORT.</P>
 | 
						||
  <DT><B>ABORT</B> 
 | 
						||
  <DD>
 | 
						||
  <P>When a constraint violation occurs, the command backs out any prior changes 
 | 
						||
  it might have made and aborts with a return code of SQLITE_CONSTRAINT. But no 
 | 
						||
  ROLLBACK is executed so changes from prior commands within the same 
 | 
						||
  transaction are preserved. This is the default behavior.</P>
 | 
						||
  <DT><B>FAIL</B> 
 | 
						||
  <DD>
 | 
						||
  <P>When a constraint violation occurs, the command aborts with a return code 
 | 
						||
  SQLITE_CONSTRAINT. But any changes to the database that the command made prior 
 | 
						||
  to encountering the constraint violation are preserved and are not backed out. 
 | 
						||
  For example, if an UPDATE statement encountered a constraint violation on the 
 | 
						||
  100th row that it attempts to update, then the first 99 row changes are 
 | 
						||
  preserved but changes to rows 100 and beyond never occur.</P>
 | 
						||
  <DT><B>IGNORE</B> 
 | 
						||
  <DD>
 | 
						||
  <P>When a constraint violation occurs, the one row that contains the 
 | 
						||
  constraint violation is not inserted or changed. But the command continues 
 | 
						||
  executing normally. Other rows before and after the row that contained the 
 | 
						||
  constraint violation continue to be inserted or updated normally. No error is 
 | 
						||
  returned.</P>
 | 
						||
  <DT><B>REPLACE</B> 
 | 
						||
  <DD>
 | 
						||
  <P>When a UNIQUE constraint violation occurs, the pre-existing rows that are 
 | 
						||
  causing the constraint violation are removed prior to inserting or updating 
 | 
						||
  the current row. Thus the insert or update always occurs. The command 
 | 
						||
  continues executing normally. No error is returned. If a NOT NULL constraint 
 | 
						||
  violation occurs, the NULL value is replaced by the default value for that 
 | 
						||
  column. If the column has no default value, then the ABORT algorithm is 
 | 
						||
  used.</P>
 | 
						||
  <P>When this conflict resolution strategy deletes rows in order to statisfy a 
 | 
						||
  constraint, it does not invoke delete triggers on those rows. But that may 
 | 
						||
  change in a future release.</P></DD></DL>
 | 
						||
<P>The conflict resolution algorithm can be specified in three places, in order 
 | 
						||
from lowest to highest precedence: </P>
 | 
						||
<OL>
 | 
						||
  <LI>
 | 
						||
  <P>On individual constraints within a CREATE TABLE or CREATE INDEX statement. 
 | 
						||
  </P>
 | 
						||
  <LI>
 | 
						||
  <P>On a BEGIN TRANSACTION command. </P>
 | 
						||
  <LI>
 | 
						||
  <P>In the OR clause of a COPY, INSERT, or UPDATE command. </P></LI></OL>
 | 
						||
<P>The algorithm specified in the OR clause of a COPY, INSERT, or UPDATE 
 | 
						||
overrides any algorithm specified on the BEGIN TRANSACTION command and the 
 | 
						||
algorithm specified on the BEGIN TRANSACTION command overrides the algorithm 
 | 
						||
specified in the a CREATE TABLE or CREATE INDEX. If no algorithm is specified 
 | 
						||
anywhere, the ABORT algorithm is used.</P>
 | 
						||
<HR>
 | 
						||
<A name=pragma></A>
 | 
						||
<H1>PRAGMA</H1>
 | 
						||
<TABLE cellPadding=10>
 | 
						||
  <TBODY>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right><I><FONT 
 | 
						||
      color=#ff3434>sql-statement</FONT></I> ::=</TD>
 | 
						||
    <TD><B><FONT color=#2c2cf0>PRAGMA </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>name</FONT></I><B><FONT color=#2c2cf0> </FONT></B>[<B><FONT 
 | 
						||
      color=#2c2cf0>= </FONT></B><I><FONT color=#ff3434>value</FONT></I><B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B>]<B><FONT color=#2c2cf0> 
 | 
						||
      </FONT></B><BIG>|</BIG><B><FONT color=#2c2cf0><BR>PRAGMA 
 | 
						||
      </FONT></B><I><FONT color=#ff3434>function</FONT></I><B><FONT 
 | 
						||
      color=#2c2cf0><BIG>(</BIG></FONT></B><I><FONT 
 | 
						||
      color=#ff3434>arg</FONT></I><B><FONT 
 | 
						||
    color=#2c2cf0><BIG>)</BIG></FONT></B></TD></TR></TBODY></TABLE>
 | 
						||
<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>
 | 
						||
  <P><B>PRAGMA count_changes = ON; </B>(1)<B> <BR>PRAGMA count_changes = 
 | 
						||
  OFF;</B> (0)</P>
 | 
						||
  <P>When on, the COUNT_CHANGES pragma causes the callback function to be 
 | 
						||
  invoked once for each DELETE, INSERT, or UPDATE operation. The argument is the 
 | 
						||
  number of rows that were changed.</P>
 | 
						||
  <P>This pragma may be removed from future versions of SQLite. Consider using 
 | 
						||
  the <B>sqlite_changes()</B> API function instead.</P>
 | 
						||
  <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 datbase 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><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 everytime you reopen the database.</P><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><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. Once the temporary database is in use, its 
 | 
						||
  location cannot be changed. It is possible for the library compile-time symbol 
 | 
						||
  TEMP_STORE to override this setting. The following table summarizes this:</P>
 | 
						||
  <TABLE cellPadding=2>
 | 
						||
    <TBODY>
 | 
						||
    <TR>
 | 
						||
      <TH>TEMP_STORE</TH>
 | 
						||
      <TH>temp_store</TH>
 | 
						||
      <TH>temp database location</TH></TR>
 | 
						||
    <TR>
 | 
						||
      <TD align=middle>0</TD>
 | 
						||
      <TD align=middle><EM>any</EM></TD>
 | 
						||
      <TD align=middle>file</TD></TR>
 | 
						||
    <TR>
 | 
						||
      <TD align=middle>1</TD>
 | 
						||
      <TD align=middle>0</TD>
 | 
						||
      <TD align=middle>file</TD></TR>
 | 
						||
    <TR>
 | 
						||
      <TD align=middle>1</TD>
 | 
						||
      <TD align=middle>1</TD>
 | 
						||
      <TD align=middle>file</TD></TR>
 | 
						||
    <TR>
 | 
						||
      <TD align=middle>1</TD>
 | 
						||
      <TD align=middle>2</TD>
 | 
						||
      <TD align=middle>memory</TD></TR>
 | 
						||
    <TR>
 | 
						||
      <TD align=middle>2</TD>
 | 
						||
      <TD align=middle>0</TD>
 | 
						||
      <TD align=middle>memory</TD></TR>
 | 
						||
    <TR>
 | 
						||
      <TD align=middle>2</TD>
 | 
						||
      <TD align=middle>1</TD>
 | 
						||
      <TD align=middle>file</TD></TR>
 | 
						||
    <TR>
 | 
						||
      <TD align=middle>2</TD>
 | 
						||
      <TD align=middle>2</TD>
 | 
						||
      <TD align=middle>memory</TD></TR>
 | 
						||
    <TR>
 | 
						||
      <TD align=middle>3</TD>
 | 
						||
      <TD align=middle><EM>any</EM></TD>
 | 
						||
      <TD align=middle>memory</TD></TR></TBODY></TABLE>
 | 
						||
  <P>This pragma changes the temp_store mode persistently. Once changed, the 
 | 
						||
  mode stays set even if the database is closed and reopened. The <A 
 | 
						||
  href="#pragma_temp_store"><B>temp_store</B></A> 
 | 
						||
  pragma does the same thing but only applies the setting to the current 
 | 
						||
  session.</P><A name=pragma_empty_result_callbacks></A>
 | 
						||
  <LI>
 | 
						||
  <P><B>PRAGMA empty_result_callbacks = ON; </B>(1)<B> <BR>PRAGMA 
 | 
						||
  empty_result_callbacks = OFF;</B> (0)</P>
 | 
						||
  <P>When on, the EMPTY_RESULT_CALLBACKS pragma causes the callback function to 
 | 
						||
  be invoked once for each query that has an empty result set. The third 
 | 
						||
  "<B>argv</B>" parameter to the callback is set to NULL because there is no 
 | 
						||
  data to report. But the second "<B>argc</B>" and fourth "<B>columnNames</B>" 
 | 
						||
  parameters are valid and can be used to determine the number and names of the 
 | 
						||
  columns that would have been in the result set had the set not been empty.</P>
 | 
						||
  <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>
 | 
						||
  <P><B>PRAGMA full_column_names = ON; </B>(1)<B> <BR>PRAGMA full_column_names = 
 | 
						||
  OFF;</B> (0)</P>
 | 
						||
  <P>The column names reported in an SQLite callback are normally just the name 
 | 
						||
  of the column itself, except for joins when "TABLE.COLUMN" is used. But when 
 | 
						||
  full_column_names is turned on, column names are always reported as 
 | 
						||
  "TABLE.COLUMN" even for simple queries.</P>
 | 
						||
  <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>
 | 
						||
  <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>
 | 
						||
  <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>
 | 
						||
  <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><A name=pragma_show_datatypes></A>
 | 
						||
  <LI>
 | 
						||
  <P><B>PRAGMA show_datatypes = ON; </B>(1)<B> <BR>PRAGMA show_datatypes = 
 | 
						||
  OFF;</B> (0)</P>
 | 
						||
  <P>When turned on, the SHOW_DATATYPES pragma causes extra entries containing 
 | 
						||
  the names of <A 
 | 
						||
  href="http://www.hwaci.com/sw/sqlite/datatypes.html">datatypes</A> of columns 
 | 
						||
  to be appended to the 4th ("columnNames") argument to <B>sqlite_exec()</B> 
 | 
						||
  callbacks. When turned off, the 4th argument to callbacks contains only the 
 | 
						||
  column names. The datatype for table columns is taken from the CREATE TABLE 
 | 
						||
  statement that defines the table. Columns with an unspecified datatype have a 
 | 
						||
  datatype of "NUMERIC" and the results of expression have a datatype of either 
 | 
						||
  "TEXT" or "NUMERIC" depending on the expression. The following chart 
 | 
						||
  illustrates the difference for the query "SELECT 'xyzzy', 5, NULL AS empty 
 | 
						||
  ":</P>
 | 
						||
  <BLOCKQUOTE>
 | 
						||
    <TABLE border=0>
 | 
						||
      <TBODY>
 | 
						||
      <TR>
 | 
						||
        <TH>show_datatypes=OFF</TH>
 | 
						||
        <TH width=30></TH>
 | 
						||
        <TH>show_datatypes=ON</TH></TR>
 | 
						||
      <TR>
 | 
						||
        <TD vAlign=top>azCol[0] = "xyzzy";<BR>azCol[1] = "5";<BR>azCol[2] = 
 | 
						||
          "empty";<BR>azCol[3] = 0; </TD>
 | 
						||
        <TD></TD>
 | 
						||
        <TD vAlign=top>azCol[0] = "xyzzy";<BR>azCol[1] = "5";<BR>azCol[2] = 
 | 
						||
          "empty";<BR>azCol[3] = "TEXT";<BR>azCol[4] = "NUMERIC";<BR>azCol[5] = 
 | 
						||
          "TEXT";<BR>azCol[6] = 0; </TD></TR></TBODY></TABLE></BLOCKQUOTE><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>
 | 
						||
  <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><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><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="http://www.hwaci.com/sw/sqlite/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>
 | 
						||
<HR>
 | 
						||
<A name=replace></A>
 | 
						||
<H1>REPLACE</H1>
 | 
						||
<TABLE cellPadding=10>
 | 
						||
  <TBODY>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right><I><FONT 
 | 
						||
      color=#ff3434>sql-statement</FONT></I> ::=</TD>
 | 
						||
    <TD><B><FONT color=#2c2cf0>REPLACE INTO </FONT></B>[<B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B><I><FONT 
 | 
						||
      color=#ff3434>database-name</FONT></I><B><FONT color=#2c2cf0> 
 | 
						||
      <BIG>.</BIG></FONT></B>]<B><FONT color=#2c2cf0> </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>table-name</FONT></I><B><FONT color=#2c2cf0> 
 | 
						||
      </FONT></B>[<B><FONT color=#2c2cf0><BIG>(</BIG> </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>column-list</FONT></I><B><FONT color=#2c2cf0> 
 | 
						||
      <BIG>)</BIG></FONT></B>]<B><FONT color=#2c2cf0> VALUES <BIG>(</BIG> 
 | 
						||
      </FONT></B><I><FONT color=#ff3434>value-list</FONT></I><B><FONT 
 | 
						||
      color=#2c2cf0> <BIG>)</BIG> </FONT></B><BIG>|</BIG><B><FONT 
 | 
						||
      color=#2c2cf0><BR>REPLACE INTO </FONT></B>[<B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B><I><FONT 
 | 
						||
      color=#ff3434>database-name</FONT></I><B><FONT color=#2c2cf0> 
 | 
						||
      <BIG>.</BIG></FONT></B>]<B><FONT color=#2c2cf0> </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>table-name</FONT></I><B><FONT color=#2c2cf0> 
 | 
						||
      </FONT></B>[<B><FONT color=#2c2cf0><BIG>(</BIG> </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>column-list</FONT></I><B><FONT color=#2c2cf0> 
 | 
						||
      <BIG>)</BIG></FONT></B>]<B><FONT color=#2c2cf0> </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>select-statement</FONT></I><B><FONT 
 | 
						||
    color=#2c2cf0></FONT></B></TD></TR></TBODY></TABLE>
 | 
						||
<P>The REPLACE command is an alias for the "INSERT OR REPLACE" variant of the <A 
 | 
						||
href="#insert">INSERT</A> command. This 
 | 
						||
alias is provided for compatibility with MySQL. See the <A 
 | 
						||
href="#insert">INSERT</A> command 
 | 
						||
documentation for additional information.</P>
 | 
						||
<HR>
 | 
						||
<A name=select></A>
 | 
						||
<H1>SELECT</H1>
 | 
						||
<TABLE cellPadding=10>
 | 
						||
  <TBODY>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right><I><FONT 
 | 
						||
      color=#ff3434>sql-statement</FONT></I> ::=</TD>
 | 
						||
    <TD><B><FONT color=#2c2cf0>SELECT </FONT></B>[<B><FONT color=#2c2cf0>ALL 
 | 
						||
      </FONT></B><BIG>|</BIG><B><FONT color=#2c2cf0> 
 | 
						||
      DISTINCT</FONT></B>]<B><FONT color=#2c2cf0> </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>result</FONT></I><B><FONT color=#2c2cf0> 
 | 
						||
      </FONT></B>[<B><FONT color=#2c2cf0>FROM </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>table-list</FONT></I><B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B>]<B><FONT color=#2c2cf0><BR></FONT></B>[<B><FONT 
 | 
						||
      color=#2c2cf0>WHERE </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>expr</FONT></I><B><FONT color=#2c2cf0></FONT></B>]<B><FONT 
 | 
						||
      color=#2c2cf0><BR></FONT></B>[<B><FONT color=#2c2cf0>GROUP BY 
 | 
						||
      </FONT></B><I><FONT color=#ff3434>expr-list</FONT></I><B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B>]<B><FONT color=#2c2cf0><BR></FONT></B>[<B><FONT 
 | 
						||
      color=#2c2cf0>HAVING </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>expr</FONT></I><B><FONT color=#2c2cf0></FONT></B>]<B><FONT 
 | 
						||
      color=#2c2cf0><BR></FONT></B>[<B><FONT color=#2c2cf0></FONT></B><I><FONT 
 | 
						||
      color=#ff3434>compound-op</FONT></I><B><FONT color=#2c2cf0> 
 | 
						||
      </FONT></B><I><FONT color=#ff3434>select</FONT></I><B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B>]<B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B><BIG>*</BIG><B><FONT 
 | 
						||
      color=#2c2cf0><BR></FONT></B>[<B><FONT color=#2c2cf0>ORDER BY 
 | 
						||
      </FONT></B><I><FONT color=#ff3434>sort-expr-list</FONT></I><B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B>]<B><FONT color=#2c2cf0><BR></FONT></B>[<B><FONT 
 | 
						||
      color=#2c2cf0>LIMIT </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>integer</FONT></I><B><FONT color=#2c2cf0> 
 | 
						||
      </FONT></B>[<B><FONT color=#2c2cf0></FONT></B>(<B><FONT color=#2c2cf0> 
 | 
						||
      OFFSET </FONT></B><BIG>|</BIG><B><FONT color=#2c2cf0> <BIG>,</BIG> 
 | 
						||
      </FONT></B>)<B><FONT color=#2c2cf0> </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>integer</FONT></I><B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B>]<B><FONT color=#2c2cf0></FONT></B>]<B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B></TD></TR>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right><I><FONT 
 | 
						||
      color=#ff3434>result</FONT></I> ::=</TD>
 | 
						||
    <TD><B><FONT color=#2c2cf0></FONT></B><I><FONT 
 | 
						||
      color=#ff3434>result-column</FONT></I><B><FONT color=#2c2cf0> 
 | 
						||
      </FONT></B>[<B><FONT color=#2c2cf0><BIG>,</BIG> </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>result-column</FONT></I><B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B>]<B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B><BIG>*</BIG><B><FONT 
 | 
						||
  color=#2c2cf0></FONT></B></TD></TR>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right><I><FONT 
 | 
						||
      color=#ff3434>result-column</FONT></I> ::=</TD>
 | 
						||
    <TD><B><FONT color=#2c2cf0><BIG>*</BIG> </FONT></B><BIG>|</BIG><B><FONT 
 | 
						||
      color=#2c2cf0> </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>table-name</FONT></I><B><FONT color=#2c2cf0> <BIG>.</BIG> 
 | 
						||
      <BIG>*</BIG> </FONT></B><BIG>|</BIG><B><FONT color=#2c2cf0> 
 | 
						||
      </FONT></B><I><FONT color=#ff3434>expr</FONT></I><B><FONT color=#2c2cf0> 
 | 
						||
      </FONT></B>[<B><FONT color=#2c2cf0> </FONT></B>[<B><FONT 
 | 
						||
      color=#2c2cf0>AS</FONT></B>]<B><FONT color=#2c2cf0> </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>string</FONT></I><B><FONT color=#2c2cf0> 
 | 
						||
      </FONT></B>]<B><FONT color=#2c2cf0></FONT></B></TD></TR>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right><I><FONT 
 | 
						||
      color=#ff3434>table-list</FONT></I> ::=</TD>
 | 
						||
    <TD><B><FONT color=#2c2cf0></FONT></B><I><FONT 
 | 
						||
      color=#ff3434>table</FONT></I><B><FONT color=#2c2cf0> </FONT></B>[<B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B><I><FONT color=#ff3434>join-op</FONT></I><B><FONT 
 | 
						||
      color=#2c2cf0> </FONT></B><I><FONT color=#ff3434>table</FONT></I><B><FONT 
 | 
						||
      color=#2c2cf0> </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>join-args</FONT></I><B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B>]<B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B><BIG>*</BIG><B><FONT 
 | 
						||
  color=#2c2cf0></FONT></B></TD></TR>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right><I><FONT 
 | 
						||
    color=#ff3434>table</FONT></I> ::=</TD>
 | 
						||
    <TD><B><FONT color=#2c2cf0></FONT></B><I><FONT 
 | 
						||
      color=#ff3434>table-name</FONT></I><B><FONT color=#2c2cf0> 
 | 
						||
      </FONT></B>[<B><FONT color=#2c2cf0>AS </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>alias</FONT></I><B><FONT color=#2c2cf0></FONT></B>]<B><FONT 
 | 
						||
      color=#2c2cf0> </FONT></B><BIG>|</BIG><B><FONT 
 | 
						||
      color=#2c2cf0><BR><BIG>(</BIG> </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>select</FONT></I><B><FONT color=#2c2cf0> <BIG>)</BIG> 
 | 
						||
      </FONT></B>[<B><FONT color=#2c2cf0>AS </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>alias</FONT></I><B><FONT color=#2c2cf0></FONT></B>]<B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B></TD></TR>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right><I><FONT 
 | 
						||
      color=#ff3434>join-op</FONT></I> ::=</TD>
 | 
						||
    <TD><B><FONT color=#2c2cf0><BIG>,</BIG> </FONT></B><BIG>|</BIG><B><FONT 
 | 
						||
      color=#2c2cf0> </FONT></B>[<B><FONT 
 | 
						||
      color=#2c2cf0>NATURAL</FONT></B>]<B><FONT color=#2c2cf0> 
 | 
						||
      </FONT></B>[<B><FONT color=#2c2cf0>LEFT </FONT></B><BIG>|</BIG><B><FONT 
 | 
						||
      color=#2c2cf0> RIGHT </FONT></B><BIG>|</BIG><B><FONT color=#2c2cf0> 
 | 
						||
      FULL</FONT></B>]<B><FONT color=#2c2cf0> </FONT></B>[<B><FONT 
 | 
						||
      color=#2c2cf0>OUTER </FONT></B><BIG>|</BIG><B><FONT color=#2c2cf0> INNER 
 | 
						||
      </FONT></B><BIG>|</BIG><B><FONT color=#2c2cf0> CROSS</FONT></B>]<B><FONT 
 | 
						||
      color=#2c2cf0> JOIN</FONT></B></TD></TR>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right><I><FONT 
 | 
						||
      color=#ff3434>join-args</FONT></I> ::=</TD>
 | 
						||
    <TD><B><FONT color=#2c2cf0></FONT></B>[<B><FONT color=#2c2cf0>ON 
 | 
						||
      </FONT></B><I><FONT color=#ff3434>expr</FONT></I><B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B>]<B><FONT color=#2c2cf0> </FONT></B>[<B><FONT 
 | 
						||
      color=#2c2cf0>USING <BIG>(</BIG> </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>id-list</FONT></I><B><FONT color=#2c2cf0> 
 | 
						||
      <BIG>)</BIG></FONT></B>]<B><FONT color=#2c2cf0></FONT></B></TD></TR>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right><I><FONT 
 | 
						||
      color=#ff3434>sort-expr-list</FONT></I> ::=</TD>
 | 
						||
    <TD><B><FONT color=#2c2cf0></FONT></B><I><FONT 
 | 
						||
      color=#ff3434>expr</FONT></I><B><FONT color=#2c2cf0> </FONT></B>[<B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B><I><FONT 
 | 
						||
      color=#ff3434>sort-order</FONT></I><B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B>]<B><FONT color=#2c2cf0> </FONT></B>[<B><FONT 
 | 
						||
      color=#2c2cf0><BIG>,</BIG> </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>expr</FONT></I><B><FONT color=#2c2cf0> </FONT></B>[<B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B><I><FONT 
 | 
						||
      color=#ff3434>sort-order</FONT></I><B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B>]<B><FONT color=#2c2cf0></FONT></B>]<B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B><BIG>*</BIG><B><FONT 
 | 
						||
  color=#2c2cf0></FONT></B></TD></TR>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right><I><FONT 
 | 
						||
      color=#ff3434>sort-order</FONT></I> ::=</TD>
 | 
						||
    <TD><B><FONT color=#2c2cf0>ASC </FONT></B><BIG>|</BIG><B><FONT 
 | 
						||
      color=#2c2cf0> DESC</FONT></B></TD></TR>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right><I><FONT 
 | 
						||
      color=#ff3434>compound_op</FONT></I> ::=</TD>
 | 
						||
    <TD><B><FONT color=#2c2cf0>UNION </FONT></B><BIG>|</BIG><B><FONT 
 | 
						||
      color=#2c2cf0> UNION ALL </FONT></B><BIG>|</BIG><B><FONT color=#2c2cf0> 
 | 
						||
      INTERSECT </FONT></B><BIG>|</BIG><B><FONT color=#2c2cf0> 
 | 
						||
    EXCEPT</FONT></B></TD></TR></TBODY></TABLE>
 | 
						||
<P>The SELECT statement is used to query the database. The result of a SELECT is 
 | 
						||
zero or more rows of data where each row has a fixed number of columns. The 
 | 
						||
number of columns in the result is specified by the expression list in between 
 | 
						||
the SELECT and FROM keywords. Any arbitrary expression can be used as a result. 
 | 
						||
If a result expression is <FONT color=#2c2cf0><BIG>*</BIG></FONT> then all 
 | 
						||
columns of all tables are substituted for that one expression. If the expression 
 | 
						||
is the name of a table followed by <FONT color=#2c2cf0><BIG>.*</BIG></FONT> then 
 | 
						||
the result is all columns 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. The full SQL-92 join syntax can 
 | 
						||
also be used to specify joins. A sub-query in parentheses may be substituted for 
 | 
						||
any table name in the FROM clause. The entire FROM clause may be omitted, in 
 | 
						||
which case the result is a single row consisting of the values of the expression 
 | 
						||
list. </P>
 | 
						||
<P>The WHERE clause can be used to limit the number of rows over which the query 
 | 
						||
operates.</P>
 | 
						||
<P>The GROUP BY clauses causes one or more rows of the result to be combined 
 | 
						||
into a single row of output. This is especially useful when the result contains 
 | 
						||
aggregate functions. The expressions in the GROUP BY clause do <EM>not</EM> have 
 | 
						||
to be expressions that appear in the result. The HAVING clause is similar to 
 | 
						||
WHERE except that HAVING applies after grouping has occurred. The HAVING 
 | 
						||
expression may refer to values, even aggregate functions, that are not in the 
 | 
						||
result.</P>
 | 
						||
<P>The ORDER BY clause causes the output rows to be sorted. The argument to 
 | 
						||
ORDER BY is a list of expressions that are used as the key for the sort. The 
 | 
						||
expressions do not have to be part of the result for a simple SELECT, but in a 
 | 
						||
compound SELECT each sort expression must exactly match one of the result 
 | 
						||
columns. Each sort expression may be optionally followed by ASC or DESC to 
 | 
						||
specify the sort order.</P>
 | 
						||
<P>The LIMIT clause places an upper bound on the number of rows returned in the 
 | 
						||
result. A negative LIMIT indicates no upper bound. The optional OFFSET following 
 | 
						||
LIMIT specifies how many rows to skip at the beginning of the result set. In a 
 | 
						||
compound query, the LIMIT clause may only appear on the final SELECT statement. 
 | 
						||
The limit is applied to the entire query not to the individual SELECT statement 
 | 
						||
to which it is attached. </P>
 | 
						||
<P>A compound SELECT is formed from two or more simple SELECTs connected by one 
 | 
						||
of the operators UNION, UNION ALL, INTERSECT, or EXCEPT. In a compound SELECT, 
 | 
						||
all the constituent SELECTs must specify the same number of result columns. 
 | 
						||
There may be only a single ORDER BY clause at the end of the compound SELECT. 
 | 
						||
The UNION and UNION ALL operators combine the results of the SELECTs to the 
 | 
						||
right and left into a single big table. The difference is that in UNION all 
 | 
						||
result rows are distinct where in UNION ALL there may be duplicates. The 
 | 
						||
INTERSECT operator takes the intersection of the results of the left and right 
 | 
						||
SELECTs. EXCEPT takes the result of left SELECT after removing the results of 
 | 
						||
the right SELECT. When three are more SELECTs are connected into a compound, 
 | 
						||
they group from left to right.</P>
 | 
						||
<HR>
 | 
						||
<A name=update></A>
 | 
						||
<H1>UPDATE</H1>
 | 
						||
<TABLE cellPadding=10>
 | 
						||
  <TBODY>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right><I><FONT 
 | 
						||
      color=#ff3434>sql-statement</FONT></I> ::=</TD>
 | 
						||
    <TD><B><FONT color=#2c2cf0>UPDATE </FONT></B>[<B><FONT color=#2c2cf0> OR 
 | 
						||
      </FONT></B><I><FONT color=#ff3434>conflict-algorithm</FONT></I><B><FONT 
 | 
						||
      color=#2c2cf0> </FONT></B>]<B><FONT color=#2c2cf0> </FONT></B>[<B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B><I><FONT 
 | 
						||
      color=#ff3434>database-name</FONT></I><B><FONT color=#2c2cf0> 
 | 
						||
      <BIG>.</BIG></FONT></B>]<B><FONT color=#2c2cf0> </FONT></B><I><FONT 
 | 
						||
      color=#ff3434>table-name</FONT></I><B><FONT color=#2c2cf0><BR>SET 
 | 
						||
      </FONT></B><I><FONT color=#ff3434>assignment</FONT></I><B><FONT 
 | 
						||
      color=#2c2cf0> </FONT></B>[<B><FONT color=#2c2cf0><BIG>,</BIG> 
 | 
						||
      </FONT></B><I><FONT color=#ff3434>assignment</FONT></I><B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B>]<B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B><BIG>*</BIG><B><FONT 
 | 
						||
      color=#2c2cf0><BR></FONT></B>[<B><FONT color=#2c2cf0>WHERE 
 | 
						||
      </FONT></B><I><FONT color=#ff3434>expr</FONT></I><B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B>]<B><FONT color=#2c2cf0></FONT></B></TD></TR>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right><I><FONT 
 | 
						||
      color=#ff3434>assignment</FONT></I> ::=</TD>
 | 
						||
    <TD><B><FONT color=#2c2cf0></FONT></B><I><FONT 
 | 
						||
      color=#ff3434>column-name</FONT></I><B><FONT color=#2c2cf0> <BIG>=</BIG> 
 | 
						||
      </FONT></B><I><FONT color=#ff3434>expr</FONT></I><B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B></TD></TR></TBODY></TABLE>
 | 
						||
<P>The UPDATE statement is used to change the value of columns in selected rows 
 | 
						||
of a table. Each assignment in an UPDATE specifies a column name to the left of 
 | 
						||
the equals sign and an arbitrary expression to the right. The expressions may 
 | 
						||
use the values of other columns. All expressions are evaluated before any 
 | 
						||
assignments are made. A WHERE clause can be used to restrict which rows are 
 | 
						||
updated.</P>
 | 
						||
<P>The optional conflict-clause allows the specification of an alternative 
 | 
						||
constraint conflict resolution algorithm to use during this one command. See the 
 | 
						||
section titled <A href="#conflict">ON 
 | 
						||
CONFLICT</A> for additional information.</P>
 | 
						||
<HR>
 | 
						||
<A name=vacuum></A>
 | 
						||
<H1>VACUUM</H1>
 | 
						||
<TABLE cellPadding=10>
 | 
						||
  <TBODY>
 | 
						||
  <TR>
 | 
						||
    <TD vAlign=top align=right><I><FONT 
 | 
						||
      color=#ff3434>sql-statement</FONT></I> ::=</TD>
 | 
						||
    <TD><B><FONT color=#2c2cf0>VACUUM </FONT></B>[<B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B><I><FONT 
 | 
						||
      color=#ff3434>index-or-table-name</FONT></I><B><FONT 
 | 
						||
      color=#2c2cf0></FONT></B>]<B><FONT 
 | 
						||
color=#2c2cf0></FONT></B></TD></TR></TBODY></TABLE>
 | 
						||
<P>The VACUUM command is an SQLite extension modelled after a similar command 
 | 
						||
found in PostgreSQL. If VACUUM is invoked with the name of a table or index then 
 | 
						||
it is suppose to clean up the named table or index. In version 1.0 of SQLite, 
 | 
						||
the VACUUM command would invoke <B>gdbm_reorganize()</B> to clean up the backend 
 | 
						||
database file.</P>
 | 
						||
<P>VACUUM became a no-op when the GDBM backend was removed from SQLITE in 
 | 
						||
version 2.0.0. VACUUM was reimplimented in version 2.8.1. The index or table 
 | 
						||
name argument is now ignored. </P>
 | 
						||
<P>When an object (table, index, or trigger) is dropped from the database, it 
 | 
						||
leaves behind empty space. This makes the database file larger than it needs to 
 | 
						||
be, but can speed up inserts. In time inserts and deletes can leave the database 
 | 
						||
file structure fragmented, which slows down disk access to the database 
 | 
						||
contents. The VACUUM command cleans the database by copying its contents to a 
 | 
						||
temporary database file and reloading the original database file from the copy. 
 | 
						||
This eliminates free pages, aligns table data to be contiguous, and otherwise 
 | 
						||
cleans up the database file structure.</P>
 | 
						||
<P>This command will fail if there is an active transaction. This command has no 
 | 
						||
effect on an in-memory database.</P>
 | 
						||
<HR>
 | 
						||
<A name=keywords></A>
 | 
						||
<H1>SQLite keywords</H1>
 | 
						||
<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. Keywords are not 
 | 
						||
reserved in SQLite. Any keyword can be used as an identifier for SQLite objects 
 | 
						||
(columns, databases, indexes, tables, triggers, views, ...) but must generally 
 | 
						||
be enclosed by brackets or quotes to avoid confusing the parser. Keyword 
 | 
						||
matching in SQLite is case-insensitive.</P>
 | 
						||
<P>Keywords can be used as identifiers in three ways:</P>
 | 
						||
<TABLE>
 | 
						||
  <TBODY>
 | 
						||
  <TR>
 | 
						||
    <TD width="12%">'keyword' 
 | 
						||
    <TD>Interpreted as a literal string if it occurs in a legal string 
 | 
						||
      context, otherwise as an identifier. 
 | 
						||
  <TR>
 | 
						||
    <TD>"keyword" 
 | 
						||
    <TD>Interpreted as an identifier if it matches a known identifier and 
 | 
						||
      occurs in a legal identifier context, otherwise as a string. 
 | 
						||
  <TR>
 | 
						||
    <TD>[keyword] 
 | 
						||
    <TD>Always interpreted as an identifer. (This notation is used by MS 
 | 
						||
      Access and SQL Server.) </TR></TBODY></TABLE>
 | 
						||
<H2>Fallback Keywords</H2>
 | 
						||
<P>These keywords can be used as identifiers for SQLite objects without 
 | 
						||
delimiters.</P>
 | 
						||
<P><I>ABORT</I>    AFTER    ASC    <I>ATTACH</I> 
 | 
						||
   BEFORE    BEGIN    DEFERRED    
 | 
						||
CASCADE    <I>CLUSTER</I>    <I>CONFLICT</I>    
 | 
						||
<I>COPY</I>    CROSS    <I>DATABASE</I>    
 | 
						||
<I>DELIMITERS</I>    DESC    <I>DETACH</I>    EACH 
 | 
						||
   END    <I>EXPLAIN</I>    <I>FAIL</I> 
 | 
						||
   FOR    FULL    IGNORE    IMMEDIATE 
 | 
						||
   INITIALLY    INNER    <I>INSTEAD</I> 
 | 
						||
   KEY    LEFT    MATCH    NATURAL 
 | 
						||
   OF    <I>OFFSET</I>    OUTER    
 | 
						||
<I>PRAGMA</I>    <I>RAISE</I>    <I>REPLACE</I>    
 | 
						||
RESTRICT    RIGHT    <I>ROW</I>    
 | 
						||
<I>STATEMENT</I>    <I>TEMP</I>    TEMPORARY    
 | 
						||
TRIGGER    <I>VACUUM</I>    VIEW    </P>
 | 
						||
<H2>Normal keywords</H2>
 | 
						||
<P>These keywords can be used as identifiers for SQLite objects, but must be 
 | 
						||
enclosed in brackets or quotes for SQLite to recognize them as an 
 | 
						||
identifier.</P>
 | 
						||
<P>ALL    AND    AS    BETWEEN    BY 
 | 
						||
   CASE    CHECK    COLLATE    COMMIT 
 | 
						||
   CONSTRAINT    CREATE    DEFAULT    
 | 
						||
DEFERRABLE    DELETE    DISTINCT    DROP 
 | 
						||
   ELSE    EXCEPT    FOREIGN    FROM 
 | 
						||
   <I>GLOB</I>    GROUP    HAVING    IN 
 | 
						||
   <I>INDEX</I>    INSERT    INTERSECT 
 | 
						||
   INTO    IS    <I>ISNULL</I>    JOIN 
 | 
						||
   LIKE    LIMIT    NOT    
 | 
						||
<I>NOTNULL</I>    NULL    ON    OR    
 | 
						||
ORDER    PRIMARY    REFERENCES    ROLLBACK 
 | 
						||
   SELECT    SET    TABLE    THEN 
 | 
						||
   TRANSACTION    UNION    UNIQUE    
 | 
						||
UPDATE    USING    VALUES    WHEN    
 | 
						||
WHERE    </P>
 | 
						||
<H2>Special words</H2>
 | 
						||
<P>The following are not keywords in SQLite, but are used as names of system 
 | 
						||
objects. They can be used as an identifier for a different type of object.</P>
 | 
						||
<P><I>_ROWID_</I>    <I>MAIN</I>    OID    
 | 
						||
<I>ROWID</I>    <I>SQLITE_MASTER</I>    
 | 
						||
<I>SQLITE_TEMP_MASTER</I>    </P>
 | 
						||
<P>
 | 
						||
<HR>
 | 
						||
 | 
						||
</BODY></HTML>
 |