What is the difference between UNIQUE KEY and UNIQUE INDEX?
Answers were Sorted based on User's Feedback
Answer / 1
There is a clear difference between the 2. A unique
constraint defines what combination of columns has to be
unique. A unique index is just a way of making sure the
above is always valid. But it's possible to have a non-
unique index supporting a unique constraint. (if the
constraint is deferable = Only has to be valid at commit
time but is allowed to be broken in the middle of a
transaction)
Is This Answer Correct ? | 1 Yes | 0 No |
Answer / varsha
A UNIQUE Key grantees Unique values to a column but does not sort the column data, whereas A UNIQUE Index grantees Unique values to a column and also sorts the column data.
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / 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 |
how to include numeric values in sql statements? : Sql dba
Differentiate between % rowtype and type record.
table name: prod there are three fields in the table that are 1.proddate 2.prodQty 3.model Day wise prodQty is stored in the table prod write a query to display total prodqty in the year 2004 april.
Why do we use view in sql?
Do triggers have restrictions on the usage of large datatypes, such as long and long raw?
one of the column in my table contains the data like SAL ---- 1000 1000 2000 3000 3000 So my requirement is i want output like SAL --- 1000 2000 3000 it mean i want to delete duplicate rows only how should u write query?
What are the various levels of constraints?
What are records give examples?
Describe the Index, Types of index, At what situation we have used? Which one s better than others?
How can we debug in PL/SQL?
How does one load ebcdic data? : aql loader
How can you load multi line records? : aql loader