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> 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)
ERROR 1075 (42000): Incorrect table definition; there can be only one auto column and it must be defined as a 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
Query OK, 0 rows affected (0.00 sec)
Records: 0 Duplicates: 0 Warnings: 0
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26506993/viewspace-2082626/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- MySQL報錯Table 'plugin' is read only [ERROR] Can't open the mysql.plugin table.MySqlPluginError
- MySQL 5.5 原始碼安裝報錯"[ERROR] Can't start server"MySql原始碼ErrorServer
- MySQL DROP TABLE刪除表報錯'ERROR 1051 (42S02): Unknown table'MySqlError
- ORACLE匯出文字到MYSQL 報錯 Incorrect integer value: ''OracleMySql
- MYSQL SOURCE報錯 ERROR: ASCIIMySqlErrorASCII
- MySQL 5.5原始碼安裝時啟動資料庫報錯"Table 'mysql.user' doesn't exist??"MySql原始碼資料庫
- MySQL 5.5初始化資料庫報錯FATAL ERROR: Could not find my_print_defaultsMySql資料庫Error
- MySQL執行語句報Incorrect key file for table '/tmp/#sql_.MYI'; try to repair itMySqlAI
- mysql報錯ERROR 1093MySqlError
- MySQL報錯 Error_code: 1045MySqlError
- Table '.\mysql\proc' is marked as crashed and should be repaired 報錯MySqlAI
- Incorrect key file for table '/tmp/....'錯誤的解決--記錄
- 【MySQL】Testing mysql connection and privileges..ERROR 1173 (42000)MySqlError
- Qt報Multiple definition錯誤的解決QT
- MySQL 啟動報錯 Table 'mysql.plugin' doesn't existMySqlPlugin
- Mysql 5.5 原始碼安裝後建立使用者報錯"ERROR 1045 (28000): Access denied for user"MySql原始碼Error
- MySQL:ERROR 1286 (42000): Unknown storage engine 'MyISAM'MySqlError
- ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql'ErrorlocalhostDatabaseMySql
- 【MySQL】5.6.x InnoDB Error Table mysql.innodb_table_stats not foundMySqlError
- mysql 報錯:ERROR 1366 (HY000): Incorrect string value: ‘\xD5\xC5\xC8\xFD‘ for column ‘name‘ at row 1MySqlError
- MySQL錯誤Incorrect file format解決方案薦MySqlORM
- [ERROR] Can't open the mysql.plugin tableErrorMySqlPlugin
- [報錯:字元太長] SQLSTATE [42000]: Syntax error or access violation: 1071 Specified key was t oo long;字元SQLError
- MySQL查詢報錯:ERROR 1146 (42S02): Table 'craw.sitePageConfig' doesn't existMySqlError
- Mysql報錯Fatal error:Can't open and lock privilege tablesMySqlError
- MYSQL ERROR 1146 Table doesnt exist 解析MySqlError
- MySQL 5.6執行DDL報錯ERROR 1050 (42S01): Table 'sms/#sql-ib752' already existMySqlError
- MySQL error 錯 誤 碼MySqlError
- vipca報錯 Error 0PCAError
- MySQL 建立外來鍵報錯Can't write; duplicate key in tableMySql
- MySQL 5.5 關閉資料庫報錯"Can't connect to local MySQL server through socket"MySql資料庫Server
- 記一次 打包報錯:Keystore was tampered with, or password was incorrect
- MySQL 8.0.26 bug ERROR 1064(42000) -master-data is deprecated and will be removeMySqlErrorASTREM
- error code 0x534. [SQLSTATE 42000] (Error 15404)).ErrorSQL
- mysqldump匯出報錯"mysqldump: Error 2013 ... during query when dumping tableMySqlError
- Mysql資料庫報ERROR 1045 (28000)報錯及MySQL忘記密碼找回MySql資料庫Error密碼
- ERROR 1045 (28000): ProxySQL Error: 報錯ErrorSQL
- GoldenGate "Error mapping from table.a to table.a"錯誤測試GoErrorAPP