???????????
????SQLServer2008??????????????????????
??????PRIMARYKEY???
??????FOREIGNKEY???
??????UNIQUE???
??????CHECK???
??????NOTNULL????????
??????IDENTITY???
???????????????????????????????????
????????????????????????????????????м??
??????PRIMARYKEY?????
???????????????????????
????(1)????????????????????????????
????(2)?????????PRIMARYKEY???????У??????????????PRIMARYKEY???????
????(3)???????PRIMARYKEY???????????????????????
???????
????(1)?????????????????????????
????(2)????????κ??в???????null????
????(3)????TRansact-SQL???PRIMARYKEY??????????????е?PRIMARYKEY?????????????′?????
????(4)????????????????sqlserver???????????????“PK_”??????????????????????????????????????????????????????????????????????????????????????????????????
??????FOREIGNKEY???
?????????????????????????????????????????л?????????????????FOREIGNKEY?????????????????е??????У????磺??????е?“?????”?в???“???”?У??????????????????
????FOREIGNKEY??????????????????????
????(1)????????????????????????????
????(2)??????б?????????????????е?PRIMARYKEY?????UNIQUE??????????????????б????FOREIGNKEY?????
????(3)?????е?FOREIGNKEY????????????????
???????FOREIGNKEY?????????????????
????(1)???????????253??FOREIGNKEY?????
????(2)FOREIGNKEY???????????????????е??????????????????????е???
????(3)FOREIGNKEY????е??????????????????????????????REFERENCES????е????????
????(4)FOREIGNKEY????????????????????
????(5)????????У????????FOREIGNKEY?????
????(6)???????????ж?????????????????????????С?
??????UNIQUE???
????(1)UNIQUE??????м???????????????
????(2)????UNIQUE????е??У????в??????????а?????????????
????(3)SQLServer??????UNIQUE?????????????UNIQUE?????????UNIQUE??????????
????(4)???????????У?SQLServer??????????????
????(5)????е??????????UNIQUE??????????????SQLServer2008??????е??????????????NULL????????????
????(6)UNIQUE???????????????????????????????????????????????????????????????????????????UNIQUE?п????ж??????????????
????(7)UNIQUE???????????????
??????CHECK???
????(1)CHECK?????????????????????????????????
????(2)??????????????????????????????????TRUE??FALSE??????????????????в????TRUE?????
????(3)??????????????CHECK?????
??????IDENTITY???
??????????????????????У????????????????????????????????????Щ?????????????????????????????????????????
????(1)???????
????(2)???????
????(3)????е?????????
???????????????????????
?????????????????????????
????CONSTRAINT<???????????????>[PRIMARYKEY????|FOREIGNKEY????|CHECK????]
???????????????????Student2??????????10000??99999?????????????????????С??30?????‘??’??‘?’??
????1CREATETABLEStudent2(
????2snointCONSTRAINTC1CHECK(snoBETWEEN10000AND99999)??
????3snameCHAR(8)CONSTRAINTC2NOTNULL??
????4sageintCONSTRAINTC3CHECK(sage<30)??
????5ssexVARCHAR(2)CONSTRAINTC4CHECK(ssexIN('??'??'?'))??
????6CONSTRAINTSKPRIMARYKEY(Sno)
????7);