Error when deleting primary key: [Err] 1075 – Incorrect table definition; there can be only one auto column and it must be defined as a key
alter table table_name drop primary key; # [Err] 1075
This is because, when creating a table, the primary key is set with an auto increment attribute: Auto_ INCREMENT
The autoincrement column can only have one column, and this column must be a key, that is, when creating a table, if it is a autoincrement column, it must be identified with a primary key
For example, the (ID) column in the table:
create table if not exists table_name(
id INT UNSIGNED AUTO_INCREMENT,
name_people VARCHAR(40) NOT NULL,
submission_time DATETIME,
PRIMARY KEY(id)
)ENGINE=InnoDB DEFAULT CHARSET=utf8;
Solution:
When creating a table, do not add the auto increment attribute, and then you can delete the primary key. For example:
create table if not exists table_name_2(
id INT UNSIGNED,
name_people VARCHAR(40) NOT NULL,
submission_time DATETIME,
PRIMARY KEY(id)
)ENGINE=InnoDB DEFAULT CHARSET=utf8;
You can then delete the primary key:
alter table table_name_2 drop primary key;
Similar Posts:
- MySQL timestamp set default value error Invalid default value reason and solution
- [Solved] MySQL query reports an error: Legal mix of settlements
- MYSQL ERROR 1005 (HY000): Can’t create table [How to Solve]
- When mysql creates a table, set timestamp DEFAULT NULL error 1067-Invalid default value for’updated_at’
- Database upgrade from Zabbix 5.0.15 to Zabbix 5.2.7 failed
- [Solved] MySQL ERROR 1062 (23000): Duplicate entry ‘0’ for key ‘PRIMARY’
- [Solved] MySQL uses the workbench tool, and the table status is read only
- [Err] 1214 – The used table type doesn’t support FULLTEXT indexes
- SET SQL_MODE=”NO_AUTO_VALUE_ON_ZERO”
- In Oracle, an error is reported: ora-00904