MySQL多列主键 [英] MySQL multicolumn primary key
问题描述
多列主键(MySQL)的最大列数是多少?是否取决于列数据类型或引擎?
What is the maximum columns number for a multicolumn primary key (MySQL)? Does it depend on column data type or engine?
推荐答案
是的,这取决于存储引擎.
Yes, it depends on storage engine.
-
MyISAM :
每个索引的最大列数为16.最大键长 是1000个字节.也可以通过更改来源和 重新编译.如果密钥长度超过250个字节,则使用较大的密钥 块大小使用默认值1024字节.
The maximum number of columns per index is 16. The maximum key length is 1000 bytes. This can also be changed by changing the source and recompiling. For the case of a key longer than 250 bytes, a larger key block size than the default of 1024 bytes is used.
InnoDB :
InnoDB内部最大密钥长度为3500字节,但MySQL本身 将其限制为3072个字节.此限制适用于 多列索引中的组合索引键.
The InnoDB internal maximum key length is 3500 bytes, but MySQL itself restricts this to 3072 bytes. This limit applies to the length of the combined index key in a multi-column index.
这篇关于MySQL多列主键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!