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

What is the difference between rename and alias?

699


Is oracle sql free?

534


What is output spooling in sql*plus?

544


How do I truncate a word?

515


Can we join tables without foreign key?

518






Differentiate between % rowtype and type record.

721


Which tcp/ip port does sql server run on? How can it be changed? : Sql dba

486


How do I add a database to sql?

567


What are literals in sql server?

522


What is string join?

546


what is clause? : Sql dba

573


List the ways to get the count of records in a table?

503


What is snowflake sql?

573


How is data stored in sql?

545


Can instead of triggers be used to fire once for each statement on a view?

534