ERROR 1075: Incorrect table definition; there can be only one auto column and it must be defined as a key

前端 未结 2 567
刺人心
刺人心 2021-01-28 03:32

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
         


        
2条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-28 04:06

    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.

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

提交回复
热议问题