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

MYSQL
mysql "too many connections" 错误 之 mysql解决方法
MySQL: mysql is not running but lock exists 的解决方法
使用mysql中遇到的几个问题
MySQL一个索引最多有多少个列?真实的测试例子
MySQL里Create Index 能否创建主键 Primary Key
MySQL 创建索引(Create Index)的方法和语法结构及例子
MYSQL 优化常用方法
linux mysql 找回密码
mysql 动态执行存储过程语句
MySQL 查找价格最高的图书经销商的几种SQL语句
MySQL 客户端不输入用户名和密码直接连接数据库的2个方法
mysql 查询表中平均分最低的班级
mysql 左连接、右连接和内连接
Mysql LONGBLOB 类型存储二进制数据 (修改+调试+整理)
Mysql LONGTEXT 类型存储大文件(二进制也可以) (修改+调试+整理)
Mysql 插入中文及中文查询 (修改+调试)
mysql 数据表中查找重复记录
MySql .frm数据库文件导入的问题
解决hibernate+mysql写入数据库乱码
mySQL UNION运算符的默认规则研究

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


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