db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bernt M. Johnsen" <Bernt.John...@Sun.COM>
Subject Re: Characters and bytes
Date Tue, 19 Jun 2007 10:29:30 GMT
>>>>>>>>>>>> Williamson, Nick wrote (2007-06-19 11:09:34):
> Hi all,
> In Oracle, you can specify character columns widths in bytes (the
> default) or characters. The advantage of specifying column width in
> characters is that you can attempt to store - say - 10 multi-byte
> characters in a VARCHAR(10) column without getting an error.
> Derby doesn't seem to have an equivalent clause in the CREATE TABLE
> statement. What does it default to, and can the default be
> overridden?

In Derby the length of CHAR(n) and VARCHAR(n) is in caharcetrs, not in
bytes.  Java (and therefore in Derby) characters are Unicode, so
VARCHAR(10) will hold up to 10 Unicode characters. They will be
encoded in what the Java specification calls "Modified UTF-8" which
will be 1 to 3 bytes.

(You might run into problems if you have characters outside what is
called the "Basic Multilingual Plane", but that will only apply if you
deal with historic scripts like Cuneiform or Egyption Hieroglyphs etc)

Bernt Marius Johnsen, Database Technology Group, 
Staff Engineer, Technical Lead Derby/Java DB
Sun Microsystems, Trondheim, Norway

View raw message