Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Composite primary key

Re: Composite primary key

From: Brian Peasland <peasland_at_edcmail.cr.usgs.gov>
Date: Tue, 9 Nov 1999 13:54:43 GMT
Message-ID: <382827A3.D14E3CC@edcmail.cr.usgs.gov>


You have to use a table constraint, not a column constraint. If I have this table:   

   t1: c1 NUMBER

          c2   NUMBER
          c3   VARCHAR2(20)

and I want the primary key to be the c1 & c2 columns, I would create the table with the following script:

CREATE TABLE t1 (

   c1 NUMBER,
   c2 NUMBER,
   c3 VARCHAR2(20)
   PRIMARY KEY (c1,c2));

HTH,
Brian

"Anson To, Chi-hang" wrote:
>
> Hi,
>
> I'm a novice database developer having problem in creating tables. I'd like to
> know how to create a composite primary key in Oracle, that is, primary key
> consisting of more than one attributes. I can't find this in the documentation...
>
> Would you please reply by email as I can't access newsgroup easily.
> Many many thanks in advance for your generous help!
>
> Sincerely yours, Anson
Received on Tue Nov 09 1999 - 07:54:43 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US