Adding column to an exiting primary key

0 pts.
Tags:
Oracle 9i
We have a table which already has a primary key. We want to make this have a composite primary key with another column. Is there any other way to do this without dropping the primary key and recreating a composite PK. Thanks in advance.
ASKED: May 26, 2004  3:55 PM
UPDATED: May 26, 2004  4:24 PM

Answer Wiki

Thanks. We'll let you know when a new response is added.

The only way I know of is to drop and re-crwatethe index with the new column names.

Discuss This Question: 4  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Hopkihc
    Hi. See how you can have only one primary key per table, you'd have to drop the original and then create the new one. May I ask why is this a concern? -John
    0 pointsBadges:
    report
  • PRASAD55
    We have other tables that refer to this table on which we need to build a composite key. Dropping the Pk (with cascade) would also mean we need to recreate other FK's too. Regards
    0 pointsBadges:
    report
  • Jwcdba
    If you need to change the primary key then the foreign keys will need to be changed also since you would not be able to renable the foreignkeys since there would not be a parent key for it.
    0 pointsBadges:
    report
  • Hopkihc
    Hi again. Well, assuming your foreign keys reference the single-column primary key, then you'd _have_ to drop and recreate them as well, because your foreign key columns will have to correspond to your new primary key columns. This can be scripted relatively simply (by querying the data dictionary) and should not be painful. Unless your foreign keys don't reference the new primary key columns? If that's the case, I think you can put a unique key constraint on the original primary key column and then drop and recreate the primary key.
    0 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following