Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: URGENT: Primary key vs Unique Index
In previous post Mars <mars_at_mediadata.com.sg> wrote:
>Bill Bearden wrote:
>>
>> There are two important differences between Primary and Unique Keys.
>>
>> 1. There can only be one Primary Key on a table. There can be more than
>> one column with Unique Key.
>> 2. Primary Key columns can't contain NULL. Unique Key columns can.
>>
>Pardon my ignorance but why can't a primary key be NULL ? Is it a rule
>or is it specific to just Oracle ?
It is a rule that is applicable to any well-behaved relational database.
Only Primary Keys can become foriegn keys in another table. To prevent an ambiguity as to which row the foriegn key is pointing, you really shouldn't (and yoiu can't, in Oracle) create nullable foriegn keys. Therefore, the easiest way to insure that you do not create nullable foriegn keys is to insure that 1) you only can create foriegn keys from primary keys and 2) you cannot create a primary key from nullable columns.
'Keystroke'
Jack L. Swayze Sr.
Sr. Data Analyst
Koch Materials Co.
(a business unit of Koch Industries, Inc.)
Personal: Keystrk_at_Feist.com
Work: SwayzeJ_at_KochInd.com
Anything stated herein is the sole opinion of Jack Swayze, and is not to be considered the position of Koch Industries. Received on Wed Feb 26 1997 - 00:00:00 CST