一个MySQL索引能容纳多少列

一个MySQL索引能容纳多少列

来源:爱站网
时间:2022-07-14
编辑:网友分享
有不少朋友问小编:一个MySQL索引能容纳多少列?如果你想了解清楚这方面的内容,不妨来看看爱站技术频道小编所整理的资料,希望这篇文章能在学习或者工作中帮助到你解决问题。

最多16列。

create table test (
f1 int,
f2 int,
f3 int,
f4 int,
f5 int,
f6 int,
f7 int,
f8 int,
f9 int,
f10 int,
f11 int,
f12 int,
f13 int,
f14 int,
f15 int,
f16 int,
f17 int
);

create index idx_test_16 on test (f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,f14,f15,f16);
create index idx_test_17 on test (f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,f14,f15,f16,f17);

运行结果如下:

mysql> create table test (
-> f1 int,
-> f2 int,
-> f3 int,
-> f4 int,
-> f5 int,
-> f6 int,
-> f7 int,
-> f8 int,
-> f9 int,
-> f10 int,
-> f11 int,
-> f12 int,
-> f13 int,
-> f14 int,
-> f15 int,
-> f16 int,
-> f17 int
-> );
Query OK, 0 rows affected (0.06 sec)

mysql>
mysql> create index idx_test_16 on test (f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,f14,f15,f16);
Query OK, 0 rows affected (0.02 sec)
Records: 0 Duplicates: 0 Warnings: 0

mysql> create index idx_test_17 on test (f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,f14,f15,f16,f17);
ERROR 1070 (42000): Too many key parts specified; max 16 parts allowed
mysql>

相信朋友们看完这篇一个MySQL索引能容纳多少列的内容后,对这方面的了解都更加透彻了吧!关注爱站技术频道网站,每天都能带你体验不一样的技术文章内容。