Sqlite 建表不能使用的关键字

前端之家收集整理的这篇文章主要介绍了Sqlite 建表不能使用的关键字前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。



最近用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 ofcompile-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
原文链接:https://www.f2er.com/sqlite/199653.html

猜你在找的Sqlite相关文章