当前位置:网站首页>MySQL fault case | error 1071 (42000): specified key was too long
MySQL fault case | error 1071 (42000): specified key was too long
2022-06-23 08:56:00 【Mortal operation and maintenance】
MySQL The following error occurred in creating the table (5.7)
ERROR 1071 (42000): Specified key was too long; max key length is 3072 bytes
Check the official website :
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
By default, the index of a single column cannot exceed 767 position , We can enable innodb_large_prefix=on Options , Extend constraint to 3072 byte.
# 1、 Open online
set global innodb_large_prefix = 1;
# 2、 Make sure to turn on
show variables like 'innodb_large_prefix';
# 3、 Configuration file configuration is enabled
innodb_large_prefix=on in addition , If the length of the field added to the index is too long , Can be added instead Prefix index The way , as follows
# Single column
alter table t1 add index idx_c1(c1(10));
# Multiple columns
alter table t1 add index idx_c1_c2(c1(10),c2(10)); Be careful , Adding prefix index length is not the longer the better , There is a question of selectivity ,
select
count(distinct Name )/count(*)as a,
COUNT(DISTINCT left( Name ,100)) as b,
COUNT(DISTINCT left( Name ,110)) as c
from Table name ;END
边栏推荐
- Unity grid programming 06
- 65. Valid Number
- Talk about the implementation principle of @autowired
- js 用**遮罩身份证以及手机号的重要数据
- The first day of employment more than ten years ago
- Vue3表单页面利用keep-alive缓存数据的一种思路
- New engine, new capability, new experience, Tencent host security flagship release
- 297. Serialize and Deserialize Binary Tree
- How to restore visualizations and dashboards after kibana rebuilds the index
- When easynvr service is started, video cannot be played due to anti-virus software interception. How to deal with it?
猜你喜欢

Keng dad's "dedication blessing": red packet technology explosion in Alipay Spring Festival Gala

“教练,我想打篮球“ —— 给做系统的同学们准备的 AI 学习系列小册

Le rapport d'analyse de l'industrie chinoise des bases de données a été publié en juin. Le vent intelligent se lève, les colonnes se régénèrent

【云原生 | Kubernetes篇】Kubernetes原理与安装(二)

自定义标签——jsp标签增强

In depth interpretation of poca smart contract platform gear: the road to parallel architecture public chain

Which one is better for rendering renderings? 2022 latest measured data (IV)

986. Interval List Intersections

In June, China database industry analysis report was released! Smart wind, train storage and regeneration
![[learning resources] understand and love mathematics](/img/a3/e1b0915c48c85d17c48a4bee523424.png)
[learning resources] understand and love mathematics
随机推荐
Talk about the implementation principle of @autowired
How to sort a dictionary by value or key?
7-palette-calayer and touch
When easynvr service is started, video cannot be played due to anti-virus software interception. How to deal with it?
Top 25 most popular articles on vivo Internet technology in 2021
2022.6.22-----leetcode.513
297. Serialize and Deserialize Binary Tree
523. Continuous Subarray Sum
3. caller service call - dapr
Lighthouse cloud desktop experience
Subsets of leetcode topic resolution
简易学生管理
New engine, new capability, new experience, Tencent host security flagship release
986. Interval List Intersections
Can portals be the next decentraland?
523. Continuous Subarray Sum
Mqtt+flink to subscribe and publish real-time messages
Longest substring without repeated characters (C language)
The results of CDN node and source station are inconsistent
【活动报名】SOFAStack × CSDN 联合举办开源系列 Meetup ,6 月 24 日火热开启