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

MYSQL
MySQL数据库在网络安全方面的功能
MySQL数据库中触发器应用深入研究
MySQL和SQL Server 我们到底选择谁?
把mysql中的乱码变成正常的编码
教你编写高质量 高性能的MySQL语法
教你编写高质量、高性能的MySQL语法
MySQL和PostgreSQLl两数据库的对决
MySQL入门学习指南
加速动态网站之MySQL索引分析和优化
SQL Server数据库导入MySQL数据库体验
将你的网站从MySQL改为PostgreSQL
教你自动恢复MySQL数据库的日志文件
MySQL数据库中用GRANT语句增添新用户
教你怎样配置MySQL数据库双机热备份
mysql5.0 绿色安装
Mysql 数据库字符集转换及版本升级/降级的详细教程
MySQL 的数据类型和建库策略
推荐:MySQL数据库中鲜为人知的技巧
mysql在linux下远程连接错误的问题
MySQL数据库中备份/恢复的两方法介绍

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


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