Results 1 to 7 of 7
  1. #1
    Join Date
    Mar 2008
    Posts
    3

    Unanswered: 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.

  2. #2
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    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

  3. #3
    Join Date
    Mar 2008
    Posts
    3
    No. For DB2/VM there are only VARCHAR and LONG VARCHAR for storing large size.

  4. #4
    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'.

  5. #5
    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

  6. #6
    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

  7. #7
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •