Purpose
TheLENGTHfunctionsreturn the length ofchar.LENGTHcalculates length usingcharacters as defined by the input character set.
--返回以字符为单位的长度.
LENGTHBusesbytes instead of characters.
--返回以字节为单位的长度.
LENGTHCusesUnicode complete characters.
--返回以Unicode完全字符为单位的长度.
LENGTH2usesUCS2 code points.
--返回以UCS2代码点为单位的长度.
LENGTH4usesUCS4 code points.
--返回以UCS4代码点为单位的长度.
charcan beany of the data typeschar,varchar2,nchar,nvarchar2,clob,ornclob.
The exceptionsareLENGTHC,LENGTH2, andLENGTH4, which do not allow chartobe aCLOBorNCLOB. The return value is of data typeNUMBER.Ifcharhas data typeCHAR, then the length includes all trailingblanks. Ifcharis null, then this function returns null.
Restriction on LENGTHB(Lengthb函数的限制)
TheLENGTHBfunctionis supported for single-byte LOBs only. It cannot be used withCLOBandNCLOBdatain a multibyte character set.
Examples
The followingexample uses theLENGTHfunction using a single-byte databasecharacter 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;