Whats the difference .. creating primary keys

NEOLLE
10-25-2004, 09:33 PM
Hello guys,
I am using Oracle9i.
Can somebody explain whats the difference between the two statements.

ALTER TABLE ORA5.SALES_REP
ADD CONSTRAINT PK_SLSREP PRIMARY KEY (SLSREP_NUMBER)
and
ALTER TABLE ORA5.SALES_REP
ADD PRIMARY KEY (SLSREP_NUMBER)
?
If theres anything basic I need to know, Ill be glad to know it. :)
Thanks..

Livid
10-25-2004, 10:27 PM
Hello guys,
I am using Oracle9i.
Can somebody explain whats the difference between the two statements.

ALTER TABLE ORA5.SALES_REP
ADD CONSTRAINT PK_SLSREP PRIMARY KEY (SLSREP_NUMBER)
and
ALTER TABLE ORA5.SALES_REP
ADD PRIMARY KEY (SLSREP_NUMBER)
?
If theres anything basic I need to know, Ill be glad to know it. :)
Thanks..

The first piece of code will add all of the constraits of PK_SLSREP to the Primary Key of the ORa5.Sales_Rep table

The second piece will simply add a normal Primary Key without any other restrictions.

NEOLLE
10-25-2004, 10:41 PM
Ok, thanks Livid. So which one is better?

Livid
10-25-2004, 11:07 PM
if you aren't sure what the first one does then i doubt u need the extra restrictions ... You will most likely only need this...


ALTER TABLE ORA5.SALES_REP
ADD PRIMARY KEY (SLSREP_NUMBER)


But it depends what ur trying to accomplish (the use for the database / restrictrictions / users / groups / privelages / exc.)

NEOLLE
10-25-2004, 11:53 PM
My concern is that Im using TOAD. Toad uses the statement with CONSTRAINT word. Before, I use SQLPlus and uses the other statement, without the CONSTRAINT word. Im not certain if problems or inconsistencies may arrise later. :confused:

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum