private static final String TASK_table_CREATE = "create table " + TASK_table + " (" + TASK_ID + " integer primary key autoincrement," + TASK_Title + " text not null," + TASK_NOTES + " text not null," + TASK_DATE_TIME + " text not null,FOREIGN KEY ("+TASK_CAT+") REFERENCES "+CAT_table+" ("+CAT_ID+"));";
任何想法我可能做错了什么?如果你需要看到其他表结构,那么我可以,它只是一个非常简单的结构,第二个具有ID和名称。
编辑:
这里是错误:
您必须首先定义TASK_CAT列,然后在其上设置外键。03-13 13:42:35.389:
ERROR/AndroIDRuntime(312): Caused by:
androID.database.sqlite.sqliteException:
unkNown column “taskCat” in foreign
key deFinition: create table reminders
(_ID integer primary key
autoincrement,task_Title text not
null,notes text not null,
reminder_date_time text not null,
FOREIGN KEY (taskCat) REFERENCES
category (_ID));
private static final String TASK_table_CREATE = "create table " + TASK_table + " (" + TASK_ID + " integer primary key autoincrement," + TASK_Title + " text not null," + TASK_NOTES + " text not null," + TASK_DATE_TIME + " text not null," + TASK_CAT + " integer," + " FOREIGN KEY ("+TASK_CAT+") REFERENCES "+CAT_table+"("+CAT_ID+"));";
更多信息,你可以找到sqlite外键doc。
总结以上是内存溢出为你收集整理的SQlite – Android – 外键语法全部内容,希望文章能够帮你解决SQlite – Android – 外键语法所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)