Home » RDBMS Server » Server Administration » Difference between Primary key and Unique&notnull on a col
Difference between Primary key and Unique&notnull on a col [message #375245] Wed, 08 August 2001 11:33 Go to next message
Srihari
Messages: 22
Registered: October 2000
Junior Member
May I Know the difference between a column defined as primary key with another column of the same table defined as Unique and not null.
When both the column can be referenced by a Foreign keys of then what is need for primary key?
Re: Difference between Primary key and Unique&notnull on a col [message #375246 is a reply to message #375245] Wed, 08 August 2001 12:16 Go to previous message
andrew again
Messages: 2577
Registered: March 2000
Senior Member
there are 3 alternatives to consider:
1.) Primary key - consists of a constraint of type 'P'=primary and a unique index.
2.) Unique constraint - consists of a constraint of type 'U'=unique and a unique index.
3.) Unique index.

in 1 & 2 you can disable the constraint in which case the unique index gets dropped, but the constraint remains (in a DISBALED state). When you re-enable the constraint, the index is re-created. 1 always has NOT NULL as a requirement, 2 does not. 1 corresponds to a requirement from relational theory. A table can only have one PK, but could have several Unique constraints. Stick to 1 for primary keys.
Previous Topic: Oracle 8i DBA OCP cd CBT's for sale
Next Topic: Re: Simple Update
Goto Forum:
  


Current Time: Fri Jul 05 11:22:43 CDT 2024