View previous topic :: View next topic
|
Author |
Message |
Debasis Misra Warnings : 1 New User
Joined: 16 Sep 2008 Posts: 72 Location: Bangalore
|
|
|
|
1. Is it possible that a single coloumn is defined as unique index?
2. Is it possible a unique index set contains no primary key or partial primary key? |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
I'm no DB2 person, but
1) Why would you not think it possible -- as long as a single column consists of unique values, a unique index on that column makes sense
2) Even I know that a unique index can be built on a table without a primary key, so obviously the answer is yes |
|
Back to top |
|
|
Debasis Misra Warnings : 1 New User
Joined: 16 Sep 2008 Posts: 72 Location: Bangalore
|
|
|
|
Thanks Robert!
But I have a doubt:
Then what is the main difference between the Unique Index field and primary key? |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
I believe the answer is constraints ... primary key is restricted in some ways that unique indexes aren't. |
|
Back to top |
|
|
Gnanas N
Active Member
Joined: 06 Sep 2007 Posts: 792 Location: Chennai, India
|
|
|
|
Unique Index allows one null, where primary key doesn't. |
|
Back to top |
|
|
Raghu navaikulam
Active User
Joined: 27 Sep 2008 Posts: 193 Location: chennai
|
|
|
|
Dear Debasis
Apart from what Robert and Gnanas had already explained in their post
there are a few more differences exists between Unique index and Primary Index.
You can have as many as (practically beyond the range of an application program ) Unique indexes in a table but only one Primary index. Primary index in the sense - index created on primary key.
For applying Referential Constraints between tables, you must have a primary key and primary index on the parent table, but unique index will not help. Unique index will help to make the value in the associated column as unique.
Regards
Raghu |
|
Back to top |
|
|
|