我通过互联网查看的效果不是很好。
这是我的表:
+------------------+---------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------------+---------+------+-----+---------+----------------+
| jobid | int(11) | NO | PRI | NULL | auto_increment |
| locid | int(11) | YES | | 0 | |
| userid | int(11) | YES | | 0 | |
| createdate | int(11) | YES | | 0 | |
| jobapplicationid | int(11) | YES | | NULL | |
+------------------+---------+------+-----+---------+----------------+
5 rows in set (0.00 sec)
我想从其原始jobid更改自动增量主键到jobapplicationid
我尝试alter table jobs_applications drop primary key jobid
但没有成功。
非常感谢任何帮助。
答案 0 :(得分:0)
-- remove pk
ALTER TABLE `jobs_applications` DROP PRIMARY KEY;
-- remove auto inc
ALTER TABLE `jobs_applications` CHANGE `jobid` `jobid` INT(11) UNSIGNED NOT NULL;
-- set pk and auto inc to the other column
ALTER TABLE `jobs_applications` CHANGE `jobapplicationid` `jobapplicationid` INT(11)AUTO_INCREMENT PRIMARY KEY;