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

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

问题描述

根据 2010 年的 this 线程,EnforceFKConstraints"连接string 属性应该在 SQLite 的未来版本中实现.有谁知道开发人员是否已经开始这样做了?

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?

如果没有,是否有另一种方法可以启用外键支持,而无需在每个连接上执行PRAGMA foreign_keys = ON"?我需要这个来确保删除总是级联的.

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.

推荐答案

System.Data.SQLite ADO.NET provider for SQLite 的未来开发由 这个组.该项目目前处于迁移状态,一些功能现在甚至不可用(在 1.0.66 版本中可用,最后由 Robert Simpson(原始库作者)).

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)).

根据 trunk 中提供的最新源代码,不支持EnforceFKConstraints".但是有 foreign keys 连接字符串属性,其默认值为 False,也许它可以完成这项工作?尝试在连接字符串中包含 foreign keys=True 属性.请务必使用来自此处的最新稳定版本.

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天全站免登陆