作者:法国警方解放军_847 | 来源:互联网 | 2023-07-01 12:06
最近用AndroidSQLite建表时,使用了下面的一条建表语句,在编译的时候程序就提示”nearGROUPsyntaxerror“,检查了没有任何的语法错误,实在是找不到错误原因,后来就尝
最近用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 |