执行查询时,我的sqlite查询出现语法错误
db.execSQL("CREATE TABLE "+TABLE_ABC+" (ID INTEGER PRIMARY KEY AUTOINCREMENT, EVENT_MATCH_ID INTEGER, FOREIGN KEY (EVENT_MATCH_ID) REFERENCES "+TABLE_DEF+" (MATCH_ID), EVENT_ID TEXT, EVENT_TYPE TEXT, EVENT_MINUTE TEXT," +
"EVENT_TEAM TEXT, EVENT_PLAYER TEXT, EVENT_PLAYER_ID TEXT, EVENT_RESULT TEXT)");
错误是" EVENT_ID"附近的语法错误。有人可以帮我跟踪错误吗?
答案 0 :(得分:2)
将表限制(例如外键定义)放在列规范之后:
db.execSQL("CREATE TABLE "+TABLE_ABC+" (ID INTEGER PRIMARY KEY AUTOINCREMENT, EVENT_MATCH_ID INTEGER, EVENT_ID TEXT, EVENT_TYPE TEXT, EVENT_MINUTE TEXT," +
"EVENT_TEAM TEXT, EVENT_PLAYER TEXT, EVENT_PLAYER_ID TEXT, EVENT_RESULT TEXT, " +
"FOREIGN KEY (EVENT_MATCH_ID) REFERENCES "+TABLE_DEF+" (MATCH_ID))");
答案 1 :(得分:2)
答案 2 :(得分:1)
Plz试试这个:
db.execSQL("CREATE TABLE "+TABLE_ABC+" (ID INTEGER PRIMARY KEY AUTOINCREMENT, EVENT_MATCH_ID INTEGER, EVENT_ID TEXT, EVENT_TYPE TEXT, EVENT_MINUTE TEXT," +
"EVENT_TEAM TEXT, EVENT_PLAYER TEXT, EVENT_PLAYER_ID TEXT, EVENT_RESULT TEXT, FOREIGN KEY (EVENT_MATCH_ID) REFERENCES "+TABLE_DEF+" (MATCH_ID))");