Kamil (ka***@poczta.onet.NO.SPAM.pl) writes:
But in SQL BOL stands (Indexes->Overview):
Tip:Although a unique index will help locate information, for the best
performance results it is recommended
that you use primary key or unique constraints instead.
Which is under "Visual Database Tools", supposedly written by someone who
know more about the GUI than than the engine! :-)
I counter with this paragraph from Create and Maintaining Databases ->
Indexes -> Designing an index -> Using Unique indexes:
Creating a PRIMARY KEY or UNIQUE constraint automatically creates a
unique index on the specified columns in the table. There are no
significant differences between creating a UNIQUE constraint and
creating a unique index manually. Data validation occurs in the same
manner and the query optimizer does not differentiate between a unique
index created by a constraint or created manually. A unique index and a
UNIQUE constraint cannot be created if there duplicate key values
exist.
But while the argument is wrong in the tip, the advice is correct. If you
have unique indexes on your table, but no PRIMARY KEY or UNIQUE
constraint, you have an error in your logical design. Then again, an
argument for using indexes only, and no constraints, is that if you want
to change an index, CREATE INDEX offers WITH DROP_EXISTING, which you
cannot - as far as I know - apply to a constraint. WITH DROP_EXISTING is
particularly useful when you change a clustered index, with one or more
non-clustered indexes, since if you drop and recreate, the non-clustered
indexes will be rebuilt twice.
--
Erland Sommarskog, SQL Server MVP,
es****@sommarskog.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp