How can I alter an indexed varchar(255) from utf8 to utf8mb4 and still stay under the 767 max key length?

前端 未结 2 445
情歌与酒
情歌与酒 2021-01-19 13:23

I have an mysql column that needs to support emoji, and that means converting a utf8 column into a utf8mb4. But my varchar(255) won\'t fit, so long as the column is indexed

2条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-19 14:03

    I think it is connected with maximum data length of the row, there is such limitation, at least for string data types as I know. To avoid this try to separate table's data, e.g. split table into two tables using one-to-one relation.

    About the maximum key length: I have tried to create table with indexed utf8mb4 field, it was successfully created with key length 191, but when I set it to 192, it threw an error - Specified key was too long; max key length is 767 bytes.

提交回复
热议问题