在Android 4.2中,使用SQLite 3.7.11,当我从Quizzes表中删除一行时,谁的架构在下面,QuizQuestions表中的相应行不会被删除。
我不知道出了什么问题。我试过把
db.execSQL("PRAGMA foreign_keys = ON;");
在创建表语句之前和之后。
创建表语句:
CREATE TABLE quizzes(quiz_name TEXT PRIMARY KEY COLLATE NOCASE);
CREATE TABLE quizQuestions(quiz_name TEXT, question_id INTEGER,
PRIMARY KEY(quiz_name, question_id),
FOREIGN KEY(quiz_name) REFERENCES quizzes(quiz_name) ON DELETE CASCADE,
FOREIGN KEY(question_id) REFERENCES questions(question_id) ON DELETE CASCADE);