What is the difference between UNIQUE KEY and UNIQUE INDEX?

Answer Posted / mallik

Unique Index and Unique Constraint are the same. They
achieve same goal. SQL Performance is same for both.

Add Unique Constraint
ALTER TABLE dbo.<tablename> ADD CONSTRAINT
<namingconventionconstraint> UNIQUE NONCLUSTERED
(
<columnname>
) ON [PRIMARY]

Add Unique Index
CREATE UNIQUE NONCLUSTERED INDEX
<namingconventionconstraint> ON dbo.<tablename>
(
<columnname>
) ON [PRIMARY]

There is no difference between Unique Index and Unique
Constraint. Even though syntax are different the effect is
the same. Unique Constraint creates Unique Index to
maintain the constraint to prevent duplicate keys. Unique
Index or Primary Key Index are physical structure that
maintain uniqueness over some combination of columns across
all rows of a table. It is a convenient way to enforce a
Unique Constraint for SQL Server.

Is This Answer Correct ?    4 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can we join more than 2 tables in sql?

682


How to use sql*plus built-in timers?

770


Explain what is a database?

817


What are inner and outer joins examples of both?

693


Does postgresql run on the cloud?

800






Is it mandatory for the primary key to be given a value when a new record is inserted?

934


what is the difference between clustered and non clustered index in sql? : Sql dba

741


Where the sql database files are stored?

696


What are all the ddl commands?

862


how would concatenate strings in mysql? : Sql dba

743


How does a self join work?

693


What is the difference between a primary key and a unique key?

754


What is the command used to fetch the first 5 characters of a string?

932


What is a unique key and primary key and foreign key?

744


How do I partition in sql?

706