丢弃主键不起作用

时间:2015-06-28 06:48:59

标签: mysql

我想从我的表中删除主键约束:

mysql> alter table 'carpool' drop PRIMARY KEY, add PRIMARY KEY('pool_id');
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 ''carpool' drop PRIMARY KEY, add PRIMARY KEY('pool_id')' at line 1

1 个答案:

答案 0 :(得分:0)

您正在使用单引号('),Mysql将其解释为字符串而不是列。你需要使用后面的刻度线(`),它位于键盘1的左侧,或者根本不使用任何一个。

alter table carpool drop PRIMARY KEY, add PRIMARY KEY(pool_id);

alter table `carpool` drop PRIMARY KEY, add PRIMARY KEY(`pool_id`);
相关问题