国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數據庫 > MySQL > 正文

MySQL5.5報錯ERROR 1075 42000 Incorrect table definition

2024-07-24 12:31:32
字體:
來源:轉載
供稿:網友
      --給表增加自增字段的時候報錯
 
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

(編輯:武林網)

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 托克托县| 高邑县| 乌兰察布市| 明溪县| 栾川县| 苗栗市| 宜兰县| 酉阳| 万盛区| 新泰市| 甘孜县| 周宁县| 陆良县| 长治县| 承德市| 和静县| 永胜县| 浙江省| 昌黎县| 桐庐县| 米易县| 松原市| 邵东县| 张北县| 邹平县| 正定县| 黑龙江省| 伊宁市| 永宁县| 沭阳县| 界首市| 达州市| 从江县| 荔波县| 历史| 滦平县| 鸡东县| 贵州省| 天津市| 吉林省| 新野县|