View previous topic :: View next topic
|
Author |
Message |
imain Warnings : 1 New User
Joined: 25 Jun 2006 Posts: 14 Location: US
|
|
|
|
Hi All,
Can anybody tell me the exact difference between primary key and unique key.
thanks in advance
imain |
|
Back to top |
|
|
guptae
Moderator
Joined: 14 Oct 2005 Posts: 1208 Location: Bangalore,India
|
|
|
|
Hi Imain,
For a db2 table primary key can only be 1 but unique key can be more than 1.
Index is created for primary key |
|
Back to top |
|
|
neelesht
New User
Joined: 24 Jul 2006 Posts: 99 Location: Los Angeles
|
|
|
|
Hi Imain,
Primary key can never have value NULL but Unique key can have NULL value.
Enjoy....
Neelesh |
|
Back to top |
|
|
cheetz007
New User
Joined: 10 Aug 2006 Posts: 23
|
|
|
|
Isn't it simpler than that? A primary key is the ONLY "real" key to a table - the table is indexed on the primary key. A unique key is any column or combination of columns that MUST have a unique value. The table may or may not be indexed on a unique key... that's up to the DBA and the usage requirements of a table. In effect, a "key" is nothing more than a value (or values) that can be contained within a column.
Clear as mud? |
|
Back to top |
|
|
|