当我执行以下命令时:
create table assessment (
id integer not null auto_increment unique,
assignment_weight_type tinyint not null,
description varchar(255),
end_date datetime not null,
from_grade tinyint not null,
f_id tinyint not null,
name varchar(255) not null,
start_date datetime not null,
status tinyint not null,
weight smallint,
school_id integer not null,
school_year_id integer not null,
s_id integer, primary key (id),
unique (name, school_id, school_year_id, from_grade, f_id)
) ENGINE=InnoDB;
Run Code Online (Sandbox Code Playgroud)
我收到此错误消息:
Specified key was too long; max key length is 767 bytes
Run Code Online (Sandbox Code Playgroud)
我正在使用utf8mb4的字符集.那我为什么收到错误信息呢?
utf8mb4 每个字符最多使用四个字节,因此名称本身可以占用多达1020个字节.