View Single Post

   
  #1 (permalink)  
Old 02-28-2008, 11:29 AM
anne001
 
Posts: n/a
Default how to add a primary key to a table


show columns from score, where student_id is a foreign key to one
table, and event_id a foreign key to another.

+------------+------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default |
Extra |
+------------+------------------+------+-----+---------+-------+
| student_id | int(10) unsigned | NO | PRI | |
|
| event_id | int(10) unsigned | NO | PRI | |
|
| score | int(11) | NO | | |
|
+------------+------------------+------+-----+---------+-------+


this blog gives the recipee, but it does not work for me
http://www.jroller.com/dschneller/en...primary_key_to

mysql> ALTER TABLE child
-> ADD COLUMN child_id BIGINT(20) AUTO_INCREMENT NOT
NULL FIRST,
-> ADD PRIMARY KEY(child_id);

alter table score
-> add column id bigint(2) auto_increment not null
first,
-> add primary key(id);
ERROR 1068 (42000): Multiple primary key defined

what do I need to do to add a primary key to this table?

Reply With Quote