MySQL 5.5 报错"ERROR 1075 (42000): Incorrect table definition"
发表于:2025-11-13 作者:千家信息网编辑
千家信息网最后更新 2025年11月13日,--给表增加自增字段的时候报错mysql> desc t7;+-------+-------------+------+-----+---------+-------+| Field | Type |
千家信息网最后更新 2025年11月13日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安全错误
数据库的锁怎样保障安全
深圳正规软件开发
南京交易软件开发报价
网络安全建党100周年
大匠通数据库
中国网络技术有限公司扣钱查询
python操作oracle数据库
dns服务器配置win7
计算机网络技术能找的工作
如何查看ntp服务器配置成功
广东网络安全产业促进会
网络安全防护建设需求
河北服务器搬家找哪家
鹿城区智能刀片服务器不二之选
网络安全法我的感想
网络巨头数据库
获取临床试验数据库
i华大网络技术中心赵思捷
数字化管理与数据库建设
华为服务器指示灯说明
服务器两根网线出口
上海通讯网络技术产品
数据库是什么专业学的课
杭州牛顿网络技术公司
数据库最高分最低分的差
网络技术产生的标志产物
平台软件开发多少钱聚顶科技
舟山新区软件开发定制
网络安全文明教育班会
和田网络安全技术批发
中兴国产化数据库怎么样