Return the length of a string in bytes. This function is a synonym for LENGTH() in default mode, returning the byte count.
LENGTHB(str)LENGTHB() returns the length of the given string, in bytes. When is not set, this is a synonym for .
A multi-byte character counts as multiple bytes. This means that for a string containing five two-byte characters, LENGTHB() returns 10, whereas returns 5.
If str is not a string value, it is converted into a string. If str is NULL, the function returns NULL.
When Oracle mode is not set:
In Oracle mode:
This page is licensed: CC BY-SA / Gnu FDL
SELECT CHAR_LENGTH('Ï€'), LENGTH('Ï€'), LENGTHB('Ï€'), OCTET_LENGTH('Ï€');
+-------------------+--------------+---------------+--------------------+
| CHAR_LENGTH('Ï€') | LENGTH('Ï€') | LENGTHB('Ï€') | OCTET_LENGTH('Ï€') |
+-------------------+--------------+---------------+--------------------+
| 1 | 2 | 2 | 2 |
+-------------------+--------------+---------------+--------------------+SELECT CHAR_LENGTH('Ï€'), LENGTH('Ï€'), LENGTHB('Ï€'), OCTET_LENGTH('Ï€');
+-------------------+--------------+---------------+--------------------+
| CHAR_LENGTH('Ï€') | LENGTH('Ï€') | LENGTHB('Ï€') | OCTET_LENGTH('Ï€') |
+-------------------+--------------+---------------+--------------------+
| 1 | 1 | 2 | 2 |
+-------------------+--------------+---------------+--------------------+