I got syntax error in my sqlite query while executing the query
执行查询时,我的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)");
Error is " syntax error near EVENT_ID". Can anybody help me to trace the error?
错误是“EVENT_ID附近的语法错误”。有人可以帮我跟踪错误吗?
3 个解决方案
#1
2
Put your table constraints such as foreign key definitions after the column specifications:
在列规范之后放置表限制,例如外键定义:
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))");
#2
2
The table constraints go after the column definition:https://www.sqlite.org/lang_createtable.html
表约束在列定义之后:https://www.sqlite.org/lang_createtable.html
Try this:
尝试这个:
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))");
#3
1
Plz try this:
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))");
#1
2
Put your table constraints such as foreign key definitions after the column specifications:
在列规范之后放置表限制,例如外键定义:
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))");
#2
2
The table constraints go after the column definition:https://www.sqlite.org/lang_createtable.html
表约束在列定义之后:https://www.sqlite.org/lang_createtable.html
Try this:
尝试这个:
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))");
#3
1
Plz try this:
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))");