jemz — 2013-01-13T12:05:43-05:00 — #1
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.
guido2004 — 2013-01-13T12:49:29-05:00 — #2
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
rcashell — 2013-01-13T17:03:55-05:00 — #3
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.