Groups | Blog | Home
all groups > sql server programming > april 2004 >

sql server programming : constraint vs index


George
4/14/2004 11:14:00 PM
Other than syntax, is there any difference between a
unique constraint and a unique index? Or, assuming they
are different, what causes a constraint to become an
index?

Hari
4/15/2004 12:30:54 PM
Hi,

I think both of them are same apart from a small difference mentioned
below. When you create a Unique constraint, it automaticly creates a Unique
index.

Only difference between them is;

A Unique constraint is a logical constraint upon the table which is decided
during database modelling (Design).
A Unique index is a physical constraint independent of the database design
and is created during optimization.

Practically speaking, the only operational difference is that a Unique
constraint, even though implemented via a Unique index, can only be dropped
via
ALTER TABLE ... DROP CONSTRAINT ... it can **not** be dropped via a DROP
INDEX.
A Unique index on the other hand can be dropped only via a DROP INDEX.

Thanks
Hari
MCDBA





[quoted text, click to view]

AddThis Social Bookmark Button