当前位置:网站首页>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
边栏推荐
- Use newbeecoder UI implements data paging
- On the light application platform finclip and the mobile application development platform mpaas
- [cloud native | kubernetes] kubernetes principle and installation (II)
- Spirit matrix for leetcode topic analysis
- 173. Binary Search Tree Iterator
- The fourth online workshop review
- Arthas vmtool命令小结
- Self organizing map neural network (SOM)
- 点击添加下拉框
- Map interface and its sub implementation classes
猜你喜欢

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

636. Exclusive Time of Functions

Linux Mysql安装
![[event registration] sofastack × CSDN jointly held the open source series meetup, which was launched on June 24](/img/e1/97c92290a2a5e68f05cdbd5bf525e8.png)
[event registration] sofastack × CSDN jointly held the open source series meetup, which was launched on June 24

最常用的5中流ETL模式

173. Binary Search Tree Iterator

Community article | mosn building subset optimization ideas sharing

Talk about the implementation principle of @autowired

Which is better, semrush or ahrefs? Which is more suitable for GoogleSEO keyword analysis

社区文章|MOSN 构建 Subset 优化思路分享
随机推荐
Unity grid programming 06
Utilisation du cookie du module de demande de noeud
125. Valid Palindrome
通信方式总结及I2C驱动详解
Arclayoutview: implementation of an arc layout
7-palette-calayer and touch
Driver Architecture & platform platform bus driver model
Flink错误--Caused by: org.apache.calcite.sql.parser.SqlParseException: Encountered “time“
社区文章|MOSN 构建 Subset 优化思路分享
Leetcode topic analysis h-index II
Map interface and its sub implementation classes
自定义标签——jsp标签基础
528. Random Pick with Weight
The results of CDN node and source station are inconsistent
Leetcode topic analysis set matrix zeroes
Monitor the cache update of Eureka client
Isomorphic strings for leetcode topic resolution
Leetcode topic analysis sort colors
Geoserver添加mongoDB数据源
XSS via host header