IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Unique index set contains no primary key or partial primary


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Debasis Misra
Warnings : 1

New User


Joined: 16 Sep 2008
Posts: 72
Location: Bangalore

PostPosted: Thu Mar 26, 2009 6:29 pm
Reply with quote

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
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Thu Mar 26, 2009 6:37 pm
Reply with quote

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
View user's profile Send private message
Debasis Misra
Warnings : 1

New User


Joined: 16 Sep 2008
Posts: 72
Location: Bangalore

PostPosted: Thu Mar 26, 2009 7:04 pm
Reply with quote

Thanks Robert!

But I have a doubt:

Then what is the main difference between the Unique Index field and primary key?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Thu Mar 26, 2009 7:06 pm
Reply with quote

I believe the answer is constraints ... primary key is restricted in some ways that unique indexes aren't.
Back to top
View user's profile Send private message
Gnanas N

Active Member


Joined: 06 Sep 2007
Posts: 792
Location: Chennai, India

PostPosted: Thu Mar 26, 2009 7:52 pm
Reply with quote

Unique Index allows one null, where primary key doesn't.
Back to top
View user's profile Send private message
Raghu navaikulam

Active User


Joined: 27 Sep 2008
Posts: 193
Location: chennai

PostPosted: Fri Mar 27, 2009 12:07 am
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Query on edit primary command CLIST & REXX 5
No new posts Query on edit primary command CLIST & REXX 1
No new posts Cobol file using index COBOL Programming 2
No new posts Cobol prog to put an indicator on the... JCL & VSAM 1
No new posts Find the occurrence of Key Field (Par... DFSORT/ICETOOL 6
Search our Forums:

Back to Top