当前位置 博文首页 > asd1358355022的博客:mysql更新varchar类型字段长度报错:ERROR

    asd1358355022的博客:mysql更新varchar类型字段长度报错:ERROR

    作者:[db:作者] 时间:2021-08-05 09:55

    mysql> alter table `apm_heuristic_result`
    ? ? -> modify column ?`value` varchar(65535) ?not null comment 'value';
    ERROR 1074 (42000): Column length too big for column 'value' (max = 21845); use BLOB or TEXT instead

    utf8下每个字符最大占用3个字节(65535/3=21845),除去一些其余的开销占用之外,自行修改一下,例如21000成功

    解决方法:

    1. 使用TEXT或者BLOB类型替换varchar类型 (注意替换之后会影响到索引性能。char > varchar > TEXT?)

    2. 缩小varchar类型指定的字符长度

    mysql> alter table `apm_heuristic_result` modify column ?`value` varchar(21000) ?not null comment 'value';
    Query OK, 0 rows affected (0.01 sec)
    Records: 0 ?Duplicates: 0 ?Warnings: 0

    mysql> alter table `apm_heuristic_result` modify column ?`value` varchar(21730) ?not null comment 'value';
    ERROR 1118 (42000): Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs

    cs
    上一篇:没有了
    下一篇:没有了