Unique key vs. unique index on SQL Server 2008

前端 未结 7 1528
抹茶落季
抹茶落季 2021-02-01 00:59

I have a table called countries and I define the country_name column to be unique by creating a “Index/Key” of type “Unique Key” on SQL Server 2008 R2.

7条回答
  •  醉酒成梦
    2021-02-01 01:14

    One of most important point is suppose you want to keep column value null with maintaining uniqueness you can't do with unique key constraint but with unique key index u can keep column value null with maintain uniqueness. so if you need column unique with Null-able type Unique Index required else if you need column not null-able then unique key constraint required.

提交回复
热议问题