I've a table like this :
+-------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+---------+------+-----+---------+-------+
| num | int(11) | NO | PRI | NULL | |
| t | int(11) | YES | | NULL | |
+-------+---------+------+-----+---------+-------+
If I need to change the constraint of num from primary key to a unique key, What shall I do? I did:
alter table c2 modify num integer unique key;
output:
mysql> desc c2;
+-------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+---------+------+-----+---------+-------+
| num | int(11) | NO | PRI | NULL | |
| t | int(11) | YES | | NULL | |
+-------+---------+------+-----+---------+-------+
Another one :
alter table c2 drop constraint num;
output : ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'constraint num' at line 1
What else shall I use to change the primary key into a unique one???