ON DELETE CASCADE 在 SQLite 中不起作用 [英] ON DELETE CASCADE not working in SQLite

查看:30
本文介绍了ON DELETE CASCADE 在 SQLite 中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在适用于 iOS 的 SQLite (3.7.7) 中,我正在运行这些查询:

In SQLite for iOS (3.7.7) I am running these queries:

PRAGMA foreign_keys = ON;

create table venue(id integer primary key not null, name text not null);

create table event(id integer primary key not null, name text not null, 
venue_id integer references venue(id) on delete cascade);

但是当我删除一个场地时,儿童事件不会被删除.有什么想法吗?

But when I delete a venue, the children events are not deleted. Any ideas?

推荐答案

我按照 Catcall 所说的去做,它对我有用:通过运行

I followed what Catcall said and it worked for me: setting foreign_keys by running

stmt.execute("PRAGMA foreign_keys = ON");

每次我建立到数据库的连接.

each time I establish a connection to the database.

这篇关于ON DELETE CASCADE 在 SQLite 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆