SQL LENGTH() Function

SQL LENGTH() Function return the length of string.

SQL LENGTH() function supported Oracle SQL version

  • Oracle 8i
  • Oracle 9i
  • Oracle 10g
  • Oracle 11g
  • Oracle 12c
  • Oracle 18c

Syntax

LENGTH(string)

LENGTH  - Length in character (supported data type CHAR, VARCHAR2, NCHAR, NVARCHAR2, CLOB, NCLOB)
LENGTHB - Length in bytes (supported only LOB data type)
LENGTHC - Length in Unicode (supported CLOB, NCLOB data type)
LENGTH2 - Length in code points
LENGTH4 - Length in code points

Example

Consider following example return the length of total number of character in given string argument.

SQL> SELECT LENGTH('opal kole') "LENGTH" FROM DUAL;

    LENGTH
----------
         9

SQL> SELECT LENGTH('opal') "LENGTH" FROM DUAL;

    LENGTH
----------
         4

SQL> SELECT LENGTH('123456 789') "LENGTH" FROM DUAL;

    LENGTH
----------
        10