SQLite3中的外键支持 [英] Foreign key support in SQLite3

查看:186
本文介绍了SQLite3中的外键支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据2010年的这个线程,一个EnforceFKConstraints连接字符串属性应该在未来的SQLite版本中实现。有谁知道是否开发人员已经做到了这一点?

如果没有,有没有另外一种方法,我可以启用外键支持而不做PRAGMA foreign_keys = ON每个连接?我需要这样做,以确保删除总是级联。

解决方案

System.Data.SQLite的未来发展SQLite的ADO.NET提供程序由这个组完成。该项目目前处于迁移状态,现在有些功能甚至无法使用(可以在1.0.66版本中获得,最后由 Robert Simpson < (原始图书馆作者))。

根据中提供的最新源代码中继线不支持EnforceFKConstraints。但是,有外键连接字符串属性,它们的默认值是 False ,也许它是工作吗?尝试在连接字符串中包含外键= True 属性。请务必使用此处的最新稳定版本。



更新。在深入了解源代码之后,我几乎可以肯定,这个连接字符串属性正在做你想要的。


According to this thread from 2010, an "EnforceFKConstraints" connection string property was supposed to be implemented into future releases of SQLite. Does anyone know if the developers have gotten around to doing that?

If not, is there another way I can enable foreign key support without doing "PRAGMA foreign_keys = ON" on each connection? I need this to make sure that deletes always cascade.

解决方案

Future development of System.Data.SQLite ADO.NET provider for SQLite is done by this group. The project is currently in migration status and some features are even unavailable now (which were available in 1.0.66 version, which is last maintained by Robert Simpson (original library author)).

According to latest source code available in trunk "EnforceFKConstraints" is not supported. However there is foreign keys connection string property which have default value of False, maybe it does the job? Try including foreign keys=True property in your connection string. Be sure to use latest stable build from here.

Update. After looking deeper in source, I'm almost sure that this connection string property is doing exactly that you want.

这篇关于SQLite3中的外键支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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