LENGTH2

LENGTH2 is an SQL function that returns the length of a specified string, but unlike the LENGTH function, it calculates the length using byte. It thus helps determine the size of a Unicode string in bytes, accounting for multi-byte characters.

Example

SELECT LENGTH2('Oracle SQL') AS String_Length FROM dual;

Output

String_Length
-------------
10

Explanation

The LENGTH2 function in Oracle SQL returns the number of bytes in a given string. In the provided example, ‘Oracle SQL’ consists of 10 bytes, thus, the output is 10.

For in-depth explanations and examples SQL keywords where you write your SQL, install our extension.