我想查询5个表里2个属性BH和TM,语句如下:
select bh,tm from xuanze  where tm like '%十%'
union all
select bh,tm from tiankong where tm like '%十%'
union all
select bh,tm from panduan where tm like '%十%'
union all
select bh,tm from jianda where tm like '%十%'
union all
select bh,tm from biancheng where tm like '%十%';
单句都可以执行,可是上面一起执行就提示ORA-12704: 字符集不匹配
为什么?

解决方案 »

  1.   

    鎻愮ず閿欒鍦╯elect bh,tm璇彞 tm涓
      

  2.   

    那5个表中的bh,tm字段数据类型是一样的吗?根据你那提示的错,可能是字段数据类型不同
      

  3.   

    是的,在使用union all是每个字段的类型要一致,应该察看一下
      

  4.   

    是不是 nvarchar2 和 varchar2的原因?
    下面是参考解决办法:
    ORA-12704 character set mismatchCause: One of the following: 
    The string operands (other than an NLSPARAMS argument) to an operator or built-in function do not have the same character set. 
    An NLSPARAMS operand is not in the database character set. 
    String data with character set other than the database character set is passed to a built-in function not expecting it. 
    The second argument to CHR() or CSCONVERT() is not CHAR_CS or NCHAR_CS. 
    A string expression in the VALUES clause of an INSERT statement, or the SET clause of an UPDATE statement, does not have the same character set as the column into which the value would be inserted. 
    A value provided in a DEFAULT clause when creating a table does not have the same character set as declared for the column. 
    An argument to a PL/SQL function does not conform to the character set requirements of the corresponding parameter. Action: Strings declared with NCHAR or NCHAR VARYING do not interoperate with strings declared with CHAR or VARCHAR2. Use TRANSLATE() function to explicitly convert one to the other.