开发者

how to give a check constraint to a character coloumn

开发者 https://www.devze.com 2023-02-20 14:39 出处:网络
How can i give a check constraint to a column whose datatype is char(1) coloumn name--->group datatype------->char(1)

How can i give a check constraint to a column whose datatype is char(1)

coloumn name--->group

datatype------->char(1)

CHECK(c,s,a)

plz tell me the exact query how to insert it in开发者_Go百科to sqlserver2005 while creating a table,, in which group is a column...

Thanks, Churchill


From your question, it seems as though you only want to allow the value c, s, or a. If I understand correctly....

Create Table YourTableNameHere(
      Id Int, 
      col Char(1) 
      Constraint ConstraintNameHere Check(Col In ('c','s','a')))
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号