Unique constraint
Posted in 1999
Topics: SQL Development & Query Writing, Triggers, Constraints & Referential Integrity
Is there any advantage to putting a unique constraint on a column instead of creating a unique index on a column? I have seen this done, and I don't see any advantage. The column is being used in a join anyway, so it would seem that a unique index would be the way to go. Comments anyone? ==================================================================== Harold Luse Phone: (970) 491-4120 Veterinary Teaching Hospital Fax: (970) 491-4123 Colorado State University Pager: (970) 229-8173 Fort Collins, Colorado USA E-mail: hluse@vth.colostate.edu ====================================================================
Luse Harold wrote: > > Is there any advantage to putting a unique constraint on a column instead > of creating a unique index on a column? I have seen this done, and I > don't see any advantage. The column is being used in a join anyway, so it > would seem that a unique index would be the way to go. > > Comments anyone? Does not matter either way. It is a documentation thing. The UNIQUE CONSTRAINT will create the same UNIQUE index you would and that index alone will be used to guarantee uniqueness of rows. Art S. Kagel