CHAR_LENGTH(str)
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.
Until MariaDB 10.3.1, returns MYSQL_TYPE_LONGLONG
, or bigint(10), in all cases. From MariaDB 10.3.1, returns MYSQL_TYPE_LONG
, or int(10), when the result would fit within 32-bits.
SELECT CHAR_LENGTH('MariaDB'); +------------------------+ | CHAR_LENGTH('MariaDB') | +------------------------+ | 7 | +------------------------+ SELECT CHAR_LENGTH('π'); +-------------------+ | CHAR_LENGTH('π') | +-------------------+ | 1 | +-------------------+
© 2019 MariaDB
Licensed under the Creative Commons Attribution 3.0 Unported License and the GNU Free Documentation License.
https://mariadb.com/kb/en/char_length/