CHAR_LENGTH
Return the length of a string in characters. This function counts the number of characters in the string, treating multi-byte characters as single units.
Syntax
CHAR_LENGTH(str)
CHARACTER_LENGTH(str)Description
Returns the length of the given string argument, measured in characters. A multi-byte character counts as a single character. This means that for a string containing five two-byte characters, LENGTH() (or OCTET_LENGTH() in Oracle mode) returns 10, whereas CHAR_LENGTH() returns 5. If the argument is NULL, it returns NULL.
If the argument is not a string value, it is converted into a string.
It is synonymous with the CHARACTER_LENGTH() function.
Examples
SELECT CHAR_LENGTH('MariaDB');
+------------------------+
| CHAR_LENGTH('MariaDB') |
+------------------------+
| 7 |
+------------------------+When Oracle mode is not set:
SELECT CHAR_LENGTH('Ï€'), LENGTH('Ï€'), LENGTHB('Ï€'), OCTET_LENGTH('Ï€');
+-------------------+--------------+---------------+--------------------+
| CHAR_LENGTH('Ï€') | LENGTH('Ï€') | LENGTHB('Ï€') | OCTET_LENGTH('Ï€') |
+-------------------+--------------+---------------+--------------------+
| 1 | 2 | 2 | 2 |
+-------------------+--------------+---------------+--------------------+In Oracle mode:
See Also
This page is licensed: GPLv2, originally from fill_help_tables.sql
Last updated
Was this helpful?

