All pages
Powered by GitBook
1 of 1

Loading...

OCTET_LENGTH

Return the length of a string in bytes. This function is a synonym for LENGTH() and returns the number of bytes in the string.

Syntax

Description

OCTET_LENGTH() returns the length of the given string, in octets (bytes). This is a synonym for , and, when is not set, a synonym for .

A multi-byte character counts as multiple bytes. This means that for a string containing five two-byte characters, OCTET_LENGTH() 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.

Examples

When Oracle mode is not set:

In Oracle mode:

See Also

This page is licensed: GPLv2, originally from

OCTET_LENGTH(str)
LENGTHB()
LENGTH()
CHAR_LENGTH()
CHAR_LENGTH()
LENGTH()
LENGTHB()
fill_help_tables.sql
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