2012-11-22 63 views
1

我想在Oracle數據庫中插入中文字符。Oracle中的多字節字符

select length('有個可愛的小娃在旁邊') from dual; 
10 
drop table multibyte; 
create table multibyte (name varchar2(10)); 
insert into multibyte 
values('有個可愛的小娃在旁邊'); 

我得到一個錯誤信息說

  An attempt was made to insert or update a column with a value 
      which is too wide for the width of the destination column. 
      The name of the column is given, along with the actual width 
      of the value, and the maximum allowed width of the column. 
      Note that widths are reported in characters if character length 
      semantics are in effect for the column, otherwise widths are 
      reported in bytes 

我知道,如果我增加列寬的問題可以想離開。 我的問題是當長度函數告訴我的寬度是10爲什麼我不能將它插入到varchar2(10)列?

回答

1

是的,這有點不幸。 Oracle以字節爲單位測量文本列長度,因此varchar2(10)只能存儲十個字節,大約三個中文字符。