473,503 Members | 1,656 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Column size for Multibyte data

Hi,

I have DB2 UTF-8 database (codeset IBM-1252) on Windows 2000 Server. I
need to store multi-byte contents. How do I calculate size of the
column to store multi-byte information?

F.ex: I cant have a column with size VARCHAR(10) bytes to store 10
multi-byte characters, because its going to run out of column size.
Do I have to simply double/tripple the column size simply by guessing?

In case of Oracle UTF-8 database I can have a table defination like

CREATE TABLE T (name VARCHAR2(10 CHARACTER));

Here I have a guarantee of storing 10 multi-byte characters. How do I
do the same in DB2.

Thanks

Sameer

May 9 '07 #1
5 11092
sameer_deshpande wrote:
Hi,

I have DB2 UTF-8 database (codeset IBM-1252) on Windows 2000 Server. I
need to store multi-byte contents. How do I calculate size of the
column to store multi-byte information?

F.ex: I cant have a column with size VARCHAR(10) bytes to store 10
multi-byte characters, because its going to run out of column size.
Do I have to simply double/tripple the column size simply by guessing?

In case of Oracle UTF-8 database I can have a table defination like

CREATE TABLE T (name VARCHAR2(10 CHARACTER));

Here I have a guarantee of storing 10 multi-byte characters. How do I
do the same in DB2.
Yes for VARCHAR you triple.
Alternatively you can use VARGRAPHIC which uses UCS-2 instead of UTF-8.
VARGRAPHIC(10) fits exactly 10 characters, but will always use 2 bytes
per character.
If you want to enforce a 10 character limit for VARCHAR you can use a
check constraint using the new character length function in DB2 9

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
May 9 '07 #2
sameer_deshpande wrote:
Hi,

I have DB2 UTF-8 database (codeset IBM-1252) on Windows 2000 Server. I
need to store multi-byte contents.
Are you sure? Codeset 1252 is Win-1252, basically a modification of the
ISO-8859-1 single byte codepage. UTF-8 is codeset 1208 in DB2. You'll
need codset 1208 if you want to use the GRAPHIC datatype as per Serge's
suggestion. If you created the database with something like:

CREATE DB MYDB CODESET UTF-8 TERRITORY ...

Then you should be fine. If you're not sure, check the default codepage
of the database with the following query:

SELECT CODEPAGE
FROM SYSCAT.DATATYPES
WHERE TYPESCHEMA = 'SYSIBM' AND TYPENAME = 'VARCHAR'

If the result isn't 1208, you've got a problem. As far as I know, you
can't change the codepage of an existing database.
HTH,

Dave.

--

May 9 '07 #3
On 9 Mai, 18:52, "Dave Hughes" <d...@waveform.plus.comwrote:
sameer_deshpande wrote:
Hi,
I have DB2 UTF-8 database (codeset IBM-1252) on Windows 2000 Server. I
need to storemulti-bytecontents.

Are you sure? Codeset 1252 is Win-1252, basically a modification of the
ISO-8859-1 single byte codepage. UTF-8 is codeset 1208 in DB2. You'll
need codset 1208 if you want to use the GRAPHIC datatype as per Serge's
suggestion. If you created the database with something like:

CREATE DB MYDB CODESET UTF-8 TERRITORY ...

Then you should be fine. If you're not sure, check the default codepage
of the database with the following query:

SELECT CODEPAGE
FROM SYSCAT.DATATYPES
WHERE TYPESCHEMA = 'SYSIBM' AND TYPENAME = 'VARCHAR'

If the result isn't 1208, you've got a problem. As far as I know, you
can't change the codepage of an existing database.

HTH,

Dave.

--
You are right. Result of the codepage column is indeed 1208. I was
wrong to specify codeset IBM-1252.

In UTF-8 database if I create a VARGRAPHIC column with size 10, then I
am able to insert 10 multi-byte charaters. What is the max column
length allowed for VARGRAPHIC data type. I could go upto
VARGRAPHIC(16336). Is this correct - 16336?
Thanks

Sameer

May 15 '07 #4
sameer_deshpande wrote:
On 9 Mai, 18:52, "Dave Hughes" <d...@waveform.plus.comwrote:
>sameer_deshpande wrote:
>>Hi,
I have DB2 UTF-8 database (codeset IBM-1252) on Windows 2000 Server. I
need to storemulti-bytecontents.
Are you sure? Codeset 1252 is Win-1252, basically a modification of the
ISO-8859-1 single byte codepage. UTF-8 is codeset 1208 in DB2. You'll
need codset 1208 if you want to use the GRAPHIC datatype as per Serge's
suggestion. If you created the database with something like:

CREATE DB MYDB CODESET UTF-8 TERRITORY ...

Then you should be fine. If you're not sure, check the default codepage
of the database with the following query:

SELECT CODEPAGE
FROM SYSCAT.DATATYPES
WHERE TYPESCHEMA = 'SYSIBM' AND TYPENAME = 'VARCHAR'

If the result isn't 1208, you've got a problem. As far as I know, you
can't change the codepage of an existing database.

HTH,

Dave.

--

You are right. Result of the codepage column is indeed 1208. I was
wrong to specify codeset IBM-1252.

In UTF-8 database if I create a VARGRAPHIC column with size 10, then I
am able to insert 10 multi-byte charaters. What is the max column
length allowed for VARGRAPHIC data type. I could go upto
VARGRAPHIC(16336). Is this correct - 16336?
http://publib.boulder.ibm.com/infoce...c/r0001029.htm

Correct. Of course storing such beats will require a 32K page size and a
one column table...

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
May 15 '07 #5
Serge Rielau wrote:
sameer_deshpande wrote:
[snip]
In UTF-8 database if I create a VARGRAPHIC column with size 10,
then I am able to insert 10 multi-byte charaters. What is the max
column length allowed for VARGRAPHIC data type. I could go upto
VARGRAPHIC(16336). Is this correct - 16336?
http://publib.boulder.ibm.com/infoce.../com.ibm.db2.u
db.admin.doc/doc/r0001029.htm

Correct. Of course storing such beats will require a 32K page size
and a one column table...
You may also wish to look into the DBCLOB data type[1] if you have a
large amount of double-byte character data to store (DBCLOB is to CLOB
as VARGRAPHIC is to VARCHAR).
[1] http://tinyurl.com/yseay6
HTH,

Dave.

--

May 15 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
4578
by: Brett Maton | last post by:
Hi NG, How do I find out the size of a column ? I am retrieving large objects from the pg_largeobject table and creating a files, I would like to know the length of the data column so that I...
18
5587
by: Zygmunt Krynicki | last post by:
Hello I've browsed the FAQ but apparently it lacks any questions concenring wide character strings. I'd like to calculate the length of a multibyte string without converting the whole string. ...
3
6826
by: yazan jab | last post by:
Is it true that Multibyte characters are : char arrays (witch represent a string from the basic characters set). In this case Wide characters are the way for encoding characters from the...
3
4209
by: Weiping | last post by:
Hi, while upgrade to 8.0 (beta3) we got some problem: we have a database which encoding is UNICODE, when we do queries like: select upper('ÖÐÎÄ'); --select some multibyte character, then...
2
2875
by: valinor | last post by:
Hi guys, (rather lengthy...) I'm trying to speed up the time spent on a postfilter for video. YUV 4:2:0 data, each pixel is 1 byte (0-255) The basic idea is to filter one pixel on each side...
1
2407
by: Nick | last post by:
hi all: the one of the column of gridview got multiple line data to be shown , so how do i deal with it? what i am thinking about is using template field instead of the boundfield. is that...
3
1984
by: dale.zjc | last post by:
I've got some bizarre behavior going on with my ASP code below. For some strange reason (and I'm a newbie to ASP so it's probably obvious to others) I can't display all the rows of data from the...
0
1384
by: Munch | last post by:
my C program deals with single byte characters but now i want to fetch multibyte data stored in the datbase so what all changes i need to make to the code so that it handles multibyte data as well....
0
1342
by: Munch | last post by:
my C program deals with single byte characters but now i want to fetch multibyte data stored in the datbase so what all changes i need to make to the code so that it handles multibyte data as well. ...
0
7198
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7072
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7319
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6979
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5570
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4998
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4666
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3160
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3149
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.