"vj_dba" <vi******@gmail.comwrote in message
news:11**********************@i3g2000cwc.googlegro ups.com...
Hi Group,
I have a Primary key in my table. It's clear Primary key wont allow
duplicates, this primary key creates one index for retrival. Suppose if
my table is having a Unique index also. Then what is the exact
difference between the Primary key and the Unique index?
Also which on data retrival..internally it uses the Primary key index
or the Unique index...also which method is faster? Kindly excuse if
concept is wrong...
Actually I want the clear idea about the Unique index and the Primary
Key....
Thanks in advance,
Vijay.
If you already created a PK, and then try to create a unique index on the
same columns, DB2 will tell you that a unique index already exists on those
columns, and it will not create a second index.
If you create a table without a PK, then create a unique index, then alter
the table to create a PK on the same columns as the unique index, DB2 will
tell you that it is using the existing unique index for the primary key
(this is a warning message only). This can be useful if you want to define
the index as clustering, change the percent free, etc, because you cannot
alter an index in DB2 for LUW once it is created (unlike DB2 for z/OS).