2015년 8월 25일 화요일

Primary key and Unique Constraint


Before setting, Primary keys constraint

  • Primary keys must contain UNIQUE values.
  • A primary key column cannot contain NULL values.



 Select Design in dbo.member under your database

You can see your table and select column to set Primary Key and save, for example, MemberIDX


when you save primary keys if you receive alert message, you have to set tool>option.



Designers>Table and Database Designers>uncheck Prevent saving.......................................



In order to test primary keys, insert sample data.





If you try to insert same data again and null data, you will receive error message because of duplication key data, so in order to ignore this message you have to constrain following Unique constraint.

Alter table Member
add constraint unique_memberID unique(memberID)





Source site: sqler~~
thank you.





댓글 없음:

댓글 쓰기