When to use utf-8 and when to use latin1 in MySQL?

后端 未结 8 1673
暖寄归人
暖寄归人 2021-02-13 21:56

I know that MySQL has default of latin1 encoding and apparently it takes 1 byte to store a character in latin1 and 3 bytes to store a character in

8条回答
  •  被撕碎了的回忆
    2021-02-13 22:09

    Since the max length of a key is 1000 BYTES, if you use utf8, then this will limmit you to 333 characters.

    However MySQL is different form Oracle for charset. In Oracle you can't have a different character set per column, wheras in MySQL you can, so may be you can set the key to latin1 and other columns to utf8.

    Finally I believe only defunct version 6.0alpha (ditched when Sun bought MySQL) could accomodate unicode characters beyound the BMP (Basic Multilingual Plan). So basically, even with UTF-8, you won't have all the whole unicode character set. In practice this is only a problem for rare Chinese characters, if that really matters to you.

提交回复
热议问题