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 > null values

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-05-10, 02:42
oracle10gsingh oracle10gsingh is offline
Registered User
 
Join Date: Nov 2007
Posts: 72
null values

hi,

Could you please tell me whether null values consume space in db2 .I am on db2V9.5 on aix ...
Reply With Quote
  #2 (permalink)  
Old 05-05-10, 06:43
dbzTHEdinosaur dbzTHEdinosaur is offline
Registered User
 
Join Date: Jun 2007
Location: germany
Posts: 96
consumes space? NULL values?

don't confuse null with vacuum.

and 'null values' is an improper use of the terms.
null indicates that there is no value (data) associated with this column in this row.

In fact, a nullable column carries within the file structure supporting db2 an additional
field to indicate if the column is null or not null.

null or not null tells db2 whether to return a value for a column.

so actually, a nullable column whether null or not null, consumes more space that a 'not null column'.
__________________
Dick Brenholtz, Ami in Deutschland
Reply With Quote
  #3 (permalink)  
Old 05-07-10, 02:37
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Aside from the fact that NULL is not a value (because it is an inherent property that you can compare one value with another value of the same domain, which you can't do with NULLs), each nullable value requires an additional byte to be stored, i.e. the null indicator. So the answer is "yes", it consumes space.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #4 (permalink)  
Old 05-07-10, 03:48
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
Hopefully I am not being redundant, but:

If a column is defined in the create table as NOT NULL, it always takes up one less byte of storage compared to a column that is nullable. This is true regardless of whether a particular row has a null value or not null value for that column.

Along similar lines, a VARCHAR column requires 2 extra bytes of storage to store the length of the actual value being stored on any given row for that column value. This is true whether the value is null or not null.

So a VARCHAR column that is nullable always takes up 3 extra bytes compared to a CHAR column defined as NOT NULL (although obviously a VARCHAR column may require less storage than CHAR for the actual data if the entire length is not used).
__________________
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
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