更新时间:2023-01-29 16:58:38
支持 on delete cascade 的外键约束,但您需要启用它们.
我刚刚在我的 SQLOpenHelper 中添加了以下内容,这似乎可以解决问题.
Foreign key constraints with on delete cascade are supported, but you need to enable them.
I just added the following to my SQLOpenHelper, which seems to do the trick.
@Override
public void onOpen(SQLiteDatabase db) {
super.onOpen(db);
if (!db.isReadOnly()) {
// Enable foreign key constraints
db.execSQL("PRAGMA foreign_keys=ON;");
}
}
我声明我的引用列如下.
I declared my referencing column as follows.
mailbox_id INTEGER REFERENCES mailboxes ON DELETE CASCADE