Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Unique index set contains no primary key or partial primary

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: Unique index set contains no primary key or partial primary
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: 8120
Location: East Dubuque, Illinois, USA

PostPosted: Thu Mar 26, 2009 6:37 pm    Post subject:
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    Post subject:
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: 8120
Location: East Dubuque, Illinois, USA

PostPosted: Thu Mar 26, 2009 7:06 pm    Post subject:
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: 788
Location: Chennai, India

PostPosted: Thu Mar 26, 2009 7:52 pm    Post subject:
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    Post subject: Reply to: Unique index set contains no primary key or partia
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts How to generate a new unique Input fi... for1ranjith CLIST & REXX 11 Sat Jul 01, 2017 12:09 pm
No new posts SQL - select data available in index Nileshkul DB2 3 Mon Jun 26, 2017 1:30 am
No new posts setting new limit Key values for inde... srilata83 DB2 1 Fri Feb 10, 2017 9:24 pm
No new posts Order BY AND Index Nileshkul DB2 2 Sat Dec 31, 2016 6:33 pm
No new posts Command UNIQUE CONSTRAINT on any tabl... rohanthengal DB2 2 Thu Aug 18, 2016 3:48 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us