Purpose
The LENGTH functionsreturn the length ofchar. LENGTH calculates length usingcharacters as defined by the inputcharacter set.
--返回以字符为单位的长度.
LENGTHB usesbytes instead of characters.
--返回以字节为单位的长度.
LENGTHC usesUnicode complete characters.
--返回以Unicode完全字符为单位的长度.
LENGTH2 usesUCS2 code points.
--返回以UCS2代码点为单位的长度.
LENGTH4 usesUCS4 code points.
--返回以UCS4代码点为单位的长度.
char can be any of the data types CHAR,VARCHAR2, NCHAR, NVARCHAR2, CLOB, or NCLOB. The exceptions are LENGTHC,LENGTH2, and LENGTH4, which do not allow char to be a CLOB or NCLOB. The returnvalue is of data type NUMBER. If char has data type CHAR, then the lengthincludes all trailing blanks. If char is null, then this function returns null.
Restriction on LENGTHB The LENGTHB functionis supported for single-byte LOBs only. It cannot be used with CLOB and NCLOBdata in a multibyte character set.
Examples
The following example uses the LENGTHfunction using a single-byte database character set:
SELECT LENGTH('CANDIDE') "Length incharacters"
FROM DUAL;
Length in characters
--------------------
7
The next example assumes a double-bytedatabase character set.
SELECT LENGTHB ('CANDIDE') "Length inbytes"
FROM DUAL;