What is the difference between Unique Key and Index with IsUnique=Yes?

后端 未结 6 1466
别那么骄傲
别那么骄傲 2021-02-04 23:45

I have a table with a primary key, but I want two other columns to be constrained so the combination of the two is guaranteed always to be unique.

(a dumb example: In a

6条回答
  •  野性不改
    2021-02-05 00:22

    Creating a UNIQUE constraint is a clearer statement of the rule. The IsUnique attribute of the index is an implementation detail - how the rule is implemented, not what the rule is. The effect is the same though.

提交回复
热议问题