All pages
Powered by GitBook
1 of 1

Loading...

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

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, (or in ) 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

When is not set:

In :

See Also

This page is licensed: GPLv2, originally from

CHAR_LENGTH(str)
CHARACTER_LENGTH(str)
LENGTH()
OCTET_LENGTH()
LENGTH()
LENGTHB()
OCTET_LENGTH()
fill_help_tables.sql
SELECT CHAR_LENGTH('MariaDB');
+------------------------+
| CHAR_LENGTH('MariaDB') |
+------------------------+
|                      7 |
+------------------------+
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 |
+-------------------+--------------+---------------+--------------------+
Oracle mode
Oracle mode
Oracle mode
Oracle mode