为已经存在不符合数据约束的表添加约束
临时禁用表的约束(NO CHECK)
查看禁用表约束 (Watch Table's CHECK)
重新启用禁用表的约束(CHECK)
创建规则
查看规则内容
应用规则
sp_bindrule <'rule'> , <'object_name'>,[<'futureonly_flag'>]
取消应用的规则
消除规则
DROP RULE <'rule'>
创建默认值
应用默认值
取消默认值
删除默认值
DROP DEFAULT <默认值>
确定那个表或者数据类型上使用了制定的规则或默认值
EXEC sp_depends <对象名>
1
ALTER Table Customers
2
WITH NOCHECK
3![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
4
ADD CONSTRAINT CN_NOCHECK
5
CHECK
6
(NAME LIKE 'GEEWU%')
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
2
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
3
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
4
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
5
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
6
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
临时禁用表的约束(NO CHECK)
1
ALTER TABLE Customers
2
NOCHECK
3
CONSTRAINT CN_GeeWu
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
2
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
3
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
查看禁用表约束 (Watch Table's CHECK)
1
EXEC sp_helpconstraint Customers
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
重新启用禁用表的约束(CHECK)
1
ALTER TABLE Customers
2
CHECK
3
CONSTRAINT CN_GeeWu
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
2
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
3
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
创建规则
1
CREATE RULE SalaryRule
2
AS @GeeWu = 'GeeWu'
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
2
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
查看规则内容
1
EXEC sp_helptext SalaryRule
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
应用规则
sp_bindrule <'rule'> , <'object_name'>,[<'futureonly_flag'>]
1
EXEC sp_bindrule 'SalaryRule' , 'Employees.Salary'
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
取消应用的规则
1
EXEC sp_unbindrule 'SalaryRule' , 'Employees.Salary'
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
消除规则
DROP RULE <'rule'>
创建默认值
1
CREATE DEFAULT SalaryDefault
2
AS 0
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
2
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
应用默认值
1
EXEC sp_bindefault 'SalaryDefault','Employees.Salary'
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
取消默认值
1
EXEC sp_unbindefault 'Employees.Salary'
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
删除默认值
DROP DEFAULT <默认值>
确定那个表或者数据类型上使用了制定的规则或默认值
EXEC sp_depends <对象名>