sql - What is the use of WITH CHECK keyword -
alter table employee check constraint ck_employee_birthdate
when run above line of code not getting error.
but when run below line of code getting error "the alter table statement conflicted foreign key constraint"
alter table employee check check constraint ck_employee_birthdate
can me understand difference between using check , not using it?
following on bogdan's comment, http://msdn.microsoft.com/en-us/library/ms190273.aspx explains "with check" syntax ensures data in table validated against new check constraint. link, check assumed new constraints, nocheck assumed when re-enable existing constraint:
check | nocheck specifies whether data in table or not validated against newly added or re-enabled foreign key or check constraint. if not specified, check assumed new constraints, , nocheck assumed re-enabled constraints. if not want verify new check or foreign key constraints against existing data, use nocheck. not recommend doing this, except in rare cases. new constraint evaluated in later data updates. constraint violations suppressed nocheck when constraint added may cause future updates fail if update rows data not comply constraint. query optimizer not consider constraints defined nocheck. such constraints ignored until re-enabled using alter table table check check constraint all.
Comments
Post a Comment