HiveBrain v1.2.0
Get Started
← Back to all entries
patternMinor

Should I use Index or Unique Key for a non PK Uniqueidentifier?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
uniqueidentifieruniquenonforshouldindexusekey

Problem

Using Sql Server 2014, I have several tables where the PK field is an int, but I also have a UniqueIdentifier field that I need to query by. This field will always be unique.

I am adding indexes for these and I have the option of choosing Index or Unique Key.

Is there any benefit to choosing one or the other?

Solution

Unique keys are indexes. If your values are guaranteed to be unique, this is the best choice.


Unique Key: Unique Key enforces uniqueness of the column on which they are defined. Unique Key creates a non-clustered index on the column. Unique Key allows only one NULL Value.

Context

StackExchange Database Administrators Q#184525, answer score: 8

Revisions (0)

No revisions yet.