SQL中约束和规则的区别 [英] Difference between Constraints and Rules in SQL
本文介绍了SQL中约束和规则的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在SQL中使用约束和规则之间有什么区别,最好是SQL Server 2008 R2。任何人都可以用实时示例解释和演示
解决方案
规则是一个向后兼容性
功能,可执行某些操作与CHECK
约束相同的函数。
CHECK
约束是首选,标准方式到限制列中的值 。
CHECK
约束也比规则更简洁;只能有一个规则应用于列,但可以应用多个CHECK
约束。CHECK
约束被指定为CREATE TABLE
语句的一部分,而规则被创建为单独的对象,然后绑定到专栏。
关于RULE的重要事项:
此功能将在未来版本的Microsoft SQL Server中删除。避免在新的开发工作中使用此功能,并计划修改当前使用此功能的应用程序。
参考:http://technet.microsoft.com/en-us/library/ms188064(v=sql.105).aspx [ ^ ]
RULE
1.第一个:
我认为规则是限制之一。
2.规则可以在表格中分配多个字段,对象
CONSTRAINTS
约束允许您定义Microsoft®SQLServer™自动强制数据库完整性的方式。约束定义了关于列中允许的值的规则,并且是强制执行完整性的标准机制。
请参阅链接以获取更多详细信息
http://msdn.microsoft.com/ en-us / library / aa174546%28v = sql.80%29.aspx [ ^ ]
希望这很有用。
Trong Anh
点击这里,
Contraints_vs_rules。
What is the difference between using constraints and rules in SQL, preferably SQL server 2008 R2. Can anyone explain and demonstrate with a real time example
解决方案
Rules are abackward-compatibility
feature that performs some of the same functions asCHECK
constraints.
CHECK
constraints are the preferred, standard way to restrict the values in a column.
CHECK
constraints are also more concise than rules; there can only be one rule applied to a column, but multipleCHECK
constraints can be applied.CHECK
constraints are specified as part of theCREATE TABLE
statement, while rules are created as separate objects and then bound to the column.
Important about RULE:
This feature will be removed in a future version of Microsoft SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature.
Refer: http://technet.microsoft.com/en-us/library/ms188064(v=sql.105).aspx[^]
RULE
1. The first one:
I think that Rule is one of constrains.
2. Rule can assign more than one fields in table, objects
CONSTRAINTS
Constraints allow you to define the way Microsoft® SQL Server™ automatically enforces the integrity of a database. Constraints define rules regarding the values allowed in columns and are the standard mechanism for enforcing integrity.
See link to get more details
http://msdn.microsoft.com/en-us/library/aa174546%28v=sql.80%29.aspx[^]
Hope that is useful.
Trong Anh
Check here,
Contraints_vs_rules.
这篇关于SQL中约束和规则的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文