gpt4 book ai didi

oracle - Oracle 中的多字节字符

转载 作者:行者123 更新时间:2023-12-02 15:38:00 27 4
gpt4 key购买 nike

我想在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) 的列中?

最佳答案

不同之处在于列的定义:VARCHAR2(10) 等同于 VARCHAR2(10 BYTE),而您想要的是 VARCHAR2 (10 个字符)

Difference between BYTE and CHAR in column datatypes

关于oracle - Oracle 中的多字节字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13505367/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com