0
我已經創造了一些表:的SQLite上刪除級聯不工作
"CREATE TABLE IF NOT EXISTS WORKOUTPLANS (ID INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE , NAME TEXT NOT NULL UNIQUE, DESCRIPTION TEXT NOT NULL UNIQUE)";
"CREATE TABLE IF NOT EXISTS ENTITY (ID INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE , NAME TEXT NOT NULL UNIQUE , DESCRIPTION TEXT NOT NULL UNIQUE)";
"CREATE TABLE IF NOT EXISTS EXERCISE (ID INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE , NAME TEXT NOT NULL UNIQUE , DESCRIPTION TEXT NOT NULL UNIQUE , REPS TEXT NOT NULL , WEIGHT TEXT NOT NULL)";
"CREATE TABLE IF NOT EXISTS WPEN (PLANID, ENID, FOREIGN KEY(PLANID) REFERENCES WORKOUTPLANS(ID) ON DELETE CASCADE, FOREIGN KEY(ENID) REFERENCES ENTITY(ID) ON DELETE CASCADE)";
"CREATE TABLE IF NOT EXISTS ENEX (ENTITYID, EXERCISEID, FOREIGN KEY(ENTITYID) REFERENCES ENTITY(ID) ON DELETE CASCADE, FOREIGN KEY(EXERCISEID) REFERENCES EXERCISE(ID) ON DELETE CASCADE)";
所以你可以看到我有M:N的關係,並在此連接的表我有上刪除級聯約束。我知道我每次連接到數據庫時都必須在sqlite中激活外鍵,我也是如此。
然而,當我在WORKOUTPLANS和WPEN不是實體,運動刪除WORKOUTPLANS一排它只是刪除行和ENEX
爲什麼上刪除級聯不工作?