lang_keywords.html 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  2. <html><head>
  3. <title>SQLite Query Language: SQLite Keywords</title>
  4. <style type="text/css">
  5. body {
  6. margin: auto;
  7. font-family: Verdana, sans-serif;
  8. padding: 8px 1%;
  9. }
  10. a { color: #45735f }
  11. a:visited { color: #734559 }
  12. .logo { position:absolute; margin:3px; }
  13. .tagline {
  14. float:right;
  15. text-align:right;
  16. font-style:italic;
  17. width:240px;
  18. margin:12px;
  19. margin-top:58px;
  20. }
  21. .toolbar {
  22. font-variant: small-caps;
  23. text-align: center;
  24. line-height: 1.6em;
  25. margin: 0;
  26. padding:1px 8px;
  27. }
  28. .toolbar a { color: white; text-decoration: none; padding: 6px 12px; }
  29. .toolbar a:visited { color: white; }
  30. .toolbar a:hover { color: #80a796; background: white; }
  31. .content { margin: 5%; }
  32. .content dt { font-weight:bold; }
  33. .content dd { margin-bottom: 25px; margin-left:20%; }
  34. .content ul { padding:0px; padding-left: 15px; margin:0px; }
  35. /* rounded corners */
  36. .se { background: url(images/se.png) 100% 100% no-repeat #80a796}
  37. .sw { background: url(images/sw.png) 0% 100% no-repeat }
  38. .ne { background: url(images/ne.png) 100% 0% no-repeat }
  39. .nw { background: url(images/nw.png) 0% 0% no-repeat }
  40. </style>
  41. <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  42. </head>
  43. <body>
  44. <div><!-- container div to satisfy validator -->
  45. <a href="lang.html">
  46. <h2 align="center">SQL As Understood By SQLite</h2></a><h1>SQLite Keywords</h1></DIV>
  47. <p>The SQL standard specifies a huge number of keywords which may not
  48. be used as the names of tables, indices, columns, databases, user-defined
  49. functions, collations, virtual table modules, or any other named object.
  50. The list of keywords is so long that few people can remember them all.
  51. For most SQL code, your safest bet is to never use any English language
  52. word as the name of a user-defined object.</p>
  53. <p>If you want to use a keyword as a name, you need to quote it. There
  54. are three ways of quoting keywords in SQLite:</p>
  55. <p>
  56. <blockquote>
  57. <table>
  58. <tr> <td valign="top"><b>'keyword'</b></td><td width="20"></td>
  59. <td>A keyword in single quotes is a string literal.</td></tr>
  60. <tr> <td valign="top"><b>"keyword"</b></td><td></td>
  61. <td>A keyword in double-quotes is an identifier</td></tr>
  62. <tr> <td valign="top"><b>&#91;keyword&#93;</b></td><td></td>
  63. <td>A keyword enclosed in square brackets is
  64. an identifier. This is not standard SQL. This quoting mechanism
  65. is used by MS Access and SQL Server and is included in SQLite for
  66. compatibility.</td></tr>
  67. <tr> <td valign="top"><b>&#96;keyword&#96;</b></td><td></td>
  68. <td>A keyword enclosed in grave accents (ASCII code 96) is
  69. an identifier. This is not standard SQL. This quoting mechanism
  70. is used by MySQL and is included in SQLite for
  71. compatibility.</td></tr>
  72. </table>
  73. </blockquote>
  74. </p>
  75. <p>For resilience when confronted with historical SQL statements, SQLite
  76. will sometimes bend the quoting rules above:</p>
  77. <ul>
  78. <li><p>If a keyword in single
  79. quotes (ex: <b>'key'</b> or <b>'glob'</b>) is used in a context where
  80. an identifier is allowed but where a string literal is not allowed, then
  81. the token is understood to be an identifier instead of a string literal.
  82. </p></li>
  83. <li><p>If a keyword in double
  84. quotes (ex: <b>"key"</b> or <b>"glob"</b>) is used in a context where
  85. it cannot be resolved to an identifier but where a string literal
  86. is allowed, then the token is understood to be a string literal instead
  87. of an identifer.</p></li>
  88. </ul>
  89. <p>Programmers are cautioned not to use the two exceptions described in
  90. the previous bullets. We emphasize that they exist only so that old
  91. and ill-formed SQL statements will run correctly. Future versions of
  92. SQLite might change to raise errors instead of accepting the malformed
  93. statements covered by the exceptions above.</p>
  94. <p>SQLite is extended to allow many keywords to be used unquoted
  95. as the names of databases, tables, indices, triggers, views, columns,
  96. user-defined functions, collations, attached databases, and virtual
  97. function modules.
  98. In the list of keywords that follows, those that can be used as identifiers
  99. are shown in an italic font. Keywords that must be quoted in order to be
  100. used as identifiers are shown in bold.</p>
  101. <p>
  102. SQLite adds new keywords from time to time when it takes on new features.
  103. So to prevent your code from being broken by future enhancements, you should
  104. normally quote any identifier that is an English language word, even if
  105. you do not have to.
  106. </p>
  107. <p>
  108. The following are the keywords currently recognized by SQLite:
  109. </p>
  110. <blockquote>
  111. <table width="100%" class="pdf_keywords">
  112. <tr>
  113. <td align="left" valign="top" width="20%">
  114. <i>ABORT</i><br><b>ADD</b><br><i>AFTER</i><br><b>ALL</b><br><b>ALTER</b><br><i>ANALYZE</i><br><b>AND</b><br><b>AS</b><br><i>ASC</i><br><i>ATTACH</i><br><b>AUTOINCREMENT</b><br><i>BEFORE</i><br><i>BEGIN</i><br><b>BETWEEN</b><br><i>BY</i><br><i>CASCADE</i><br><b>CASE</b><br><i>CAST</i><br><b>CHECK</b><br><b>COLLATE</b><br><i>COLUMN</i><br><b>COMMIT</b><br><i>CONFLICT</i><br><b>CONSTRAINT</b><br></td><td valign="top" align="left" width="20%"><b>CREATE</b><br><b>CROSS</b><br><i>CURRENT_DATE</i><br><i>CURRENT_TIME</i><br><i>CURRENT_TIMESTAMP</i><br><i>DATABASE</i><br><b>DEFAULT</b><br><b>DEFERRABLE</b><br><i>DEFERRED</i><br><b>DELETE</b><br><i>DESC</i><br><i>DETACH</i><br><b>DISTINCT</b><br><b>DROP</b><br><i>EACH</i><br><b>ELSE</b><br><i>END</i><br><b>ESCAPE</b><br><b>EXCEPT</b><br><i>EXCLUSIVE</i><br><b>EXISTS</b><br><i>EXPLAIN</i><br><i>FAIL</i><br><i>FOR</i><br></td><td valign="top" align="left" width="20%"><b>FOREIGN</b><br><b>FROM</b><br><b>FULL</b><br><i>GLOB</i><br><b>GROUP</b><br><b>HAVING</b><br><i>IF</i><br><i>IGNORE</i><br><i>IMMEDIATE</i><br><b>IN</b><br><b>INDEX</b><br><i>INDEXED</i><br><i>INITIALLY</i><br><b>INNER</b><br><b>INSERT</b><br><i>INSTEAD</i><br><b>INTERSECT</b><br><b>INTO</b><br><b>IS</b><br><b>ISNULL</b><br><b>JOIN</b><br><i>KEY</i><br><b>LEFT</b><br><i>LIKE</i><br></td><td valign="top" align="left" width="20%"><b>LIMIT</b><br><i>MATCH</i><br><b>NATURAL</b><br><b>NOT</b><br><b>NOTNULL</b><br><b>NULL</b><br><i>OF</i><br><i>OFFSET</i><br><b>ON</b><br><b>OR</b><br><b>ORDER</b><br><b>OUTER</b><br><i>PLAN</i><br><i>PRAGMA</i><br><b>PRIMARY</b><br><i>QUERY</i><br><i>RAISE</i><br><b>REFERENCES</b><br><i>REGEXP</i><br><i>REINDEX</i><br><i>RELEASE</i><br><i>RENAME</i><br><i>REPLACE</i><br><i>RESTRICT</i><br></td><td valign="top" align="left" width="20%"><b>RIGHT</b><br><b>ROLLBACK</b><br><i>ROW</i><br><i>SAVEPOINT</i><br><b>SELECT</b><br><b>SET</b><br><b>TABLE</b><br><i>TEMP</i><br><i>TEMPORARY</i><br><b>THEN</b><br><b>TO</b><br><b>TRANSACTION</b><br><i>TRIGGER</i><br><b>UNION</b><br><b>UNIQUE</b><br><b>UPDATE</b><br><b>USING</b><br><i>VACUUM</i><br><b>VALUES</b><br><i>VIEW</i><br><i>VIRTUAL</i><br><b>WHEN</b><br><b>WHERE</b><br>
  115. </td></tr></table></blockquote>
  116. <h2>Special names</h2>
  117. <p>The following are not keywords in SQLite, but are used as names of
  118. system objects. They can be used as an identifier for a different
  119. type of object.</p>
  120. <blockquote class="pdf_keywords"><b>
  121. _ROWID_<br>
  122. MAIN<br>
  123. OID<br>
  124. ROWID<br>
  125. SQLITE_MASTER<br>
  126. SQLITE_SEQUENCE<br>
  127. SQLITE_TEMP_MASTER<br>
  128. TEMP<br>
  129. </b></blockquote>