Can you replace or update a SQL constraint?

前端 未结 3 1248
灰色年华
灰色年华 2020-12-29 22:08

I have written the following constraint for a column I\'ve called \'grade\':

CONSTRAINT gradeRule CHECK grade IN (‘easy’, ‘moderate’, ‘difficult’),
         


        
3条回答
  •  心在旅途
    2020-12-29 22:28

    Drop the constraint, and then add the replacement constraint. You can't update a constraint in SQL Server at least.

    ALTER TABLE SomeTable DROP CONSTRAINT gradeRule
    

    In addition, you'll need to update the table data before adding the new constraint, so that it meets the new constraint.

提交回复
热议问题