Saturday, February 25, 2012

chack attribute domain

How can I be sure that a attribute in a table only can accepta {1,2,3}

You could add CHECK constraint

Code Snippet

createtable test

(

id int,

valueint

)

altertable test addconstraint chk_possible check(valuein(1,2,3))

insertinto test values(1,1)--Works

insertinto test values(1,7)--Fail

No comments:

Post a Comment