If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > add / drop primary key

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-05-04, 09:59
alvincks alvincks is offline
Registered User
 
Join Date: Mar 2004
Posts: 74
add / drop primary key

hi, good day, i have a question on primary key , currently, i have a table call "newcampaign" which already contain a primary key, named "cam_code", now let say i want to add another primary key"cam_name" to existing "newcampaign" table ,

so i using
Code:
alter table newcampaign add PRIMARY KEY (cam_name);");
but it give me error , say multiple primary key defined

so i need to drop all primary key before add both of primary key (cam_name,cam_code)?


another question is , if the table consist of 3 primary key, now i want to drop only one of the primary key , what should i do ? thank you very much !!
Reply With Quote
  #2 (permalink)  
Old 12-05-04, 11:02
healdem healdem is online now
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,262
you can only have one primary key per table, as far as I'm aware. However you can create other keys which have unique values.

If you want to set another key as primary key then youwillneed todelete the old index first, and the add the new index

You may find it easier to do this through soemthing like MySQL admin, dbtools or PHPAdmin
HTH
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On