1

I am new with Mysql and character set and having some doubpts.

I have one Column which is:

VARHCAR(250) and CHARACTER SET = utf8

Now does VARCHAR(250) means that I can save 250 bytes or 250 UTF8 characters.

If it means that I can store 250 UTF8 characters, because max size of UTF8 character is 3 byte does it means that I can store 250*3 bytes?

What I want to do in my code is to check Length before inserting value in DB and reject it if it's too long. But I am not sure if I have to check characters length of byte length.

carpics
  • 2,272
  • 4
  • 28
  • 56
  • 3
    See http://stackoverflow.com/questions/1997540/mysql-varchar-lengths-and-utf-8 – Saleh Dec 02 '16 at 15:23
  • `CHAR_LENGTH(...)` counts _characters_; `LENGTH(...)` counts _bytes_. `VARCHAR(250)` can hold 250 _characters_ in whatever `CHARACTER SET` is is declared to be. That will occupy _up to_ 2+3*250 bytes in the case of `utf8`. – Rick James Dec 03 '16 at 06:51

0 Answers0