[英]Error changing MySQL column to AUTO_INCREMENT
Here is my current table design: 这是我当前的表格设计:
I have several columns and no KEYs set, so when I try the following command: 我有几列,并且没有设置键,因此当我尝试以下命令时:
ALTER TABLE users MODIFY COLUMN id INT auto_increment;
it gives me an error. 这给了我一个错误。 I want the id column in the table to auto-increment and I want it to start with 1.
我希望表格中的id列自动递增,并希望它以1开头。
您必须使用AUTO_INCREMENT
指定PRIMARY_KEY
:
ALTER TABLE users MODIFY id INT PRIMARY_KEY AUTO_INCREMENT;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.