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
What does pragma mean?
How many types of literals are available in pl sql?
What is trigger and how to use it in sql?
What is union, minus and interact commands?
What are the differences between in and exists clause?
What is the syntax to add a record to a table?
Suppose a student column has two columns, name and marks. How to get name and marks of the top three students.
How do we accept inputs from user during runtime?
What is server name sql?
explain access control lists. : Sql dba
Which query operators in sql is used for pattern matching?
What is user defined functions?
what are the differences between char and nchar? : Sql dba
Why is sql important?
What is offset in sql query?