When a UNIQUE constraint is added to an existing column or columns in
the table, by default, the Database Engine examines the existing data
in the columns to make sure all values are unique. If a UNIQUE
constraint is added to a column that has duplicated values, the Database
Engine returns an error and does not add the constraint.
The
Database Engine automatically creates a UNIQUE index to enforce the
uniqueness requirement of the UNIQUE constraint. Therefore, if an
attempt to insert a duplicate row is made, the Database Engine returns
an error message that states the UNIQUE constraint has been violated and
does not add the row to the table. Unless a clustered index is
explicitly specified, a unique, nonclustered index is created by default
to enforce the UNIQUE constraint.
No comments:
Post a Comment