Altering a primary Key Constraint which is referred by foreign Key Constraint.

  • Hi,

    I have a table Item with a Primary Key Constraint. A foreign key is created with 6 other tables referring Item's Primary key. I want to include another column in the Primary Key. I tried disabling the foreign key and primary key but i am not able to drop the primary key from the Item table.

    Can someone please suggest how to alter the primary without dropping the foreign key? Is that possible?

  • nope, you have to drop the foreign keys that reference the PK, then drop the PK, then recreate a new PK and -the foreign keys so they now feature the new two column constraint.
    if you wanted the foregin key to reference just one part of the  new-multi column PK, then you need a unique constraint on that column for the FK to attach to.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply