android – SQLite的“NO ACTION”外键约束究竟做了什么,它与“RESTRICT”的区别如何?

android – SQLite的“NO ACTION”外键约束究竟做了什么,它与“RESTRICT”的区别如何?,第1张

概述documentation说: Configuring “NO ACTION” means just that: when a parent key is modified or deleted from the database, no special action is taken. 我对这句话的第一个解释是“如果父键被修改或删除,那么这个修改就完成了,不采取任何其他行动”,因此不保留数据库的 documentation说:

Configuring “NO ACTION” means just that: when a parent key is modifIEd
or deleted from the database,no special action is taken.

我对这句话的第一个解释是“如果父键被修改或删除,那么这个修改就完成了,不采取任何其他行动”,因此不保留数据库的完整性,这导致了一些confusion.
但我的测试显示,如果我尝试删除父键(如果子键仍然存在),我会得到一个异常(“sqliteConstraintException:错误代码19:约束失败” – 我在androID 4.0.3 / sqlite下测试3.7.x),所以“NO ACTION”似乎表现得像预期的那样.

有人可以解释一下,也许举个例子,究竟“无行动”是做什么的,以及它与“限制”的区别.

解决方法 引言段落说:

If an action is not explicitly specifIEd,it defaults to “NO ACTION”.

这是正常的行动.

此外:

The difference between the effect of a RESTRICT action and normal foreign key constraint enforcement is that the RESTRICT action processing happens as soon as the fIEld is updated – not at the end of the current statement as it would with an immediate constraint,or at the end of the current transaction as it would with a deferred constraint.

如果您使用仅更改一条记录的单语句事务进行测试,则不会看到NO ACTION和RESTRICT之间存在任何差异.

总结

以上是内存溢出为你收集整理的android – SQLite的“NO ACTION”外键约束究竟做了什么,它与“RESTRICT”的区别如何?全部内容,希望文章能够帮你解决android – SQLite的“NO ACTION”外键约束究竟做了什么,它与“RESTRICT”的区别如何?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1124947.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-30
下一篇 2022-05-30

发表评论

登录后才能评论

评论列表(0条)

保存