MySQL 5.5 报错"ERROR 1075 (42000): Incorrect table definition"
发表于:2025-02-02 作者:千家信息网编辑
千家信息网最后更新 2025年02月02日,--给表增加自增字段的时候报错mysql> desc t7;+-------+-------------+------+-----+---------+-------+| Field | Type |
千家信息网最后更新 2025年02月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安全错误
数据库的锁怎样保障安全
武汉聚力汇通网络技术有限公司
辽宁高性能服务器
job数据库
文献数据库教育
汽车车型数据库sql
游戏软件开发地在哪里
hpe服务器ai管理工具
网游玩家数据库设计
萝岗区数据库修复
软件开发报哪个专业
django删除数据库表
网络安全自学可以么
qnap文档服务器
搜索数据库某个字段
php如何建立数据库
网络安全和国庆假期安全内容
战网服务器ip
永恒大陆服务器喇叭
学校网络安全管理制度
广东品质软件开发服务价格优惠
在服务器旁边呆久了有伤害吗
防网络安全教育讲稿
网络安全筑起五道 防火墙
单位有网络安全岗中级考啥
蚌埠供电公司网络安全
绥化网络安全宣传活动
齐治堡垒机的网络安全证书
交通大学网络安全教材
软件开发培训班怎么选
长沙交易软件开发哪家好