2

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) の列に挿入できないのですか?

4

2 に答える 2

6

違いは、列の定義によるものです。はとVARCHAR2(10)同等VARCHAR2(10 BYTE)ですが、必要なのはVARCHAR2(10 CHAR)です。

列データ型のBYTEとCHARの違い

于 2012-11-22T03:19:27.013 に答える
1

ええ、それは少し残念です。Oracleはテキスト列の長さをバイト単位で測定するため、varchar2(10)は10バイト(約3漢字)しか格納できません。

于 2012-11-22T03:18:37.677 に答える