日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Oracle中NVARCHAR2与VARCHAR2的区别

發(fā)布時間:2025/5/22 编程问答 14 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Oracle中NVARCHAR2与VARCHAR2的区别 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

Oralce官方文檔“Datatypes”部分對NVARCHAR2、VARCHAR2以及VARCHAR有一段描述,可以清晰得到它們的區(qū)別。羅列在此,供大家參考。
【鏈接】http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/sql_elements001.htm#sthref71

NVARCHAR2 Datatype

The NVARCHAR2 datatype is a Unicode-only datatype. When you create a table with an NVARCHAR2 column, you supply the maximum number of characters it can hold.?Oracle?subsequently stores each value in the column exactly as you specify it, provided the value does not exceed the maximum length of the column.

The maximum length of the column is determined by the national character set definition. Width specifications of character datatype NVARCHAR2 refer to the number of characters. The maximum column size allowed is 4000 bytes. Please refer to Oracle Database Globalization Support Guide for information on Unicode datatype support.

VARCHAR2 Datatype

The VARCHAR2 datatype specifies a variable-length character string. When you create a VARCHAR2 column, you supply the maximum number of bytes or characters of data that it can hold. Oracle subsequently stores each value in the column exactly as you specify it, provided the value does not exceed the column's maximum length of the column. If you try to insert a value that exceeds the specified length, then Oracle returns an error.

You must specify a maximum length for a VARCHAR2 column. This maximum must be at least 1 byte, although the actual string stored is permitted to be a zero-length string (''). You can use the CHAR qualifier, for example VARCHAR2(10 CHAR), to give the maximum length in characters instead of bytes. A character is technically a code point of the database character set. CHAR and BYTE qualifiers override the setting of the NLS_LENGTH_SEMANTICS parameter, which has a default of bytes. For performance reasons, Oracle recommends that you use the NLS_LENGTH_SEMANTICS parameter to set length semantics and that you use the BYTE and CHAR qualifiers only when necessary to override the parameter. The maximum length of VARCHAR2 data is 4000 bytes. Oracle compares VARCHAR2 values using nonpadded comparison semantics.

To ensure proper data conversion between databases with different character sets, you must ensure that VARCHAR2 data consists of well-formed strings. See Oracle Database Globalization Support Guide for more information on character set support.

VARCHAR Datatype

Do not use the VARCHAR datatype. Use the VARCHAR2 datatype instead. Although the VARCHAR datatype is currently synonymous with VARCHAR2, the VARCHAR datatype is scheduled to be redefined as a separate datatype used for variable-length character strings compared with different comparison semantics.

【注意】
VARCHAR2是Oracle提供的特定數(shù)據(jù)類型,Oracle可以保證VARCHAR2在任何版本中該數(shù)據(jù)類型都可以向上和向下兼容。
VARCHAR在Oracle中不建議使用。

具體到NVARCHAR2和VARCHAR2的區(qū)別,從使用角度來看區(qū)別在于:NVARCHAR2在計算長度時和字符集相關(guān)的,例如數(shù)據(jù)庫是中文字符集時以長度10為例,則

1、NVARCHAR2(10)是可以存進(jìn)去10個漢字的,如果用來存英文也只能存10個字符。

2、而VARCHAR2(10)的話,則只能存進(jìn)5個漢字,英文則可以存10個。?

?

引用自:http://www.cnblogs.com/flyingfish/archive/2010/01/15/1648448.html

轉(zhuǎn)載于:https://www.cnblogs.com/powerwu/articles/4449503.html

總結(jié)

以上是生活随笔為你收集整理的Oracle中NVARCHAR2与VARCHAR2的区别的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。