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
how to get a list of columns in an existing table? : Sql dba
What are the different types of triggers?
What is bulk collect in pl sql?
What are the different set operators available in sql?
How can you create an empty table from an existing table?
What are database links used for?
What is exit statement?
What is a sql instance vs database?
What does trigger mean in psychology?
What is the difference between python and sql?
What is data control language?
What is graph sql?
What is optimistic concurrency control? : Transact sql
What does fetching a cursor do?
How do I partition a table in sql?