|
Home > Archive > MySQL Server Forum > August 2005 > add primary keys to a table one-time and there are already
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
add primary keys to a table one-time and there are already
|
|
| Lucas Gump 2005-08-07, 3:23 am |
| Is it possible to add primary keys to a table one-time and there are
already
multiple primary key defined?
I have to change sp_id, so_id as primary keys to the existing primary
keys
dn_slot_id and dn_mm_id.
I tried several times but all failed:
1. alter table debit_slot_detail add primary key (sp_id, so_id);
2. alter table debit_slot_detail add primary key (dn_slot_id, dn_mm_id,
sp_id, so_id);
thanks in advance for any help
| |
| Bill Karwin 2005-08-07, 8:23 pm |
| Lucas Gump wrote:
> Is it possible to add primary keys to a table one-time and there are
> already
> multiple primary key defined?
A table can have only one primary key (it counts as one if that key is a
"compound key" comprised of multiple columns in the table). To add a
new primary key, or change the columns that comprise the key, you have
to drop the old one first. There is another usage of ALTER TABLE for this.
Regards,
Bill K.
|
|
|
|
|