Re: Primary Keys

From: Murray Kaiser <ae873_at_cfn.cs.dal.ca>
Date: 1995/04/10
Message-ID: <D6u694.Byq_at_cs.dal.ca>#1/1


Oberle, John F. (DPWCC02.OBERLE02_at_SSW.ALCOA.COM) wrote:
: Can someone tell me the significance of the primary key
: constraint. What are the advantages or disadvantages over
: creating unique indexes.
 

: Thanks in advance;
 

: John F. Oberle

--
An index created via the constraint cannot accidentally be drop by the

DROP INDEX index_name;

Oracle responds with

ORA-02429: cannot drop index used for enforcement of unique/primary key

Instead you must

ALTER TABLE table_name DROP PRIMARY KEY;

In addition, you can now set up foreign keys that reference the primary 
key without specifying what column they reference (automatically 
reference the primary key of the referenced table).

ALTER TABLE table_name ADD CONSTRAINT constraint_name
FOREIGN KEY (column_name) REFERENCES constraining_table_name;

This all assume you are interested in using constraints!

Murray Kaiser                 | Usual gutless disclaimer..  
Nova Scotia Power             |  Opinions are mine and not necessarily
(Murray.Kaiser_at_NSPower.NS.CA) | shared by my employer
Received on Mon Apr 10 1995 - 00:00:00 CEST

Original text of this message