SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Wizard
    Join Date
    May 2012
    Posts
    1,087
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Post Need help for creating multiple PK on the table

    Hi, I need some help regarding on my created table...I already created table in my database with 5 columns but i forgot to put PK on my table and i want to have 3 PK on my table is this possible in one table with 3 PK,if it is possible can you please help me how to put PK on my table.

    Thank you in advance.

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,494
    Mentioned
    161 Post(s)
    Tagged
    4 Thread(s)
    You can have only one PK on a table, but you can define more unique indexes on the same table.
    So you would have one PK and two unique indexes.

    Just to be complete: you can also have a PK on three columns.

    Read this page of the manual to see how you can add the PK/indexes to an existing table: http://dev.mysql.com/doc/refman/5.5/en/alter-table.html

  3. #3
    SitePoint Enthusiast
    Join Date
    Jul 2007
    Location
    San Sebastian, Spain
    Posts
    93
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    To be a bit more precise, a primary key, is the same as a unique key but the columns must also be marked as NOT NULL.


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
  •