⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 syntax.html

📁 sqlite的帮助文档
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html><head><title>SQLite SQL Language Syntax Requirements</title><style type="text/css">body {    margin: auto;    font-family: "Verdana" "sans-serif";    padding: 8px 1%;}a { color: #45735f }a:visited { color: #734559 }.logo { position:absolute; margin:3px; }.tagline {  float:right;  text-align:right;  font-style:italic;  width:240px;  margin:12px;  margin-top:58px;}.toolbar {  font-variant: small-caps;  text-align: center;  line-height: 1.6em;  margin: 0;  padding:1px 8px;}.toolbar a { color: white; text-decoration: none; padding: 6px 12px; }.toolbar a:visited { color: white; }.toolbar a:hover { color: #80a796; background: white; }.content    { margin: 5%; }.content dt { font-weight:bold; }.content dd { margin-bottom: 25px; margin-left:20%; }.content ul { padding:0px; padding-left: 15px; margin:0px; }/* rounded corners */.se  { background: url(images/se.png) 100% 100% no-repeat #80a796}.sw  { background: url(images/sw.png) 0% 100% no-repeat }.ne  { background: url(images/ne.png) 100% 0% no-repeat }.nw  { background: url(images/nw.png) 0% 0% no-repeat }</style><meta http-equiv="content-type" content="text/html; charset=UTF-8">  </head><body><div><!-- container div to satisfy validator --><a href="index.html"><img class="logo" src="images/SQLite.gif" alt="SQLite Logo" border="0"></a><div><!-- IE hack to prevent disappearing logo--></div><div class="tagline">Small. Fast. Reliable.<br>Choose any three.</div><table width=100% style="clear:both"><tr><td>  <div class="se"><div class="sw"><div class="ne"><div class="nw">  <div class="toolbar">    <a href="about.html">About</a>    <a href="sitemap.html">Sitemap</a>    <a href="docs.html">Documentation</a>    <a href="download.html">Download</a>    <a href="copyright.html">License</a>    <a href="news.html">News</a>    <a href="http://www.sqlite.org/cvstrac/index">Developers</a>    <a href="support.html">Support</a>  </div></div></div></div></div></td></tr></table>  <h1>SQLite Language Syntax Requirements</h1><p>These requirements make the distinction between "preparing" anSQL statement and "evaluating" or "invoking" an SQL statement.Preparation means that the SQL statement text is translated intoan internal binary representation that is more suitable for processing.Evaluation or invocation means that the processing is actually carried out.Preparation of an SQL statement is usually accomplished by interfaces<a href="c3ref/prepare.html">sqlite3_prepare()</a>, <a href="c3ref/prepare.html">sqlite3_prepare16()</a>, or <a href="c3ref/prepare.html">sqlite3_prepare_v2()</a> andevaluation or invocation of an SQLite statement is accomplished bycalling <a href="c3ref/step.html">sqlite3_step()</a>.  However, if a statement is initiallyprepared using <a href="c3ref/prepare.html">sqlite3_prepare_v2()</a> and a change to the databaseschema is detected during evaluation, then the preparation is redoneautomatically, by <a href="c3ref/step.html">sqlite3_step()</a>.  So even though it is reasonableto think about preparation as being a function of <a href="c3ref/prepare.html">sqlite3_prepare_v2()</a>and its companions and evaluation as being a function of<a href="c3ref/step.html">sqlite3_step()</a>, the reader should keep in mind that<a href="c3ref/step.html">sqlite3_step()</a> might also sometimes do preparations followingschema changes.</p><h2>1.0 General Requirements</h2><h3>1.1 Parser operation</h3><a name="H42000"></a><p>  SQLite expects all statements to be terminated by a semicolon.  If a statement is submitted to SQLite that does not end in a  semicolon, then a semicolon is added automatically by the tokenizer.  (See <a href="tokenreq.html#H41040">H41040</a>.)</p><blockquote><b>H42000:</b>  The SQLite parser shall accept SQL statements consisting of an SQL command  followed by a semicolon.<blockquote><pre>sql_statement ::= cmd SEMI.</pre></blockquote></b></blockquote><a name="H42002"></a><p>  Acceptance by the parser does not imply that the SQL statement  will be accepted by SQLite.  SQL statements may be rejected by other  parts of the SQLite library.  Acceptance by the parser is a necessary  but not a sufficient condition for the statement to work.</p><blockquote><b>H42002:</b>  The preparation of an SQL statement that is not accepted by  the SQLite parser shall fail with an error.</b></blockquote><a name="H42004"></a><p>  SQLite ignores case when comparing ASCII characters in identifiers and  in type names.  (The rules for comparison of content are different.)  Case is considered for other unicode characters, however.  Hence, SQLite considers identifiers "A" and "a" to be equivalent but  "&Aring;" and "&aring;" are distinct.</p><blockquote><b>H42004:</b>  SQLite shall use the built-in NOCASE collating sequence when comparing  identifiers and datatype names within SQL statements during   statement preparation.</b></blockquote><a name="H42008"></a><p>  Many tokens are allowed to "fallback" to the ID token.  The SQL  language has many keywords.  The fallback token feature provides  robustness in the case where a seldom-used keyword is accidentally  used as the name of a table or column.</p><blockquote><b>H42008:</b>  A token received by the parser shall be converted into an ID token  if the original token value would have resulted in a syntax error,  a token value of ID will allow the parse to continue,  and if the original token value was one of:     ABORT     AFTER     ANALYZE     ASC     ATTACH     BEFORE     BEGIN     CASCADE     CAST     CONFLICT     CTIME_KW     DATABASE     DEFERRED     DESC     DETACH     EACH     END     EXCEPT     EXCLUSIVE     EXPLAIN     FAIL     FOR     IF     IGNORE     IMMEDIATE     INITIALLY     INSTEAD     INTERSECT     KEY     LIKE_KW     MATCH     OF     OFFSET     PLAN     PRAGMA     QUERY     RAISE     REINDEX     RENAME     REPLACE     RESTRICT     ROW     TEMP     TRIGGER     UNION     VACUUM     VIEW     VIRTUAL</b></blockquote><a name="H42012"></a><p>  A second level of fallback allows any token to be converted into  the token ANY.  The ANY token is used to gather arbitrary delimited  token sequences, such as used as the arguments to the CREATE VIRTUAL  TABLE command.</p><blockquote><b>H42012:</b>  A token received by the parser shall be converted into an ANY token  if the original token value would have resulted in a syntax error  and if a token value of ANY will allow the parse to continue.</b></blockquote><h3>1.2 Name Contexts</h3><p>Expressions in SQL statements often contain identifiers that referto columns in tables or views or to columns in the result set of a SELECT statement.The process of determining which column an identifier refers tois called "name resolution".</p><p>Names are resolved with the aid of a "name context".A name context is a set of tables and views and result set expressionsto which an expression identifier can refer.  A single name contextis a hierarchy of "name context layers".  Subqueries have their ownname context layer (called the "inner layer") that is distinct from thename context layer (called the "outer layer") associated with the overall statement.  In an SQL statement with multiple levels of tested subqueries,there can be multiple name context layers in the name context.  Inother words, a complete name context is an ordered list of namecontext layers.</p><p>Within a name context a "source" is a table or view containing columnsthat expression names can match against.  Every source has a "canonicalname" which is the name of the table or view as it appears in the schema.A source might also have an "aliased name" resulting from an AS clause.The "source name" is the aliased name if it exists, otherwise the sourcename is the canonical name.</p><p>Each name context layer has a "source set" and a "result set",either or both of which can be empty.  The source set is an ordered setof sources.  The result set is an ordered set of expressions withan optional alias on each expression.  Roughly speaking, a source setcorresponds to the FROM clause of a SELECT statement and the result setcorresponds to the list of expressions that form the result set of theSELECT statement.</p><p>A "empty name context" is a name context comprised of a singlename context layer in which both the source set and the result set areempty.</p><h2>2.0 Transaction Control</h2><h3>2.1 BEGIN</h3><a name="H42010"></a><blockquote><b>H42010:</b>  The SQLite parser shall accept BEGIN statements  that conform to the following syntax:<blockquote><pre>cmd ::= BEGIN transaction_type transaction_name.transaction_type ::= .transaction_type ::= DEFERRED.transaction_type ::= IMMEDIATE.transaction_type ::= EXCLUSIVE.transaction_name ::= .transaction_name ::= TRANSACTION.transaction_name ::= TRANSACTION name.</pre></blockquote></b></blockquote><a name="H42013"></a><blockquote><b>H42013:</b>  The successful evaluation of a BEGIN statement shall  cause the <a href="c3ref/sqlite3.html">database connection</a> to exit autocommit mode.</b></blockquote><a name="H42016"></a><blockquote><b>H42016:</b>  The evaluation of a BEGIN TRANSACTION statement shall fail with an error  if the <a href="c3ref/sqlite3.html">database connection</a> is not in autocommit mode at the  start of evaluation.</b></blockquote><a name="H42019"></a><blockquote><b>H42019:</b>  If the <i>transaction_type</i> keyword is omitted from a  BEGIN TRANSACTION statement then the behavior shall be the same  as if the DEFERRED keyword were used.</b></blockquote><a name="H42022"></a><blockquote><b>H42022:</b>  When the DEFERRED keyword appears in a BEGIN statement  the locking state of the underlying database files shall be  the same before and after the statement is evaluated.</b></blockquote><a name="H42025"></a><blockquote><b>H42025:</b>  When the IMMEDIATE keyword appears in a BEGIN statement  then successful evaluation of the statement shall cause a RESERVED  lock to be obtained for all underlying database files.</b></blockquote><a name="H42028"></a><blockquote><b>H42028:</b>  When the EXCLUSIVE keyword appears in a BEGIN statement  then successful evaluation of the statement shall cause a EXCLUSIVE   lock to be obtained for all underlying database files.</b></blockquote><p>The <i>transaction_name</i> clause of a BEGIN statement isprovided for syntactic compatibility to other SQL database engines.The <i>transaction_name</i> clause is silently ignored.</p><h3>2.2 COMMIT</h3><a name="H42110"></a><blockquote><b>H42110:</b>  SQLite shall accept the following COMMIT statement syntax:<blockquote><pre>cmd ::= COMMIT transaction_name.cmd ::= END transaction_name.</pre></blockquote></b></blockquote><a name="H42113"></a><blockquote><b>H42113:</b>  The successful evaluation of COMMIT statement places the  <a href="c3ref/sqlite3.html">database connection</a> in autocommit mode.</b></blockquote><a name="H42116"></a><blockquote><b>H42116:</b>  If a <a href="c3ref/sqlite3.html">database connection</a> is already in autocommit mode when  a COMMIT statement is evaluated, then the statement shall fail  with an error.</b></blockquote><p>The <i>transaction_name</i> clause of a COMMIT statement isprovided for syntactic compatibility to other SQL database engines.The <i>transaction_name</i> clause is silently ignored.</p><p>The COMMIT and END statements are aliases for one another andaccomplish exactly the same thing.  One is merely a different wayof expression the other.</p><h3>2.3 ROLLBACK</h3><a name="H42210"></a><blockquote><b>H42210:</b>  The SQLite parser shall accept ROLLBACK statements  that conform to the following syntax:<blockquote><pre>cmd ::= ROLLBACK transaction_name.</pre></blockquote></b></blockquote><a name="H42213"></a><blockquote><b>H42213:</b>  The successful evaluation of ROLLBACK statement places the  <a href="c3ref/sqlite3.html">database connection</a> in autocommit mode.</b></blockquote><a name="H42216"></a><blockquote><b>H42216:</b>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -