oracle官方文檔- length篇

來源:互聯網
上載者:User

標籤:

首先介紹下 單一位元組字元集 和  多位元組字元集

2.2字元編碼方案
2.2.1 單位元組編碼
    (1)單位元組7位字元集,可以定義128個字元,最常用的字元集為 US7ASCII
    (2)單位元組8位字元集,可以定義256個字元,適合於歐洲大部分國家
    例如:WE8ISO8859P1(西歐、8位、ISO標準8859P1編碼 )
2.2.2 多位元組編碼
    (1)變長多位元組編碼
     某些字元用一個位元組表示,其它字元用兩個或多個字元表示,變長多位元組編碼常用於對亞洲語言的支援,   例如日語、漢語、印地語等
    例如:AL32UTF8(其中AL代表ALL,指適用於所有語言)、 zhs16cgb231280
    (2)定長多位元組編碼
    每一個字元都使用固定長度位元組的編碼方案,目前oracle唯一支援的定長多位元組編碼是AF16UTF16,也是僅用於國家字元集
2.2.3 unicode 編碼
    Unicode 是一個涵蓋了目前全世界使用的所有已知字元的單一編碼方案,也就是說Unicode為每一個字元提供唯一的編碼。UTF-16是unicode的16位編碼方式,是一種定長多位元組編碼,用2個位元組表示一個unicode字元,AF16UTF16是UTF-16編碼字元集。
    UTF-8 是unicode的8位編碼方式,是一種變長多位元組編碼,這種編碼可以用1、2、3個位元組表示一個unicode字元,AL32UTF8,UTF8、UTFE是UTF-8編碼字元集

 LENGTH

Syntax

length::=


Description of the illustration length.gif

Purpose

The LENGTH functions return the length of char. LENGTH calculates length using characters as defined by the input character set. LENGTHB uses bytes instead of characters. LENGTHC uses Unicode complete characters. LENGTH2 uses UCS2 code points. LENGTH4 uses UCS4 code points.

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 return value is of data type NUMBER. If char has data type CHAR, then the length includes all trailing blanks. If char is null, then this function returns null.

Restriction on LENGTHB The LENGTHB function is supported for single-byte LOBs only. It cannot be used with CLOB and NCLOB data in a multibyte character set.

Examples

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

SELECT LENGTH(‘CANDIDE‘) "Length in characters"  FROM DUAL;Length in characters--------------------                   7

The next example assumes a double-byte database character set.

SELECT LENGTHB (‘CANDIDE‘) "Length in bytes"  FROM DUAL; Length in bytes---------------             14

oracle官方文檔- length篇

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.