Introduction SQL

Basic SQL

SQL Constraints

Advance SQL

SQL Joins

SQL Function

SQL LENGTH Function


SQL LENGTH function return the length of string.

Supported Oracle SQL Version :

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

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