问题描述
我在DB2 UTF-8数据库中的日语字符插入中有一些数据被拒绝到
Varchar列。我正在努力了解
如何让inesert的Varchar专栏成功地为我的所有数据工作。我还想了解Vargraphic是否是一种更好的方法以及可能产生的后果。
这些数据来自UTF-8 Oracle(使用字节语义)
将列定义为
Varchar2(255)。我已经定义了我的DB2列Varchar(255),但
插入拒绝了一些行。
列,指定键的值为8。但是,对于这个在DB2端加载的相同密钥,我得到的长度为
33.有时候,DB2端的长度超过5倍
Oracle方面。我不明白这是怎么回事。
此外,有人可以澄清DB2以字节为单位分配的存储量,对于
以下(假设不可为空) )?我的假设如下 -
CHAR(1) - 假设1个字节
CHAR(100) - 假设100个字节
VARCHAR (1) - 假设长度+ 1字节= 2字节
VARCHAR(100) - 假设长度+ 100字节=最多101字节
VARGRAPHIC(100) - ?
提前感谢您的帮助。
I am having some data reject on an insert of Japanese characters to a
Varchar column in my DB2 UTF-8 database. I am trying to understand how
big to make the Varchar column for the inesert to work successfully for
all of my data. I would also like ot understand if Vargraphic is a
better approach and what ramifications that might have.
This data is sourced from UTF-8 Oracle (using byte semantics) which
defines a columns as
Varchar2(255). I had defined my DB2 columns Varchar(255) but the
insert rejects some rows.
I notice that for Oracle : if I apply the length function to a specific
column , I get a value of 8 for a specified key. However, for this
same key that sucecssfully loaded on the DB2 side, I get a length of
33. Sometimes, the length on the DB2 side is more than 5 times the
Oracle side. I do not understand how this can be.
Also, Can someone clarify how much storage DB2 allocates in bytes, for
the following (assume non-nullable) ? My assumptions are below -
CHAR(1) - assume 1 byte
CHAR(100) - assume 100 bytes
VARCHAR(1) - assume length + 1 byte = 2 bytes
VARCHAR(100) - assume lenght + 100 bytes = 101 bytes at most
VARGRAPHIC(100) - ?
Thank you in advance for your assistance.
推荐答案
我会在DB2中将VARCHAR的大小增加三倍。在DB2中使用VARCHAR可以达到大约32K
(不完全)。
DB2使用2个额外字节作为长度,但这并没有减少数据的空间金额为
。如果它可以为空,则使用一个额外的字节。
I would triple the size of the VARCHAR in DB2. You can go up to about 32K
(not quite) with VARCHAR in DB2.
DB2 uses 2 extra bytes for the length, but that does not reduce the amount
of space for the data. If it is nullable, it uses one additional byte.
这篇关于在UTF-8数据库中存储日文字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!