Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Can a table have more then one primary key

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
chandrasekhar

New User


Joined: 29 Sep 2004
Posts: 35
Location: bangalore

PostPosted: Wed Oct 20, 2004 8:28 pm    Post subject: Can a table have more then one primary key
Reply with quote

q1. Can a table have more then one primary key.

q2
. What is the diff. between unique key and primary key.

q3. is it necessary to creat a index for every table.

q4.Can a table resides under more then one tablespace .
Back to top
View user's profile Send private message

janardhana Reddy

New User


Joined: 20 Oct 2004
Posts: 17
Location: Bangalore

PostPosted: Thu Oct 21, 2004 3:36 pm    Post subject:
Reply with quote

Hi

1) Ans. One table should have only one primary key.
2) Ans. The main difference b/t unique key and primary key is null value.
Unique key may have null value.
3) Ans. If no index exists means you will not able execute some functions like count etc. To create path you need the index. If no index means there is no difference between flat file and database file..

4) no table can reside in more than one table space.
Back to top
View user's profile Send private message
khamarutheen

Active Member


Joined: 23 Aug 2005
Posts: 680
Location: NJ

PostPosted: Wed Nov 23, 2005 2:36 pm    Post subject: Primary key
Reply with quote

hi frnd,
one more thing is that unique key will have only one null value i think so.
but primary key will not have that too.

and if the primary key is created then u should need the unique index such that to activate the primary key.
Back to top
View user's profile Send private message
priya

Moderator


Joined: 24 Jul 2003
Posts: 568
Location: Bangalore

PostPosted: Wed Nov 23, 2005 2:55 pm    Post subject:
Reply with quote

Yes, you can have more than one columns as primary key. It's called as partial key.
Back to top
View user's profile Send private message
jontyjun

New User


Joined: 12 Sep 2006
Posts: 12
Location: India

PostPosted: Tue Aug 21, 2007 4:33 pm    Post subject: Reply to: Can a table have more then one primary key
Reply with quote

Hi Janardhana Reddy,

This is in regard to your answer: "3) Ans. If no index exists means you will not able execute some functions like count etc. To create path you need the index. If no index means there is no difference between flat file and database file.."

For Count You dont need an index at all... Verified it just now..

Regards,
Arjun.
Back to top
View user's profile Send private message
stodolas

Active Member


Joined: 13 Jun 2007
Posts: 632
Location: Wisconsin

PostPosted: Tue Aug 21, 2007 5:29 pm    Post subject:
Reply with quote

1) No - as has been stated but a primary key can be multiple columns
If you define a primary key with multiple columns, when you reference only one of those columns it is called a partial key

2) Primary key should be defined as the most commonly accessed key
Unique keys are ususually defined on columns other than the primary key. Think of them as alternate indexes on a VSAM with a uniqueness contraint. Although I have never heard them called Unique keys, usually they are called indexes.
3) No - but it will help performance
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 Update table without cursor Ron Klop DB2 3 Wed Oct 11, 2017 1:06 pm
No new posts Table(Unicode(Graphic) table) loading... muralikrishnan_new DB2 0 Thu Oct 05, 2017 5:10 pm
No new posts Insert a Row_number into table useit DB2 2 Tue Sep 19, 2017 1:07 pm
No new posts how to see when the last read access ... Mike 1304 DB2 1 Tue Sep 12, 2017 7:52 pm
No new posts PC (UTF-8) -> z/OS (EBCDIC) -> ... prino All Other Mainframe Topics 4 Fri Sep 01, 2017 1:47 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us