【问题标题】:When issuing a command to MySQL, I'm getting that error "#1075 - Incorrect table definition;"向 MySQL 发出命令时,我收到错误“#1075 - Incorrect table definition;”
【发布时间】:2021-01-04 08:58:42
【问题描述】:
CREATE TABLE onscreen(
id int(2) not null AUTO_INCREMENT,
subject varchar(100) not null,
content varchar(100) not null,
date datetime not null
);
【问题讨论】:
标签:
mysql
sql
primary-key
auto-increment
create-table
【解决方案1】:
整个错误信息是:
表定义不正确;只能有一个自动列,并且必须定义为一个键
这很清楚:MySQL 要求您将自增列定义为主键:
CREATE TABLE onscreen(
id int(2) not null AUTO_INCREMENT primary key, --> here
subject varchar(100) not null,
content varchar(100) not null,
date datetime not null
)
Demo on DB Fiddle