Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

MySQL 5.5 error report & quot;ERROR 1075 (42000): Incorrect table definition"

2025-03-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

-- an error is reported when adding self-increasing fields to the table

Mysql > desc T7

+-+ +

| | Field | Type | Null | Key | Default | Extra | |

+-+ +

| | name | varchar (20) | YES | | NULL |

| | id | int (4) | YES | | NULL |

+-+ +

2 rows in set (0.00 sec)

Mysql > alter table T7 add id2 int (4) auto_increment

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

Cause of error: the self-increment field is not defined as a key.

Solution: you can define the new field as unique key or primary key.

Mysql > alter table T7 add id2 int (4) auto_increment primary key

Query OK, 0 rows affected (0.00 sec)

Records: 0 Duplicates: 0 Warnings: 0

Mysql > alter table T7 drop column id2

Query OK, 0 rows affected (0.01 sec)

Records: 0 Duplicates: 0 Warnings: 0

Mysql > alter table T7 add id2 int (4) auto_increment unique key

Query OK, 0 rows affected (0.00 sec)

Records: 0 Duplicates: 0 Warnings: 0

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report