一、MySql官网文档解释
在**mysql5.***中描述如下
Different limits related to tables and indexes. For example, the maximum number of ordered indexes in the cluster is determined by MaxNoOfOrderedIndexes, and the maximum number of ordered indexes per table is 16.
**mysql8.***中描述如下
A table can contain a maximum of 64 secondary indexes.A maximum of 16 columns is permitted for multicolumn indexes. Exceeding the limit returns an error.
ERROR 1070 (42000): Too many key parts specified; max 16 parts allowed
二、测试验证
mysql版本为mysql-5.5.61
1、创建测试表blog_user,包含17个列
create table blog_user
(
user_Name1 char(15) not null,
user_Name2 char(15) not null,
user_Name3 char(15) not null,
user_Name4 char(15) not null,
user_Name5 char(15) not null,
user_Name6 char(15) not null,
user_Name7 char(15) not null,
user_Name8 char(15) not null,
user_Name9 char(15) not null,
user_Name10 char(15) not null,
user_Name11 char(15) not null,
user_Name12 char(15) not null,
user_Name13 char(15) not null,
user_Name14 char(15) not null,
user_Name15 char(15) not null,
user_Name16 char(15) not null,
user_Name17 char(15) not null,
primary key(user_Name1)
)engine=innodb default charset=utf8 auto_increment=1;
执行结果如下(正常执行):
2.创建包含16个列的索引
CREATE INDEX idx_blog_user ON blog_user(
user_Name1,
user_Name2,
user_Name3,
user_Name4,
user_Name5,
user_Name6,
user_Name7,
user_Name8,
user_Name9,
user_Name10,
user_Name11,
user_Name12,
user_Name13,
user_Name14,
user_Name15,
user_Name16
);
执行结果如下(正常执行):
3.创建包含17个列的索引
CREATE INDEX idx_blog_user ON blog_user(
user_Name1,
user_Name2,
user_Name3,
user_Name4,
user_Name5,
user_Name6,
user_Name7,
user_Name8,
user_Name9,
user_Name10,
user_Name11,
user_Name12,
user_Name13,
user_Name14,
user_Name15,
user_Name16,
user_Name17
);
执行结果如下(已经报错):
MySQL 一张表单个索引最多支持创建16个字段。
原文:MySQL 一张表单个索引最多支持创建16个字段