1. 程式人生 > >Oracle中 Union 中 ORA-12704:字符集不匹配問題的解決

Oracle中 Union 中 ORA-12704:字符集不匹配問題的解決

錯誤原因

在使用Union 連線時,若A集合中某列為nvarchar2或nvarchar型別,而B表或者更多表對應的是varchar2或者是varchar型別時,則會報ORA-12704:字符集不匹配問題的解決

解決方法

to_char()函式

select a.id as ID,a.title as Title, a.apply_reason as applyReason from table1 a
union 
select b.id as ID , to_char(b.name) as Title ,  to_char(b.use) as applyReason from table2 b