Results 1 to 6 of 6
  1. #1
    Join Date
    Jun 2007
    Posts
    66

    Unanswered: Char for bit data datatype

    I have a table that is defined as
    CREATE TABLE "PPNAT"."TB6537"
    ("CALICENSEID" CHARACTER(13) FOR BIT DATA NOT NULL,
    ------------------------------------------------
    -------------------------------------------------
    )

    Can some one here tell the me the usage for the datatype CHARACTER(13) FOR BIT DATA??In what scenarios it can be used??

    Does it have the value of 0 and 1 ??

    Thanks

  2. #2
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    The data is stored as binary, but is output as hex values. The length is the number of bytes, so the output would be twice the length since there are two hex values for each byte:

    create table bit_data (COL1 CHAR(5) FOR BIT DATA);

    insert into bit_data values (x'4f33ca8b90');

    select * from bit_data;

    COL1
    -------------
    x'4F33CA8B90'

    This is usefull if you want to store binary data that contains non-printable characters such as a picture, sound file, or something smaller that is stored as binary.
    M. A. Feldman
    IBM Certified DBA on DB2 for Linux, UNIX, and Windows
    IBM Certified DBA on DB2 for z/OS and OS/390

  3. #3
    Join Date
    Jun 2007
    Posts
    66
    Thanks Marcus.

    What does 00 mean in hex?? When i pull output of a table file that has char for bit data it has several 00 values in it.
    Do they mean blank spaces that are padded towards the end of a field??

  4. #4
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    Quote Originally Posted by nivasreddy007
    Thanks Marcus.

    What does 00 mean in hex?? When i pull output of a table file that has char for bit data it has several 00 values in it.
    Do they mean blank spaces that are padded towards the end of a field??
    No, it means binary zeros. If you don't understand binary data and its hex representations, then you should go elsewhere to learn about that before asking any more questions in this forum.

    BTW: If you are using ascii code set, then a blank is represented by hex 20 (x'20').
    M. A. Feldman
    IBM Certified DBA on DB2 for Linux, UNIX, and Windows
    IBM Certified DBA on DB2 for z/OS and OS/390

  5. #5
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    Another aspect of FOR BIT DATA data types is that no code page conversions apply. After all, it is binary data and not text data that will be stored.
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

  6. #6
    Join Date
    Nov 2012
    Posts
    1

    char() for bit data

    Hello! in table data decleared as char but when i submit select command in ibm db2 udb it comes like char() for bita data.I do not know what the reason. Please help me

Posting Permissions

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