Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2004
    Posts
    268

    Unanswered: 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?

  2. #2
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    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).
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  3. #3
    Join Date
    Jul 2004
    Posts
    268
    Thanks. It worked.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •