SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    chown linux:users\ /world Hartmann's Avatar
    Join Date
    Aug 2000
    Location
    Houston, TX, USA
    Posts
    6,455
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)

    Drop a single key out of a composite?

    I have a composite primary key made up of 2 foreign keys and a primary key. I need to drop the single primary key (in this case "page_num") but I cannot figure out how to do it and there's no documentation at mysql.com.

    Any ideas?

  2. #2
    Tranceoholic lilleman's Avatar
    Join Date
    Feb 2004
    Location
    Írebro, Sweden
    Posts
    2,716
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    Perhaps this could be what you're looking for?

    Code:
    ALTER TABLE tbl_name DROP PRIMARY KEY,
      ADD PRIMARY KEY (first_field, second_field);
    ERIK RIKLUND :: Yes, I've been gone quite a while.

  3. #3
    chown linux:users\ /world Hartmann's Avatar
    Join Date
    Aug 2000
    Location
    Houston, TX, USA
    Posts
    6,455
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    Nope. I get an error as it's trying to "rename tables"...

  4. #4
    Tranceoholic lilleman's Avatar
    Join Date
    Feb 2004
    Location
    Írebro, Sweden
    Posts
    2,716
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    I just tried the query on a simple test table, and it worked for me...
    ERIK RIKLUND :: Yes, I've been gone quite a while.

  5. #5
    chown linux:users\ /world Hartmann's Avatar
    Join Date
    Aug 2000
    Location
    Houston, TX, USA
    Posts
    6,455
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    It didn't work but I figured out a way to do it... The foreign keys were keeping it from being dropped.


Bookmarks

Posting Permissions

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