Skip to content

LENGTHB

  • character_expression: This parameter represents the string for which the length is to be calculated. It can be of data type CHAR, VARCHAR2, NCHAR, NVARCHAR2, CLOB, NCLOB, or a string literal. LENGTHB returns the length in bytes instead of characters. The value returned by LENGTHB is of NUMBER data type. This function does not count trailing blanks.
SELECT LENGTHB('SHEEP') AS String_Length FROM dual;
STRING_LENGTH
-------------
5

The SQL code selects the byte length of the string ‘SHEEP’. The LENGTHB function in Oracle SQL returns the length in bytes of a given string. In this example, it returns 5, which is the number of bytes in ‘SHEEP’.