更新时间:2023-02-03 08:03:04
支持删除级联的外键约束,但您需要启用它们.
我刚刚将以下内容添加到我的 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