-1

What does N in varchar(N) actually mean in MySQL?

Is it the length of the string in characters or the maximum size in bytes, and can varchar in modern MySQL hold Unicode values? Or do I need to choose a different data type? If varchar supports Unicode, do I have to take into account that a Unicode character can be larger than 1 byte?

jarlh
  • 40,041
  • 8
  • 39
  • 58
Nethrenial.
  • 146
  • 1
  • 10

1 Answers1

1

N is the number of characters, and character is larger than 1 byte usually. https://dev.mysql.com/doc/refman/8.0/en/char.html

utf8mb4 is a good choose to handle emoji. The is a little trap with utf8mb3 that is used some time by default that is not really UTF8 but a subset.

https://dev.mysql.com/doc/refman/8.0/en/charset-unicode.html

Mr_Thorynque
  • 1,467
  • 15
  • 28