Monday, March 19, 2012

Composite Primary Key Constraint

Hi All,

I have a table that has 3 columns, two of them make a composite primary key. The table is populated with data. What I need to do is to add a third column to a composite primary key. I have tried to do that with the following command:

alter table databasesize
add constraint pk_dbsize primary key (dbid)

But I get the error message:

Table 'databasesize' already has a primary key defined on it.

How can I do this?You'll need to drop the existing primary key, of course.

Try making the change using enterprise manager, and then scripting the change before you save it (there is a button in the alter database dialog box that will generate the script for you).|||Thanks. It worked.

No comments:

Post a Comment