Recently I’ve been experimenting with database character sets. For Oracle I’m able to set the character set to, for instance AL32UTF8, which can handle Unicode data for CHAR/VARCHAR columns. The only problem is that when you create a table with CHAR/VARCHAR columns you must explicitly state the size unit. If you create a column VARCHAR(20), there’s only 20 bytes reserved. However, this doesn’t mean that you can insert a string of length 20, since UTF8 encoding could yield more than 1 byte for a character. To cope with that Oracle allows you to specify the size of a column in character units. So VARCHAR(20 CHAR) means that the database should reserve enough space for 20 characters, and depending on the encoding (for UTF8b this will give us 4x20 and for UTF16 probably 2x20 bytes) enough bytes are reserved.
My question is; is it possible for DB2 to indicate the column sizes in character units? If the answer is no, how could we deal with varying character encodings and column sizes? Do we have a similar type in DB2?
Thanks in advance.