MySQL 5.5 报错"ERROR 1075 (42000): Incorrect table definition"
发表于:2026-11-02 作者:千家信息网编辑
千家信息网最后更新 2026年11月02日,--给表增加自增字段的时候报错mysql> desc t7;+-------+-------------+------+-----+---------+-------+| Field | Type |
千家信息网最后更新 2026年11月02日MySQL 5.5 报错"ERROR 1075 (42000): Incorrect table definition"--给表增加自增字段的时候报错
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
报错原因:自增字段没有被定义为一个key。
解决办法:可以将新增字段定义为unique key或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
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
报错原因:自增字段没有被定义为一个key。
解决办法:可以将新增字段定义为unique key或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
字段
办法
原因
时候
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
西安纸贵互联网科技有限公司
鸠鸠互联网科技
重庆互联网络科技
唐信互联网科技
郑州华宇互联网科技
互联网科技咨询
海南购全球互联网科技
互联网科技创新企业排名
互联网 科技馆
云创客互联网科技公司
央行互联网金融科技公司
本届互联网博览会上的黑科技
玉溪新华互联网科技好不好
长沙互联网科技
广州百诚互联网科技有限公司官网
互联网领先科技宣传片
富国互联网科技002692
上海互联网科技公司ppt
北京品多多互联网科技有限公司
株洲百竞科技的互联网营销顾问
迪茉互联网科技
壹账通互联网科技
奔汉互联网科技
互联网 新科技
成都互联网科技公司100强
顶级互联网科技成果有哪些
保险科技服务互联网营销体系
城市宝互联网科技有限公司
互联网科技创新方面的资料
科技美学互联网 艺术