473,899 Members | 4,542 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 11124
sameer_deshpand e 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_deshpand e 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.DATATYPE S
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_deshpand e 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.DATATYPE S
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(1633 6). Is this correct - 16336?
Thanks

Sameer

May 15 '07 #4
sameer_deshpand e wrote:
On 9 Mai, 18:52, "Dave Hughes" <d...@waveform. plus.comwrote:
>sameer_deshpan de 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.DATATYPE S
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(1633 6). 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_deshpand e 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(1633 6). 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
4608
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 can implement buffering instead of writing hundreds of small chunks to disk. Any help would be appreciated.
18
5625
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. Zygmunt PS: The whole multibyte string vs wide character string concept is broken IMHO since it allows wchar_t not to be large enough to contain a full character (rendering both types virtually the same). What's the point of
3
6864
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 extended characters set. or Multibyte characters are: characters from the extended character set which need more than one byte to encode. And in this case wide
3
4241
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 postgresql response: ERROR: invalid multibyte character for locale
2
2908
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 of a 8-pixel border. The filter used is a variant of (1,1,-4,1,1).
1
2428
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 other solution out there? Cheers Nick
3
2004
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 query. As an example, the Problem Solution column doesn't display and unless I comment out another column. Or if I move Problem Solution and it make ithe first column, then the Root Cause won't display. Here's the code: <%
0
1419
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. i know about wide characters and convertion from wide to multibyte.but m not sure of where to start from. what all header files to include? do i need to change locale type or include some codepage and if yes how to do all these? m supposed to...
0
1368
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. i know about wide characters and convertion from wide to multibyte.but m not sure of where to start from. what all header files to include? do i need to change locale type or include some codepage and if yes how to do all these? I think I need...
0
9843
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11272
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10863
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10494
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9666
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8039
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7201
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5887
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6081
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.