データベース:Incorrect table definition;there can be only one auto column and it must be defined as a keyエラー


エラーメッセージ:ERROR 1075(42000):Incorrect table definition;there can be only one auto column and it must be defined as a key
エラー原因:idフィールドにauto_が指定されていますincrementタイプなので、プライマリ・キーはidフィールドのみを指定できます.

mysql> create table llll (id int(10) not null auto_increment,user char(16) not null,primary key (user));
ERROR 1075 (42000): Incorrect table definition; there can be only one auto column and it must be defined as a key

解決策:プライマリ・キーでidを指定するか、auto_を削除します.increment文
mysql> create table llll (id int(10) not null,user char(16) not null,primary key (user));
Query OK, 0 rows affected (0.00 sec)

mysql> show keys from llll;
+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| llll  |          0 | PRIMARY  |            1 | user        | A         |           0 |     NULL | NULL   |      | BTREE      |         |               |
+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
1 row in set (0.00 sec)