There is no hard limit, it depends on the use case. I will update the
CLOB documentation as follows:
CLOB is like VARCHAR, but intended for very large values. Unlike when
using VARCHAR, large CLOB objects are not kept fully in-memory. CLOB
should be used for documents and texts with arbitrary size such as XML
or HTML documents, text files, or memo fields of unlimited size.
VARCHAR should be used for text with relatively short average size
(for example shorter than 200 characters). Short CLOBs are stored
inline, but there is an
overhead compared to VARCHAR. Use PreparedStatement.setCharacterStream
to store values.
Regards,
Thomas
> My general rule of thumb is that if it's ONE line of text, it's a
> VARCHAR, and if it's multiple lines, it's a CLOB.
Yes, this is a simple and good rule. There are some exceptions, for
example an address could be stored using multiple lines, but it
usually short enough for a VARCHAR.
> One word on CLOBs and XML: It's my experience that although XML is
> considered text, it should always go into a BLOB.
Maybe you are right. It seems that most XML APIs in Java use InputStream.
In many cases the encoding is hardcoded as UTF-8, and XML is processes
as a String in the application, or a Reader is used. In such cases
CLOB is OK.
Regards,
Thomas
> Hmm, I have only one line. Every time. But the line usually has about
> 30,000 chars in it.
> VARCHAR or CLOB?
CLOB.
> In MySQL I used column types like 'tinytext' and 'longtext'. Does H2
> use/know these types, too?
H2 maps the data types to BLOB. For the list of supported data types I
suggest you have a look at the H2 documentation.
Regards,
Thomas
Sorry, to CLOB of course ;-)