原文网址:https://www.youyong.top/article/1158ce32812
有一次想更换一下主键,删除主键的时候报错了:ERROR 1075 (42000): Incorrect table definition; there can be only one auto column and it must be defined as a key。大致意思是:一张表只能由一个自增的列,并且必须定义为key, 也就是说想要更换主键,得先删除自增列。
原文网址:https://www.youyong.top/article/1158ce32812
有一次想更换一下主键,删除主键的时候报错了:ERROR 1075 (42000): Incorrect table definition; there can be only one auto column and it must be defined as a key。大致意思是:一张表只能由一个自增的列,并且必须定义为key, 也就是说想要更换主键,得先删除自增列。
原文网址:https://www.youyong.top/article/1158ce32812
1)去掉自增:
ID原来是这样的:
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '用户id',
去掉AUTO_INCREMENT:
alter table user modify column `id` int(10) unsigned NOT NULL COMMENT '用户id';
2)删除主键
alter table user drop primary key;
3)给另一个字断增加主键
alter table user add primary key(`mid`);
在给另一个字段(mid)添加主键之前,必须保证mid字段的值非空且唯一
作者声明:本篇文章系本人原创,欢迎分享,但未经许可,谢绝转载。
共 0 条留言
Ubuntu安装MySQL提示Depends: mysql-server-5.5 but it is not going
mysql-bin.00000* 文件误删删除导致mysql启动不起来
Linux screen 提示:There is no screen to be resumed matching
MySQL 上传报错#1064-You have an error in your SQL syntax
iPhone X 跌破发行价,苏宁200亿入股恒大 | 财经日日评
资深黄牛现身说法:iPhone X价格秒变不停,就像炒股一样
网站请求日志中的 article-expand tooltip_arrow article-contract 是什么
网络请求日志中的 apple-touch-icon.png 是什么?
又拍云上传图片503 put file capture error | put file to fs error
链接里的isappinstalled=0与isappinstalled=1有什么区别?|微信分享
手机扫一扫
分享文章