Small. Fast. Reliable.
Choose any three.

SQL As Understood By SQLite

[Top]

SQLite Keywords

The SQL standard specifies a large number of keywords which may not be used as the names of tables, indices, columns, databases, user-defined functions, collations, virtual table modules, or any other named object. The list of keywords is so long that few people can remember them all. For most SQL code, your safest bet is to never use any English language word as the name of a user-defined object.

If you want to use a keyword as a name, you need to quote it. There are four ways of quoting keywords in SQLite:

'keyword' A keyword in single quotes is a string literal.
"keyword" A keyword in double-quotes is an identifier.
[keyword] A keyword enclosed in square brackets is an identifier. This is not standard SQL. This quoting mechanism is used by MS Access and SQL Server and is included in SQLite for compatibility.
`keyword` A keyword enclosed in grave accents (ASCII code 96) is an identifier. This is not standard SQL. This quoting mechanism is used by MySQL and is included in SQLite for compatibility.

For resilience when confronted with historical SQL statements, SQLite will sometimes bend the quoting rules above:

Programmers are cautioned not to use the two exceptions described in the previous bullets. We emphasize that they exist only so that old and ill-formed SQL statements will run correctly. Future versions of SQLite might raise errors instead of accepting the malformed statements covered by the exceptions above.

SQLite adds new keywords from time to time when it takes on new features. So to prevent your code from being broken by future enhancements, you should normally quote any identifier that is an English language word, even if you do not have to.

The list below shows all possible keywords used by any build of SQLite regardless of compile-time options. Most reasonable configurations use most or all of these keywords, but some keywords may be omitted when SQL language features are disabled. Applications can use the sqlite3_keyword_count(), sqlite3_keyword_name(), and sqlite3_keyword_check() interfaces to determine the keywords recognized by SQLite at run-time. Regardless of the compile-time configuration, any identifier that is not on the following 140 element list is not a keyword to the SQL parser in SQLite:

  1. ABORT
  2. ACTION
  3. ADD
  4. AFTER
  5. ALL
  6. ALTER
  7. ANALYZE
  8. AND
  9. AS
  10. ASC
  11. ATTACH
  12. AUTOINCREMENT
  13. BEFORE
  14. BEGIN
  15. BETWEEN
  16. BY
  17. CASCADE
  18. CASE
  19. CAST
  20. CHECK
  21. COLLATE
  22. COLUMN
  23. COMMIT
  24. CONFLICT
  25. CONSTRAINT
  26. CREATE
  27. CROSS
  28. CURRENT
  29. CURRENT_DATE
  30. CURRENT_TIME
  31. CURRENT_TIMESTAMP
  32. DATABASE
  33. DEFAULT
  34. DEFERRABLE
  35. DEFERRED
  36. DELETE
  37. DESC
  38. DETACH
  39. DISTINCT
  40. DO
  41. DROP
  42. EACH
  43. ELSE
  44. END
  45. ESCAPE
  46. EXCEPT
  47. EXCLUDE
  48. EXCLUSIVE
  49. EXISTS
  50. EXPLAIN
  51. FAIL
  52. FILTER
  53. FOLLOWING
  54. FOR
  55. FOREIGN
  56. FROM
  57. FULL
  58. GLOB
  59. GROUP
  60. GROUPS
  61. HAVING
  62. IF
  63. IGNORE
  64. IMMEDIATE
  65. IN
  66. INDEX
  67. INDEXED
  68. INITIALLY
  69. INNER
  70. INSERT
  71. INSTEAD
  72. INTERSECT
  73. INTO
  74. IS
  75. ISNULL
  76. JOIN
  77. KEY
  78. LEFT
  79. LIKE
  80. LIMIT
  81. MATCH
  82. NATURAL
  83. NO
  84. NOT
  85. NOTHING
  86. NOTNULL
  87. NULL
  88. OF
  89. OFFSET
  90. ON
  91. OR
  92. ORDER
  93. OTHERS
  94. OUTER
  95. OVER
  96. PARTITION
  97. PLAN
  98. PRAGMA
  99. PRECEDING
  100. PRIMARY
  101. QUERY
  102. RAISE
  103. RANGE
  104. RECURSIVE
  105. REFERENCES
  106. REGEXP
  107. REINDEX
  108. RELEASE
  109. RENAME
  110. REPLACE
  111. RESTRICT
  112. RIGHT
  113. ROLLBACK
  114. ROW
  115. ROWS
  116. SAVEPOINT
  117. SELECT
  118. SET
  119. TABLE
  120. TEMP
  121. TEMPORARY
  122. THEN
  123. TIES
  124. TO
  125. TRANSACTION
  126. TRIGGER
  127. UNBOUNDED
  128. UNION
  129. UNIQUE
  130. UPDATE
  131. USING
  132. VACUUM
  133. VALUES
  134. VIEW
  135. VIRTUAL
  136. WHEN
  137. WHERE
  138. WINDOW
  139. WITH
  140. WITHOUT