在Android中,我很难找到以下查询的问题。编码似乎是正确的。我正在尝试以下代码段:
DATABASE_TABLES.add("CREATE TABLE PageRights("
+"RightsId INTEGER NOT NULL,"
+"PageName varchar(-1) NULL,"
+"PageId INTEGER NOT NULL,"
+"UserId INTEGER NOT NULL,"
+"RoleId INTEGER NOT NULL,"
+"Add BOOLEAN NOT NULL,"
+"Edit BOOLEAN NULL,"
+"Delete BOOLEAN NULL,"
+"CreatedBy varchar(-1) NULL,"
+"CreatedDate DATE NOT NULL,"
+"Views BOOLEAN NULL)");
抛出的错误是;
android.database.sqlite.SQLiteException: near "Add": syntax error (code 1): , while compiling: CREATE TABLE PageRights(RightsId INTEGER NOT NULL,PageName varchar(-1) NULL,PageId INTEGER NOT NULL,UserId INTEGER NOT NULL,RoleId INTEGER NOT NULL,Add BOOLEAN NOT NULL,Edit BOOLEAN NULL,Delete BOOLEAN NULL,CreatedBy varchar(-1) NULL,CreatedDate DATE NOT NULL,Views BOOLEAN NULL)
请通过提出你的想法来帮助我。
答案 0 :(得分:5)
Add
,Edit
,Delete
是预定义的关键字,请按照以下方式使用,
DATABASE_TABLES.add("CREATE TABLE PageRights("
+"RightsId INTEGER NOT NULL,"
+"PageName varchar(-1) NULL,"
+"PageId INTEGER NOT NULL,"
+"UserId INTEGER NOT NULL,"
+"RoleId INTEGER NOT NULL,"
+"Add_PageRights BOOLEAN NOT NULL,"
+"Edit_PageRights BOOLEAN NULL,"
+"Delete_PageRights BOOLEAN NULL,"
+"CreatedBy varchar(-1) NULL,"
+"CreatedDate DATE NOT NULL,"
+"Views BOOLEAN NULL)");
答案 1 :(得分:4)
android.database.sqlite.SQLiteException:near" Add"
Add
是MySQL中的保留字。顺便说一下,Edit
和Delete
也是如此。
将这些列的名称更改为其他名称。