SQLite Query Language: SQLite Keywords

Small. Fast. Reliable.
Choose any three.
Search for:

# SQL As Understood By SQLite

[Top]

## SQLite Keywords

The SQL standard specifies a huge 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:

- If a keyword in single quotes (ex: 'key' or 'glob') is used in a context where an identifier is allowed but where a string literal is not allowed, then the token is understood to be an identifier instead of a string literal.

- If a keyword in double quotes (ex: "key" or "glob") is used in a context where it cannot be resolved to an identifier but where a string literal is allowed, then the token is understood to be a string literal instead of an identifier.

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. Regardless of the compile-time configuration, any identifier that is not on the following 124 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_DATE
29. CURRENT_TIME
30. CURRENT_TIMESTAMP
31. DATABASE
32. DEFAULT
33. DEFERRABLE
34. DEFERRED
35. DELETE
36. DESC
37. DETACH
38. DISTINCT
39. DROP
40. EACH
41. ELSE
42. END
43. ESCAPE
44. EXCEPT
45. EXCLUSIVE
46. EXISTS
47. EXPLAIN
48. FAIL
49. FOR
50. FOREIGN
51. FROM
52. FULL
53. GLOB
54. GROUP
55. HAVING
56. IF
57. IGNORE
58. IMMEDIATE
59. IN
60. INDEX
61. INDEXED
62. INITIALLY
63. INNER
64. INSERT
65. INSTEAD
66. INTERSECT
67. INTO
68. IS
69. ISNULL
70. JOIN
71. KEY
72. LEFT
73. LIKE
74. LIMIT
75. MATCH
76. NATURAL
77. NO
78. NOT
79. NOTNULL
80. NULL
81. OF
82. OFFSET
83. ON
84. OR
85. ORDER
86. OUTER
87. PLAN
88. PRAGMA
89. PRIMARY
90. QUERY
91. RAISE
92. RECURSIVE
93. REFERENCES
94. REGEXP
95. REINDEX
96. RELEASE
97. RENAME
98. REPLACE
99. RESTRICT
100. RIGHT
101. ROLLBACK
102. ROW
103. SAVEPOINT
104. SELECT
105. SET
106. TABLE
107. TEMP
108. TEMPORARY
109. THEN
110. TO
111. TRANSACTION
112. TRIGGER
113. UNION
114. UNIQUE
115. UPDATE
116. USING
117. VACUUM
118. VALUES
119. VIEW
120. VIRTUAL
121. WHEN
122. WHERE
123. WITH
124. WITHOUT