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 > Char for bit data datatype

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-16-07, 17:48
nivasreddy007 nivasreddy007 is offline
Registered User
 
Join Date: Jun 2007
Posts: 66
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
Reply With Quote
  #2 (permalink)  
Old 11-16-07, 17:57
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
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
Reply With Quote
  #3 (permalink)  
Old 11-16-07, 18:04
nivasreddy007 nivasreddy007 is offline
Registered User
 
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??
Reply With Quote
  #4 (permalink)  
Old 11-16-07, 19:28
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
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
Reply With Quote
  #5 (permalink)  
Old 11-17-07, 05:22
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
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
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