w3resource

Oracle LENGTH function

Description

The Oracle LENGTH function is used to return the length of a given string. If the string has data type CHAR, then the length includes all trailing blanks. If a string is null, then this function returns null.

LENGTHB uses bytes instead of characters. LENGTHC uses Unicode complete characters. LENGTH2 uses UCS2 code points. LENGTH4 uses UCS4 code points.

Syntax:

{ LENGTH
| LENGTHB
| LENGTHC
| LENGTH2
| LENGTH4
}
(string1)

Parameters:

Name Description Data Types
string1 The string to return the length for. CHAR, VARCHAR2, NCHAR, NVARCHAR2, CLOB, or NCLOB exceptions are LENGTHC, LENGTH2, and LENGTH4, which do not allow char to be a CLOB or NCLOB.

Return Value Type

NUMBER

Applies to

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

Examples: Oracle LENGTH function

The following example uses the LENGTH function using a single-byte database character set:

SELECT LENGTH('w3resource.com') "Length in characters"
FROM DUAL;
 

Sample Output:

Length in characters
--------------------
                  14

Previous: INSTR
Next: REGEXP_COUNT



Follow us on Facebook and Twitter for latest update.