LENGTH2 is one of the vital string/char functions of Oracle. It is used to get the length of a string, same as the LENGTH function with the only difference that it uses the UCS2 code points. The LENGTH2 function is supported in the various versions of the Oracle/PLSQL, including, Oracle 12c, Oracle 11g, Oracle 10g, Oracle 9i and Oracle 8i.
Syntax:
LENGTH2 ( string )
Parameters:
string: It is used to specify the string whose length needs to get.
Example 1:
LENGTH2 (NULL) |
Output:
NULL
Explanation:
There is no string passed hence the result is NULL.
Example 2:
LENGTH2 (‘’) |
Output:
NULL
Explanation:
There is no string passed hence the result is NULL.
Example 3:
LENGTH2 (‘ ’) |
Output:
1
Explanation:
The SPACE is passed as a string, hence the result is 1.
Example 3:
LENGTH2 (‘HELLOWORLD.COM’) |
Output:
14
Explanation:
The total number of characters including the ‘.’ is 14 and so is the result..