当前位置:网站首页>MySQL故障案例 | ERROR 1071 (42000): Specified key was too long
MySQL故障案例 | ERROR 1071 (42000): Specified key was too long
2022-06-23 08:43:00 【凡人学运维】
MySQL 建表出现如下错误 (5.7)
ERROR 1071 (42000): Specified key was too long; max key length is 3072 bytes
查看官网内容得知:
If innodb_large_prefix is enabled (the default), the index key prefix limit is 3072 bytes for InnoDB tables that use the DYNAMIC or COMPRESSED row format. If innodb_large_prefix is disabled, the index key prefix limit is 767 bytes for tables of any row format.
https://dev.mysql.com/doc/refman/5.7/en/innodb-limits.html
默认情况下单个列的索引不能超过767位,我们可以启用 innodb_large_prefix=on 选项,将约束项扩展至 3072 byte。
# 1、在线开启
set global innodb_large_prefix = 1;
# 2、确认开启
show variables like 'innodb_large_prefix';
# 3、配置文件配置开启
innodb_large_prefix=on另外,如果添加索引的字段长度过长,可以改为添加前缀索引的方式,如下
# 单列
alter table t1 add index idx_c1(c1(10));
# 多列
alter table t1 add index idx_c1_c2(c1(10),c2(10)); 注意,添加前缀索引的长度并不是越长越好,这里涉及到一个选择性问题,
select
count(distinct 列名)/count(*)as a,
COUNT(DISTINCT left(列名,100)) as b,
COUNT(DISTINCT left(列名,110)) as c
from 表名;END
边栏推荐
- On the light application platform finclip and the mobile application development platform mpaas
- '教练,我想打篮球!' —— 给做系统的同学们准备的 AI 学习系列小册
- 谈谈 @Autowired 的实现原理
- (resolved) difference between leftmost prefix and overlay index
- [cloud computing] GFS ideological advantages and architecture
- 670. Maximum Swap
- usb peripheral 驱动 - debug
- 1-gradients, shadows, and text
- 简易学生管理
- GeoServer adding mongodb data source
猜你喜欢

Quartz Crystal Drive Level Calculation

6月《中国数据库行业分析报告》发布!智能风起,列存更生

986. Interval List Intersections

鸿蒙读取资源文件

636. Exclusive Time of Functions

力扣之滑动窗口《循序渐进》(209.长度最小的子数组、904. 水果成篮)

【活动报名】SOFAStack × CSDN 联合举办开源系列 Meetup ,6 月 24 日火热开启

Self organizing map neural network (SOM)
![[cloud computing] GFS ideological advantages and architecture](/img/98/2a4ef0ca805add24d431dac9808903.png)
[cloud computing] GFS ideological advantages and architecture

谈谈 @Autowired 的实现原理
随机推荐
Open source technology exchange batch stream integrated data synchronization engine Chunjun data restore DDL function module analysis
How to evaluate code quality
3-progressbar and secondary cropping
523. Continuous Subarray Sum
Can portals be the next decentraland?
Implementing an open source app store with swiftui
类型从属名称的使用必须以“typename”为前缀
[operating steps] how to set the easynvr hardware device to be powered on without automatic startup?
173. Binary Search Tree Iterator
670. Maximum Swap
297. Serialize and Deserialize Binary Tree
In depth interpretation of poca smart contract platform gear: the road to parallel architecture public chain
XSS via host header
“教练,我想打篮球“ —— 给做系统的同学们准备的 AI 学习系列小册
3. caller service call - dapr
297. Serialize and Deserialize Binary Tree
论文阅读【Quo Vadis, Action Recognition? A New Model and the Kinetics Dataset】
Hongmeng reads the resource file
Why is the easycvr Video Fusion platform offline when cascading with the Hikvision platform? How to solve it?
1、 Software architecture evaluation