mysql5.6 innodb_large_prefix引起的一个异常

phenomenon: Specified key was too long; max key length is 3072 bytes

在修改一个数据库字段时,字段容量被限制为了表前缀的大小而不是本身的容量大小

查了一下innodb_large_prefix究竟是什么?

动态行格式DYNAMIC row format支持最大的索引前缀(3072)。由变量innodb_large_prefix进行控制。

By default, the index key prefix length limit is 767 bytes. See Section 13.1.13, “CREATE INDEX Statement”. For example, you might hit this limit with a column prefix index of more than 255 characters on a TEXT or VARCHAR column, assuming a utf8mb3 character set and the maximum of 3 bytes for each character. When the innodb_large_prefix configuration option is enabled, the index key prefix length limit is raised to 3072 bytes for InnoDB tables that use the DYNAMIC or COMPRESSED row format.

官方上说在utf8mb3(most bytes n)如果设置为 varchar(255)时,索引前缀将大于767,可以扩展为3072,但是实际上 varchar的size可以为65535,这个就限制了整个alter table 的操作

因为建表是时索引没设置大小,默认是超过255的,后面开启了前缀限制,大小会为3072,此时无法做表修改

Reference
https://forums.percona.com/t/utf8mb4-error-1709-hy000-index-column-size-too-large-the-maximum-column-size-is-767-bytes/8336
MySQL8 innodb large prefix
innodb_file_format settings backwards compatible
innodb limits

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Hermokrates

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值