问题描述
在oracle sql中,将约束设置为延迟VS禁用约束似乎具有相似的功能。两者之间有何重大区别?如果您能说明它们在实际场景中的用法,将不胜感激。
In oracle sql, setting a constraint to deferred VS disabling a constraint seem to have similar functionalities. Are there any significant differences between the two? It would be much appreciated if you can illustrate their uses with real world scenarios.
谢谢
推荐答案
禁用的约束是在数据库,但完全不执行。 (就像放下约束一样,重新打开更容易。)至于可延迟的:
A disabled constraint is one that's defined in the database but not enforced at all. (Like dropping a constraint only it's easier to switch back on.) As for deferrable:
可延迟约束
一个约束,它允许SET CONSTRAINT语句将约束检查推迟到提交事务之后。可延缓的约束使您可以在进行可能违反约束的更改时临时禁用约束。
A constraint that permits a SET CONSTRAINT statement to defer constraint checking until after the transaction is committed. A deferrable constraint enables you to disable the constraint temporarily while making changes that might violate the constraint.
值得注意的是:
您无法更改约束的可延期性。无论您指定这两个参数中的一个,还是通过都不指定它们来隐式地使约束为NOT DEFERRABLE,则不能在ALTER TABLE语句中指定此子句。您必须删除约束并重新创建它。
You cannot alter the deferrability of a constraint. Whether you specify either of these parameters, or make the constraint NOT DEFERRABLE implicitly by specifying neither of them, you cannot specify this clause in an ALTER TABLE statement. You must drop the constraint and re-create it.
这篇关于oracle sql延迟VS禁用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!