2014-12-01 106 views
1
select rawtohex(UNISTR('\0436')) from dual 

收益0436甲骨文改變編碼

update my_table set my_column = UNISTR('\0436') where id = 248149; 
SELECT rawtohex(my_column) from my_table where id = 248149; 

返回E6

所以我把符號UTF8和拿回來的CP1251。爲什麼這樣?

+0

什麼是您的數據庫編碼?它可以存儲寬字符嗎? NLS_CHARACTERSET。如果不是,您可能需要重新安裝或使用NVARCHAR/NCLOB列。 – eckes 2014-12-01 16:31:55

回答

0

您正在將unicode字符串保存到varchar2列中。考慮將它們保存在nvarchar2類型列中。

create table my_table 
(
id number(10), 
my_column varchar2(100), 
my_column_uni nvarchar2(100) 
); 

insert into my_table values(1, UNISTR('\0436'), UNISTR('\0436')); 
commit; 

select rawtohex(my_column), rawtohex(my_column_uni) 
    from my_table 
where id = 1; 

的輸出將是對E6 VARCHAR2柱和0436爲NVARCHAR2列。 Oracle根據您的nls parameters更改編碼,其中您有NLS_CHARACTERSETNLS_NCHAR_CHARACTERSET NLS參數。你可以通過查詢你的具體參數。

select * 
from nls_database_parameters