| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Composite primary key
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
![]()  | 
![]()  |