Database Character Set & National Character Set


http://download.oracle.com/docs/cd/B10500_01/server.920/a96529/ch2.htm

Oracle uses the database character set for:

  • Data stored in SQL CHAR datatypes (CHAR, VARCHAR2, CLOB, and LONG)
  • Identifiers such as table names, column names, and PL/SQL variables
  • Entering and storing SQL and PL/SQL source code

The character encoding scheme used by the database is defined as part of the CREATE DATABASE statement. All SQL CHAR datatype columns (CHAR, CLOB, VARCHAR2, and LONG), including columns in the data dictionary, have their data stored in the database character set. In addition, the choice of database character set determines which characters can name objects in the database. SQL NCHAR datatype columns (NCHAR, NCLOB, and NVARCHAR2) use the national character set.


Note:

CLOB data is encoded as UCS-2 if the database character set is multibyte. If the database character set is single-byte, then CLOB data is stored in the database character set.


After the database is created, you cannot change the character sets, with some exceptions, without re-creating the database.

http://download.oracle.com/docs/cd/B19306_01/server.102/b14220/datatype.htm#i3253

NCHAR and NVARCHAR2 Datatypes

NCHAR and NVARCHAR2 are Unicode datatypes that store Unicode character data. The character set of NCHAR and NVARCHAR2 datatypes can only be either AL16UTF16 or UTF8 and is specified at database creation time as the national character set. AL16UTF16 and UTF8 are both Unicode encoding.

  • The NCHAR datatype stores fixed-length character strings that correspond to the national character set.

  • The NVARCHAR2 datatype stores variable length character strings.

When you create a table with an NCHAR or NVARCHAR2 column, the maximum size specified is always in character length semantics. Character length semantics is the default and only length semantics for NCHAR or NVARCHAR2.

For example, if national character set is UTF8, then the following statement defines the maximum byte length of 90 bytes:

CREATE TABLE tab1 (col1 NCHAR(30));

This statement creates a column with maximum character length of 30. The maximum byte length is the multiple of the maximum character length and the maximum number of bytes in each character.

优质内容筛选与推荐>>
1、放假相对于工作,似乎更喜欢工作了
2、windows系统日志怎么看
3、POJ3617
4、Python之False和None
5、Scala-Unit7-Scala并发编程模型AKKA


长按二维码向我转账

受苹果公司新规定影响,微信 iOS 版的赞赏功能被关闭,可通过二维码转账支持公众号。

    阅读
    好看
    已推荐到看一看
    你的朋友可以在“发现”-“看一看”看到你认为好看的文章。
    已取消,“好看”想法已同步删除
    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送

    已发送

    朋友将在看一看看到

    确定
    分享你的想法...
    取消

    分享想法到看一看

    确定
    最多200字,当前共

    发送中

    网络异常,请稍后重试

    微信扫一扫
    关注该公众号