当前位置: 首页 > 图文教程 > 数据库 > MYSQL > MySQL一个索引最多有多少个列?真实的测试例子

MYSQL
提高MySQL 查询效率的三个技巧
mysql同步复制搭建方法指南详细步骤
详解MySQL中DROP,TRUNCATE 和DELETE的区别实现mysql从零开始
MySQL Replace INTO的使用
mysql 分页优化解析
同时运行多个MySQL服务器的方法
mysql主从服务器同步心得体会
删除mysql数据库中的重复数据记录
mysql忘记密码的解决方法
mysql替换表中的字符串的sql语句
Lost connection to MySQL server during query的解决
mysql出现Error performing load command的解决方法
mysql中的“money”类型说明
mysql常见错误集锦
MYSQL administrator 使用
MYSQL初学者命令行使用指南
MySQL的Query Cache原理分析
linux下改良版本mysqldump来备份MYSQL数据库
mysql删除表中某一字段重复的记录
log引起的mysql不能启动的解决方法

MYSQL 中的 MySQL一个索引最多有多少个列?真实的测试例子


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-13   浏览: 156 ::
收藏到网摘: n/a

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>