ERROR 1075 (42000): Incorrect table definition; there can be only one auto column and it must be defined as a key
The table is created as follows:
mysql> create table tb_emp5(
-> id int(11) not null auto_increment,
-> name varchar(11),
-> deptid int(11) not null auto_increment,
-> salary float,
-> primary key(id,deptid)
-> );
ERROR 1075 (42000): Incorrect table definition; there can be only one auto column and it must be defined as a key
when creating a MySQL table, if you want to set auto_increment, you must set the primary key, not null, and only one
After the change is as follows:
mysql> create table tb_emp5(
-> id int(11) not null auto_increment,
-> name varchar(11),
-> deptid int(11) not null,
-> salary float,
-> primary key(id)
-> );
mysql> desc tb_emp5;
+--------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------+-------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| name | varchar(11) | YES | | NULL | |
| deptid | int(11) | NO | | NULL | |
| salary | float | YES | | NULL | |
+--------+-------------+------+-----+---------+----------------+
Read More:
- postgresql-Database query problem-ERROR: column “t.domainid“ must appear in the GROUP BY clause or be used in an a
- Error 1406 (22001) in MySQL: data too long for column (Fixed)
- How to Fix MySQL error 1005: can’t create table (errno: 150)
- Solve MySQL table can not query, modify, delete and other operations and appear stuck
- [Solved] ERROR 1054 (42S22): Unknown column ‘password‘ in ‘field list‘
- ERROR 1265 (01000): Data truncated for column ‘ENABLED’ at row 7
- MySQL 8.0 error 1114 (HY000): the table’sbtest1’is full (Fixed)
- SQL Server Deletes a table foreign key constraint Error [Solved]
- ERROR 1054(42S22) Unknown column ‘password’ in ‘field list’ (Fixed)
- [Solved] Daily further: database error: unknown column ‘model’ in ‘field list‘
- [Solved] tidb-cdc Create Task Error: Unknown or incorrect time zone
- [Solved] Connections could not be acquired from the underlying database
- Mysql Script Error Code: 1136. Column count doesn’t match value count at row 1
- Mysql5.7.18.1 Error 1054 (42S22): Unknown Column’password’ In’field List’ When Changing User Password
- [Solved] Navicat Connect MySQL error: Authentication plugin ‘caching_sha2_password‘ cannot be loaded
- mysql workbench Error Code: 1046. No database selected Select the default DB to be used by doubl
- How to Solve “Out of range value for column” Error
- Error creating foreign key in MySQL: 1215 cannot add the foreign key constraint
- ORA-29913 ORA-06512 external table query prompt: error
- MySQL startup error: vcruntime140_1.dll cannot be found, unable to continue code execution