all groups > sql server misc > september 2003 >
You're in the

sql server misc

group:

Unique Constraint vs. Unique Index


Unique Constraint vs. Unique Index jeff_carver NO[at]SPAM hotmail.com
9/26/2003 9:38:56 AM
sql server misc: I have yet to find a clear explanation of (a) what the difference(s)
is/are between a unique constraint and a unique index, and (b) under
what conditions one would be preferable over the other.

Re: Unique Constraint vs. Unique Index Bob Simms
9/27/2003 11:55:17 AM
[quoted text, click to view]

A unique constraint automatically creates a unique indexfor you (as does a
primary key constraint). Both the constraint and the index prevent
duplicate values.

The advantage of greating a unique constraint is that it makes documentation
easier (the constraint shows as part of the table definition) and it makes
it easier to port from one platform to another (One CREATE statement as
opposed to two).

However, you can create UNIQUE indexes on a view where you can't create a
constraint.


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.520 / Virus Database: 318 - Release Date: 18/09/2003

AddThis Social Bookmark Button