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
Can we join more than 2 tables in sql?
How to use sql*plus built-in timers?
Explain what is a database?
What are inner and outer joins examples of both?
Does postgresql run on the cloud?
Is it mandatory for the primary key to be given a value when a new record is inserted?
what is the difference between clustered and non clustered index in sql? : Sql dba
Where the sql database files are stored?
What are all the ddl commands?
how would concatenate strings in mysql? : Sql dba
How does a self join work?
What is the difference between a primary key and a unique key?
What is the command used to fetch the first 5 characters of a string?
What is a unique key and primary key and foreign key?
How do I partition in sql?