views:

49

answers:

2

Hi folks,

I've got a Varchar2 field in my table which I want to convert to a CLOB. I am unsure whether the data would get truncated when selected. If so, what is the limit and does it depend on the database settings?

In my TOAD or SQLPLUS window it gets truncated but this may just be the environment settings. I'm not sure whether it would get truncated in my actual application (I can test this, but up to what size should I test?)

If it does get truncated, what's the best way to display the whole CLOB? There are other fields in my SELECT query, so I think I can't just loop through multiple rows. Is there any way out?

Thanks for your help.

+2  A: 

In 10gR2 a CLOB can hold "(4 gigabytes - 1) * (database block size)", and the database block size is typically 8k.

So a CLOB can, in theory, be a terabyte of data which would be beyond the scope of most machines to cope with.

So the answer to "what size should I test" is whatever size you decide. I'd go with an order of magnitude larger than the limit I expect to process so if I'd was expecting a 5 MB value, I'd test with 50 MB. 50MB would be very big for text (though it may be appropriate if it was a log file of some sort).

Gary
Hi Gary,Thanks for your answer. I don't think I understood you properly. I know that CLOBs can store a large amount of data. What I don't know is whether some special handling is required to avoid truncation or whether CLOBs can be used in place of VARCHAR2 without any other steps.Do you mean that the whole CLOB will be displayed by default in a SELECT query? Or is it limited by the database block size?Is there any special handling to be done to display CLOBs in a select query? Or does it display the whole CLOB by default?
HappyCoder4U
What I'm saying is that, for very large CLOBs, you can get issues (eg memory allocation) and you wouldn't want to or be able to deal with grabbing hundreds of megabytes at a time. You'd want to deal with it in chunks (eg maybe 100K at a time).
Gary
Ah. Thanks for clarifying.
HappyCoder4U
+2  A: 

If you select a clob value from a table it depends on your application how it will handle it. If you change a varchar2 column to a clob column you will need to change your application so that it retrieves the clob data correctly from the database. So I guess the answer is: It is possible to get it working correctly.

Rene
Thanks for replying. Could someone please mark this as useful? I can't do this yet.
HappyCoder4U