LENGTHB function in Oracle

LENGTHB is one of the vital string/char functions of Oracle. It is used to get the length of a string, same as the LENGTH4 function with the only difference that it uses the bytes instead of characters. The LENGTHB function is supported in the various versions of the Oracle/PLSQL, including, Oracle 12c, Oracle 11g, Oracle 10g, Oracle 9i and Oracle 8i.

Syntax:

LENGTHB ( string )

Parameters:
string: It is used to specify the string whose length needs to get.

Example 1:

LENGTHB (NULL)

Output:

NULL

Explanation:
There is no string passed hence the result is NULL.

Example 2:

LENGTHB (‘’)

Output:

NULL

Explanation:
There is no string passed hence the result is NULL.

Example 3:

LENGTHB (‘ ’)

Output:

1

Explanation:
The SPACE is passed as a string, hence the result is 1.

Example 4:

LENGTHB (‘HELLOWORLD.COM’)

Output:

14

Explanation:
The total number of characters including the ‘.’ is 14 and so is the result..