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

Difference between primary key and unique key


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
rajesh822
Currently Banned

New User


Joined: 22 Sep 2005
Posts: 5

PostPosted: Mon Oct 10, 2005 12:47 am
Reply with quote

what is the difference between primary key and unique key?
Back to top
View user's profile Send private message
radhakrishnan82

Active User


Joined: 31 Mar 2005
Posts: 435
Location: chennai, India

PostPosted: Mon Oct 10, 2005 10:21 am
Reply with quote

Primary Key is Unique and NotNull
UniqueKey --The Values should be Unique and can be null even

for further info on this one,please search the previous posts in this forum.

hope this helps.
Back to top
View user's profile Send private message
SWAPNA LATHA

New User


Joined: 13 Jun 2005
Posts: 3

PostPosted: Sat Oct 15, 2005 4:06 pm
Reply with quote

one more addition to the above question......
if unique key allows null values and more than one record has null entries,then how is uniqueness maintained?????
Back to top
View user's profile Send private message
radhakrishnan82

Active User


Joined: 31 Mar 2005
Posts: 435
Location: chennai, India

PostPosted: Sat Oct 15, 2005 4:35 pm
Reply with quote

swapna latha,

Unique can have only one null value.

Pls refer this previous posts.
http://ibmmainframes.com/about5855.html&highlight=unique+key

hope this helps.
Back to top
View user's profile Send private message
SWAPNA LATHA

New User


Joined: 13 Jun 2005
Posts: 3

PostPosted: Mon Oct 17, 2005 10:40 am
Reply with quote

thanks radhakrishna

this answers my query...
Back to top
View user's profile Send private message
nijugopalan

New User


Joined: 15 Oct 2005
Posts: 15
Location: pune

PostPosted: Thu Oct 20, 2005 7:58 pm
Reply with quote

all the keys used in the table which have unique values are unique keys.while the unique key which is selected to identify records is the primary key while all other keys are alternate keys.

ALL PRIMARY KEYS ARE UNIQUE KEYS WHILE ALL PRIMARY KEYS CANNOT BE AN UNIQUE KEYS.

THIS IS CORRECT NAA. MY FREINDS. icon_lol.gif
Back to top
View user's profile Send private message
ravisan
Warnings : 1

New User


Joined: 13 Sep 2005
Posts: 13
Location: chennai

PostPosted: Mon Oct 24, 2005 3:08 pm
Reply with quote

One more differance is there......

A table may contains no of unique key. But it must contains only a primery key


Regards,
Ravisan
Back to top
View user's profile Send private message
khamarutheen

Active Member


Joined: 23 Aug 2005
Posts: 677
Location: NJ

PostPosted: Wed Oct 26, 2005 6:27 pm
Reply with quote

hi frnd,
the primary key is let active when any the unique index is create. its same like unique value. ie., the unique key can have only one null value and it cannot have any foreign key ref. as the primary key cannot have a null value and can have ref to any foreign key. hope enough
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 Timestamp difference and its average ... DB2 11
No new posts Difference when accessing dataset in ... JCL & VSAM 7
No new posts Cobol prog to put an indicator on the... JCL & VSAM 1
Search our Forums:

Back to Top