错误1075:错误的表格定义;只能有一个自动列,并且必须将其定义为键 [英] ERROR 1075: Incorrect table definition; there can be only one auto column and it must be defined as a key

查看:1420
本文介绍了错误1075:错误的表格定义;只能有一个自动列,并且必须将其定义为键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试更改表" 我还需要一个AI领域,而不是关键... 列表"

I try to "alter Table" I need one more AI field, not key... "List"

ID INT(11):PK Not Null AutoIn..
Name VARCHAR
UserID INT(11):FK Not Null
edit BOOL

现在我还需要一个字段"sortpos"作为AI. 我在MySQL Workbench上尝试过

and now i need one more field "sortpos" as AI. I try it with MySQL Workbench

ALTER TABLE `**mydb**`.`List` 
ADD COLUMN `sortpos` INT(11) NOT NULL AUTO_INCREMENT AFTER `edit`;

你能帮我吗?

Thx

推荐答案

您无法获得比这更好的错误消息.您已经在表中将 ID 定义为自动增量.现在,您尝试添加另一个不允许自动递增的字段 sortpos . 一个表只能有一个自动增量,必须将其定义为主键.

You can't get better error message than this one. You already have ID defined as Auto Increment in your table. Now you are trying to add another field sortpos as auto increment which is not allowed. One table can only have one auto increment which must be defined as primary key.

从alter语句中删除AUTO_INCREMENT并创建一个触发器以增加新列.

Remove AUTO_INCREMENT from the alter statement and create a trigger to increment the new column.

这篇关于错误1075:错误的表格定义;只能有一个自动列,并且必须将其定义为键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆