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

Is it possible to read/write files to-and-from PL/SQL?

656


What is db journal file?

521


Do we need to create index on primary key?

468


Can we write dml inside a function in sql server?

501


What is right join sql?

536






How do you explain an index?

791


what happens when the column is set to auto increment and you reach the maximum value for that table? : Sql dba

578


What is having clause in sql?

529


What does a pl/sql package consist of?

518


What are the types of records?

537


Can we connect to postgresql using sql developer?

489


What is union and union all keyword in sql?

568


What is pl sql code?

593


How do you determine the current isolation level? : Transact sql

584


What is nosql db?

546