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

MYSQL
MySQL 一次执行多条语句的实现及常见问题
mysql 常见命令和学习心得
mysql 发生系统错误1067的解决方法
MySQL 建表的优化策略 小结
批量替换 MySQL 指定字段中的字符串
mysql4.0升级到mysql5(4.1),解决字符集问题
MySQL 随机密码生成代码
Linux系统下配置功能完善的Web服务器
PHP+MYSQL实例:网站在线人数的代码
Perl直接入门详尽指南
PHP实例程序:直接读取数据库信息的三种方法
Apache、PHP和mySQL的配置的过程
新手学PHP和MySQL动态网站开发教程
优化mysql性能的十个参数
用相关数据库命令对MySQL进行优化
MYSQL执行SQL语句需要注意的两个问题
保护MySQL数据库中重要数据全攻略
Linux下配置 Tomcat+JDK+MySQL应用平台
数据从MySQL迁移到 Oracle的注意事项
快速掌握 MySQL数据库中触发器的应用

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-13   浏览: 149 ::
收藏到网摘: 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>