Sqlite 建表不能使用的關鍵字

NO IMAGE

最近用Android SQLite建表時,使用了下面的一條建表語句 ,在編譯的時候程式就提示”near GROUP syntax error“,檢查了沒有任何的語法錯誤,實在是找不到錯誤原因,後來就嘗試更換表的表名,當我把”GROUP”換成其它的表名的時候就不會有任何問題。這下問題就直接定位到了表名上,我猜測”GROUP”這個名字可能和Sqlite定義的關鍵字衝突了,上Sqlite官網一查果然是SQLite指出不能用GROUP作為表,列等的名字。尷尬,
 SQLite官方網站對SQLite關鍵字的定義 http://www.sqlite.org/lang_keywords.html.

//群組表
private static String CREATE_GROUPTABLE = “CREATE TABLE GROUP” “(“
“_id INTEGER PRIMARY KEY AUTOINCREMENT,”
“group_id TEXT,”
“group_owner TEXT,”
“group_name TEXT,”
“group_desc TEXT,”
“group_level TEXT,”
“group_flag TEXT,”
“group_members TEXT”
“)”;

官方給出的不能使用以下的關鍵字作為表名 列名

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:

ABORT
ACTION
ADD
AFTER
ALL
ALTER
ANALYZE
AND
AS
ASC
ATTACH
AUTOINCREMENT
BEFORE
BEGIN
BETWEEN
BY
CASCADE
CASE
CAST
CHECK
COLLATE
COLUMN
COMMIT
CONFLICT
CONSTRAINT
CREATE
CROSS
CURRENT_DATE
CURRENT_TIME
CURRENT_TIMESTAMP
DATABASE
DEFAULT
DEFERRABLE
DEFERRED
DELETE
DESC
DETACH
DISTINCT
DROP
EACH
ELSE
END
ESCAPE
EXCEPT
EXCLUSIVE
EXISTS
EXPLAIN
FAIL
FOR
FOREIGN
FROM
FULL
GLOB
GROUP
HAVING
IF
IGNORE
IMMEDIATE
IN
INDEX
INDEXED
INITIALLY
INNER
INSERT
INSTEAD
INTERSECT
INTO
IS
ISNULL
JOIN
KEY
LEFT
LIKE
LIMIT
MATCH
NATURAL
NO
NOT
NOTNULL
NULL
OF
OFFSET
ON
OR
ORDER
OUTER
PLAN
PRAGMA
PRIMARY
QUERY
RAISE
RECURSIVE
REFERENCES
REGEXP
REINDEX
RELEASE
RENAME
REPLACE
RESTRICT
RIGHT
ROLLBACK
ROW
SAVEPOINT
SELECT
SET
TABLE
TEMP
TEMPORARY
THEN
TO
TRANSACTION
TRIGGER
UNION
UNIQUE
UPDATE
USING
VACUUM
VALUES
VIEW
VIRTUAL
WHEN
WHERE
WITH
WITHOU