db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel John Debrunner <...@apache.org>
Subject Re: how do you make a column a primary key later?
Date Thu, 20 Mar 2008 18:52:35 GMT
Amir Michail wrote:
> Hi,
> 
> I would like to reference a column in another table but that column is
> not designated as a primary key and unfortunately referring to it
> explicitly results in this error:
> 
> ERROR XSCH5: In a base table there was a mismatch between the
> requested column number 6 and the maximum number of columns 7.

That sounds like a bug, can you provide a script to reproduce it?

> So is there a way to make a column a primary key?  alter table
> table_name alter column column_name primary key doesn't work.

I think you need to add it as a table level constraint.

here's some examples:

ALTER TABLE WAREHOUSE ADD CONSTRAINT
     WAREHOUSE_PK PRIMARY KEY (W_ID);

ALTER TABLE DISTRICT ADD CONSTRAINT
     DISTRICT_PK PRIMARY KEY (D_W_ID, D_ID);

Dan.

Mime
View raw message