All pages
Powered by GitBook
1 of 1

Loading...

LENGTH

Return the length of a string in bytes. This function counts the number of bytes in the string, which may differ from character count for multi-byte strings.

Syntax

Description

Returns the length of the string str.

In the default mode, when is not set, the length is measured in bytes. In this case, a multi-byte character counts as multiple bytes. This means that for a string containing five two-byte characters, LENGTH() returns 10, whereas returns 5.

When running Oracle mode, the length is measured in characters, and LENGTH is a synonym for .

If str is not a string value, it is converted into a string. If str is NULL, the function returns NULL.

Examples

When Oracle mode is not set:

In Oracle mode:

See Also

This page is licensed: GPLv2, originally from

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