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
 

 

Difference between primary key and index key

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

New User


Joined: 20 Dec 2006
Posts: 1
Location: chennai

PostPosted: Wed Dec 20, 2006 8:36 pm    Post subject: Difference between primary key and index key
Reply with quote

what is the difference between primary and index key?
i had so much of confusion in this.please clear my doudt.
Back to top
View user's profile Send private message

khamarutheen

Active Member


Joined: 23 Aug 2005
Posts: 680
Location: NJ

PostPosted: Wed Dec 20, 2006 9:16 pm    Post subject: DB2 Query
Reply with quote

Primary key is a unique key that is a part of the definition of a table. Where there wont be any null values ...

index key is the set of columns in a table that is used
to determine the order of index entries. This key may hold null values ...
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Wed Dec 20, 2006 9:24 pm    Post subject: Re: Difference between primary key and index key
Reply with quote

Hello bhanu

I will assume this is a DB2 question, not JCL. Should post in the DB2 forum.

In a DB2 table, a Primary Key uniquely identifies the row, no two rows can have the same Primary Key value. (A Primary Key is not required, but you can only have 1).

An Index Key can be unique, or not. In an Index Key you can have multiple Rows with the same Index Key Value.

An example.

Employee table;

Employee_Number
Last_name
First_Name
Department
SSN

The Primary key could be Employee_Number, There can only be one employee with this number.

Index_Key_1 could be Department, There can be many Employees in the same department.

Index_Key_2 could be SSN (U.S. Social Security Number). This is not the Primary Key, but it is Unique, so you would declare this Index Key as being Unique.

Index_Key_3 could be a concatenation of Last_Name/First_Name. This could result in multiple rows having the same Index Key Value.

Dave
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 setting new limit Key values for inde... srilata83 DB2 1 Fri Feb 10, 2017 9:24 pm
No new posts Difference between TWALENG and TWASIZE Arunkumar Chandrasekaran CICS 3 Tue Jan 03, 2017 12:57 pm
No new posts Order BY AND Index Nileshkul DB2 2 Sat Dec 31, 2016 6:33 pm
No new posts Sticky: difference between ... DUMMY ... and ... enrico-sorichetti JCL & VSAM 0 Mon Oct 17, 2016 4:31 pm
No new posts Several errors during building altern... Andi1982 JCL & VSAM 11 Wed Jul 06, 2016 7:39 pm


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