Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Maximum number of column in Composite Primary Key

Arun Kumar GuptaJan 16 2007 — edited Jan 16 2007
Hi
I have read that composite primary key can contain maximum of 32 columns (Oracle 9i).

However I am able to create a primary key on 33 columns. It fails to create primary key on 34 columns. Below are the queries.

DROP TABLE XYZ;

CREATE TABLE XYZ
( N1 NUMBER
,N2 NUMBER
,N3 NUMBER
,N4 NUMBER
,N5 NUMBER
,N6 NUMBER
,N7 NUMBER
,N8 NUMBER
,N9 NUMBER
,N10 NUMBER
,N11 NUMBER
,N12 NUMBER
,N13 NUMBER
,N14 NUMBER
,N15 NUMBER
,N16 NUMBER
,N17 NUMBER
,N18 NUMBER
,N19 NUMBER
,N20 NUMBER
,N21 NUMBER
,N22 NUMBER
,N23 NUMBER
,N24 NUMBER
,N25 NUMBER
,N26 NUMBER
,N27 NUMBER
,N28 NUMBER
,N29 NUMBER
,N30 NUMBER
,N31 NUMBER
,N32 NUMBER
,N33 NUMBER
,N34 NUMBER
,N35 NUMBER
,N36 NUMBER
,N37 NUMBER
,N38 NUMBER
,N39 NUMBER
,N40 NUMBER
,N41 NUMBER
,N42 NUMBER
,N43 NUMBER
,N44 NUMBER
,N45 NUMBER
,N46 NUMBER
,N47 NUMBER
,N48 NUMBER
,N49 NUMBER
,N50 NUMBER
);


ALTER TABLE XYZ ADD CONSTRAINT XYZ_PK PRIMARY KEY
( N1,N2,N3,N4,N5,N6,N7,N8,N9,N10,N11,N12,N13,N14
,N15,N16,N17,N18,N19,N20,N21,N22,N23,N24,N25,N26
,N27,N28,N29,N30,N31,N32,N33,N34);

ALTER TABLE XYZ ADD CONSTRAINT XYZ_PK PRIMARY KEY
( N1,N2,N3,N4,N5,N6,N7,N8,N9,N10,N11,N12,N13,N14
,N15,N16,N17,N18,N19,N20,N21,N22,N23,N24,N25,N26
,N27,N28,N29,N30,N31,N32,N33);

Can someone let me know the lmit of maximum no. of columns in Primary Key?

Regards
Arun
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 13 2007
Added on Jan 16 2007
10 comments
5,477 views