zoukankan      html  css  js  c++  java
  • oracle中nvarchar2字符集不匹配

    oracle当多表union时遇到nvarchar2类型时报错 字符集不匹配
    对使用nvarchar的地方,加上 to_char( nvarchar 的变量或字段 )

    如:
    select to_char(name),price from aa 
    union all
    select  to_char(name),price from bb 



    3张表aa,bb,cc都有 name price 字段 查询价格最高的前3位姓名

    select * from(select to_char(name),price from aa 
    union all
    select  to_char(name),price from bb 
    union all 
    select to_char(name),price from cc  order by price desc)where rownum<=3

    【注意】
    VARCHAR2是Oracle提供的特定数据类型,Oracle可以保证VARCHAR2在任何版本中该数据类型都可以向上和向下兼容。
    VARCHAR在Oracle中不建议使用。


    具体到NVARCHAR2和VARCHAR2的区别,从使用角度来看区别在于:NVARCHAR2在计算长度时和字符集相关的,例如数据库是中文字符集时以长度10为例,则

    1、NVARCHAR2(10)是可以存进去10个汉字的,如果用来存英文也只能存10个字符。

    2、而VARCHAR2(10)的话,则只能存进5个汉字,英文则可以存10个。 

  • 相关阅读:
    linux: convmv =-======pkgs.org
    ETL__pentaho__SPOON_PDI
    jira-source--plugin
    MAC OSX
    android gradle,groovy--https://blog.csdn.net/hebbely/article/details/79074460
    CentOS下Redis服务器安装配置
    mysql db imported into mongodb
    mongdb ---shard
    高精度整数
    CentOS 配置 Hadoop 2.6.5
  • 原文地址:https://www.cnblogs.com/telwanggs/p/4861193.html
Copyright © 2011-2022 走看看