Difference
between Check Constraint and Rule
-
S.NoCheck ConstraintRule
1 Check constraint is associated with columns in a Table. So these cannot be re-used.Rules are defined with in a database and can be applied to any number of columns
Example
for Constraint:
alter
table Emp add constraint ck_op Check (Salary between 15000 and 45000)
Example
for Rule (Creation & Binding):
Creating
Rule:
CREATE
RULE SAL_RANGE
as
@Sal
> 15000 and @Sal > 45000
Binding
Rule to a Column:
SP_BINDRULE
'SAL_RANGE','Emp.Salary'
Summary:
The
major difference between rule and Check is re usability
No comments:
Post a Comment