ITPub博客

首页 > 应用开发 > IT综合 > Column Length Semantics

Column Length Semantics

原创 IT综合 作者:msdnchina 时间:2011-05-27 23:57:14 0 删除 编辑

http://download.oracle.com/docs/cd/B19306_01/server.102/b14226/repunicode.htm#i11177

Column Length Semantics for Replication Sites and Table Columns

Column length semantics determine whether the length of a column is specified in bytes or in characters. You use BYTE to specify that the length is in bytes, and you use CHAR to specify that the length is in characters. CHAR length semantics is also known as codepoint length semantics.

Because some character sets require more than one byte for each character, a specification of 10 BYTE for a column might actually store less than 10 characters for certain character sets, but a 10 CHAR specification ensures that the column can store 10 characters, regardless of the character set. Only Oracle9i Database or later databases can specify CHAR length semantics.

You set the length semantics for an Oracle database using the NLS_LENGTH_SEMANTICS initialization parameter, and all VARCHAR2 and CHAR columns use the setting specified for this initialization parameter as the default. If this initialization parameter is not set, then the default setting is BYTE.

An individual column can override the length semantics for the database. For example, if the length semantics for a site is CHAR, then you can still specify BYTE for the length semantics of an individual column using the CREATE TABLE or ALTER TABLE statement.

The following statement creates a table and specifies the column length in bytes:

CREATE TABLE byte_col (a VARCHAR2(10 BYTE));

The following statement creates a table and specifies the column length in characters:

CREATE TABLE char_col (a VARCHAR2(10 CHAR));

Note:

A database must have a compatibility level of 9.0.1 or higher to have CHAR length semantics. The compatibility level is controlled by the COMPATIBLE initialization parameter.

[@more@]

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/161195/viewspace-1050458/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2008-07-30

  • 博文量
    498
  • 访问量
    1542058