If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > DB2/VM and LONG VARCHAR

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-07-08, 09:17
pascalou pascalou is offline
Registered User
 
Join Date: Mar 2008
Posts: 3
DB2/VM and LONG VARCHAR

HI,
I'm on DB2/VM 7.3.0.
I want use the LONG VARCHAR data type for a column and I don't understand how it works. I thought long varchar areas occupied more space than the varchar. It seems that this is not always the case. Do you have any idea on that? Which is the used real space?
Thank you for your help.
Reply With Quote
  #2 (permalink)  
Old 03-07-08, 09:45
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
I don't know if this is applicable for DB2/VM as well, but for DB2 LUW, the recommendation is to not use LONG VARCHAR. Either stick to VARCHAR (which can be up to nearly 32K in size) or use CLOBs for anything bigger.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #3 (permalink)  
Old 03-07-08, 10:56
pascalou pascalou is offline
Registered User
 
Join Date: Mar 2008
Posts: 3
No. For DB2/VM there are only VARCHAR and LONG VARCHAR for storing large size.
Reply With Quote
  #4 (permalink)  
Old 03-07-08, 11:34
nidm nidm is offline
Registered User
 
Join Date: May 2003
Posts: 113
long varchar is just a varchar that can be longer, you can just use it as varchar. It only take larger space if the varchar data is large. I think, at some point, a normal varchar can be only 255 bytes, so people use 'long varchar' for data that more than 1K(I may be wrong).

Starting v8, all varchar can be 32K. You can just use varchar. 'long varchar' is legacy.


BTW, I believe, the name is 'DB2 for z/OS'.
Reply With Quote
  #5 (permalink)  
Old 03-09-08, 04:54
guyprzytula guyprzytula is offline
Registered User
 
Join Date: Jun 2006
Posts: 471
no, all these answers are wrong
the question was for DB2/VM or VSE and not z/os - mvs - os/390 - luw
in vm whenever a varchar is longer than 255 it is treated as longvarchar
the long varchar are not saved on the same pages as the original row, as is could not fit on the page. an additional special page is acquired to store the long field and the original field is replaced by a pointer to this page. there is a slight overhead and can not be indexed..
__________________
Best Regards, Guy Przytula
DB2 UDB LUW certified V6/7/8
Reply With Quote
  #6 (permalink)  
Old 03-10-08, 11:17
pascalou pascalou is offline
Registered User
 
Join Date: Mar 2008
Posts: 3
Thanks Guy,
So, can we say that a column LONGVARCHAR takes only 4 bytes where the column is empty and not 255 as everyone seemed to think?
And how many byte when there are only, for axxample, 10 bytes in the column?
Best regards
pascal BEAU
Reply With Quote
  #7 (permalink)  
Old 03-11-08, 04:35
guyprzytula guyprzytula is offline
Registered User
 
Join Date: Jun 2006
Posts: 471
if the long varchar is 10 bytes you will have the pointer to the page (i believe 4 bytes) and the long field 10bytes + 2 bytes for the length I believe
__________________
Best Regards, Guy Przytula
DB2 UDB LUW certified V6/7/8
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On