www.icesr.com
IT运维工程师的摇篮

oracle 11g nvarchar2 varchar2 varchar对比

oracle11g sql对比

nvarchar不支持,直接报错

<code><span class="hljs-operator"><span class="hljs-keyword">select</span> <span class="hljs-keyword">cast</span>(<span class="hljs-string">'二一'</span> <span class="hljs-keyword">as</span> nvarchar2(<span class="hljs-number">4</span>)) <span class="hljs-keyword">from</span> dual;</span> 
<span class="hljs-operator"><span class="hljs-keyword">select</span> <span class="hljs-keyword">cast</span>(<span class="hljs-string">'二一'</span> <span class="hljs-keyword">as</span> varchar2(<span class="hljs-number">4</span>)) <span class="hljs-keyword">from</span> dual;</span> 
<span class="hljs-operator"><span class="hljs-keyword">select</span> <span class="hljs-keyword">cast</span>(<span class="hljs-string">'二一'</span> <span class="hljs-keyword">as</span> varchar2(<span class="hljs-number">6</span>)) <span class="hljs-keyword">from</span> dual;</span> 
<span class="hljs-operator"><span class="hljs-keyword">select</span> <span class="hljs-keyword">cast</span>(<span class="hljs-string">'二一'</span> <span class="hljs-keyword">as</span> <span class="hljs-keyword">varchar</span>(<span class="hljs-number">4</span>)) <span class="hljs-keyword">from</span> dual;</span>

<span class="hljs-operator"><span class="hljs-keyword">select</span> <span class="hljs-keyword">cast</span>(<span class="hljs-string">'000'</span> <span class="hljs-keyword">as</span> nvarchar2(<span class="hljs-number">3</span>)) <span class="hljs-keyword">from</span> dual;</span> 
<span class="hljs-operator"><span class="hljs-keyword">select</span> <span class="hljs-keyword">cast</span>(<span class="hljs-string">'000'</span> <span class="hljs-keyword">as</span> varchar2(<span class="hljs-number">3</span>)) <span class="hljs-keyword">from</span> dual;</span> 
<span class="hljs-operator"><span class="hljs-keyword">select</span> <span class="hljs-keyword">cast</span>(<span class="hljs-string">'000'</span> <span class="hljs-keyword">as</span> <span class="hljs-keyword">varchar</span>(<span class="hljs-number">3</span>)) <span class="hljs-keyword">from</span> dual;</span> 

<span class="hljs-comment">--数据库编码</span>
<span class="hljs-operator"><span class="hljs-keyword">select</span> * <span class="hljs-keyword">from</span> nls_database_parameters <span class="hljs-keyword">where</span> parameter =<span class="hljs-string">'NLS_CHARACTERSET'</span>;</span>
<span class="hljs-comment">--客户端编码</span>
<span class="hljs-operator"><span class="hljs-keyword">select</span> * <span class="hljs-keyword">from</span> nls_instance_parameters <span class="hljs-keyword">where</span> parameter=<span class="hljs-string">'NLS_LANGUAGE'</span>;</span>
</code>

输出

<code>二一
二
二一
二
00
000
000

1   NLS_CHARACTERSET    AL32UTF8
1   NLS_LANGUAGE    AMERICAN</code>

varchar最大支持2000字节
nvarchar2/varchar2最大支持4000字节
varchar2中文3字节
nvarchar2中文2字节

nvarchar2非汉字显示不全

注:nvarchar2非汉字显示不全还是跟客户端有关,plsql显示不全,但是换成toad就可以正常显示了,plsql还是不够强大

未经允许不得转载:冰点网络 » oracle 11g nvarchar2 varchar2 varchar对比

分享到:更多 ()

评论 抢沙发

评论前必须登录!