peewee.InternalError: (1071, 'Specified key was too long; max key length is 1000 bytes')
程序员文章站
2022-05-04 15:02:20
原因 :使用peewee创建表时,有类似于这样的语句: (也就是把char类型的字段设置成了主键。) 解释 :utf8mb4 编码下 1 char = 4 bytes。而varchar默认长度为255(255 4 = 1020),超过报错显示的最大长度 1000 bytes。 解决 :设置CharF ......
原因:使用peewee创建表时,有类似于这样的语句: field_name = charfield(primary_key=true)
(也就是把char类型的字段设置成了主键。)
解释:utf8mb4 编码下 1 char = 4 bytes。而varchar默认长度为255(255*4 = 1020),超过报错显示的最大长度 1000 bytes。
解决:设置charfield的最大长度参数:max_length=num
(num <= 250)
推荐阅读
-
ERROR 1071 (42000): Specified key was too long; max key length is 767 bytes
-
peewee.InternalError: (1071, 'Specified key was too long; max key length is 1000 bytes')
-
Specified key was too long max key length is 1000 bytes
-
ERROR 1071 (42000): Specified key was too long; max key length is 767 bytes
-
MySQL错误“Specified key was too long; max key length is 100
-
peewee.InternalError: (1071, 'Specified key was too long; max key length is 1000 bytes')
-
MySQL错误“Specified key was too long; max key length is 100_MySQL
-
laravel migrate时报错:Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes
-
mysql建库时提示Specified key was too long max key length is_MySQL
-
MySQL:Specified key was too long; max key length is 767 bytes.