Home > database >  MySQL character set issues
MySQL character set issues

Time:09-30

Why the MySQL utf-8 Chinese is 3 bytes, but I set varchar3, can save three Chinese characters?

CodePudding user response:

MySql version 5.0 + :

1, how much a Chinese characters of length coding related:
Utf-8: a=3 bytes of Chinese characters, English is a byte
GBK: a=2 bytes of Chinese characters, English is a byte
2, a varchar (n) n characters, regardless of the Chinese and English, MySql can be deposited in the n characters, only the actual bytes,

CodePudding user response:

Varchar N represents the number of characters is not the number of bytes

CodePudding user response:

So varchar N represents the number of characters is not the number of bytes, so I need not consider bytes of concept?

CodePudding user response:

Varchar 3 represents the number of characters, not bytes

CodePudding user response:

SQL server varchar (n) is the representative of bytes

reference jitunei2202 reply: 3/f
so varchar N represents the number of characters is not the number of bytes, so I need not consider bytes of concept?

Yes, how many characters in this field is the most save how many went, varchar SQL server varchar only need to consider the byte, SQL server varchar (2) can only save one Chinese character, because of a Chinese character of two bytes, and varchar (2) can only save two bytes, mysql doesn't have to think about this question

CodePudding user response:

About whether to need to calculate the number of spatial database using problem, when data volume is larger or the spectrum of the estimated,
  • Related